completed

PyCardano - Build dApps in Python

$104,781.00 Received
$104,781.00 Requested
Ideascale logo View on ideascale
Community Review Results (1 reviewers)
Addresses Challenge
Feasibility
Auditability
ソリューション

Create a library for developers to write off-chain code in Python, so they can be freed from learning and writing off-chain code in Haskell.

Problem:

Developers without Haskell experience need to spend months in learning Haskell before they can productively build dApps on Cardano.

Yes Votes:
₳ 102,644,163
No Votes:
₳ 13,660,866
Votes Cast:
707

チーム

This proposal was approved and funded by the Cardano Community via Project F8: Developer Ecosystem Catalyst funding round.

[IMPACT]

PyCardano will provide developers with APIs to write entire off-chain code for their dApps in Python. For Python developers, it means instead of spending weeks or even months in learning advanced Haskell, they can now build dApps in days (see more details and explanations in next section).

The library will have core functionalities that enable developers to:

  • compose datums and redeemers, which are used in transactions that interact with Plutus script

  • query and deserialize datums and redeemers to Python object

  • build transactions to interact with Plutus script

  • stake ADA locked in Plutus scripts to designated pools

  • test different use cases and scenarios on a local chain

  • deploy Plutus scripts to testnet and mainnet

Apart from core functionalities, we will also create two end-to-end educational dApps that can be directly deployed to testnet or mainnet. The dApps will be similar to the ones in Plutus pioneer program [1], but with all off-chain code written in Python. To get a sense of sample dApp, check out this example dApp built by the proposer: https://github.com/cffls/pycardano/tree/main/examples/full_stack. The linked dApp is built with PyCardano. Users can send ADA to multiple addresses with Nami wallet, which is impossible with Nami wallet alone.

[1] Plutus pioneer program: <https://testnets.cardano.org/en/plutus-pioneer-program/>

A complete Cardano dApp usually consist of two main components: 1) on-chain Plutus script(s), which usually defines the core business logic of the dApp, and 2) off-chain code through with users' wallets will interact with the Plutus script.

Plutus application backend (PAB) provides an all-in-one solution where developers can write Haskell code for both on-chain and off-chain code. However, off-chain code requires non-trivial understanding of Haskell, such as Monad [1] and type families [2], which means weeks, if not months, of learning for new Haskell developers to fully master. Additionally, off-chain code is usually more complex and longer than on-chain code, because it is responsible for handling all use cases and scenarios for users to interact with Plutus scripts. Hence, for developers without prior Haskell experience, it will take a significant amount of time to learn, write, and debug off-chain code. A supporting evidence is that Plutus pioneer program is a ten-week long program, and there is a week dedicated to Monad [3]. The steep learning curve of Haskell does not only affect development speed, but also discourages new developers who want to build on Cardano, and could potentially slow down developer adoption.

What if we provide developers with a library by which they can write all off-chain code in one of the most popular programming languages, Python? Instead of spending time on learning advanced Haskell, developers can write simple Python code, and building dApps suddenly becomes much easier! Thousands of Python developers will be able to quickly learn, understand, and build Cardano dApps, not in weeks or months, but in days.

Some people might ask if using Python will jeopardize the security of Cardano's smart contract in a certain degree. The short answer is no. As a reminder, on-chain code will still need to be written in Haskell/Plutus, and only the gigantic off-chain code will be written in Python. The main security of Plutus script is coming from its on-chain part, which basically determines Who, How, and When could the locked fund be spent. This part is intact and therefore secured. Only the off-chain part will be written in Python. A resulting benefit of such combination is that developers can enjoy the security brought by Plutus and the easiness and simplicity brought by Python.

[1] Monad: https://wiki.haskell.org/All_About_Monads

[2] Type families: https://wiki.haskell.org/GHC/Type_families

[3] Plutus-pioneer-program, Monad: <https://github.com/input-output-hk/plutus-pioneer-program#lecture-4>

Potential challenges:

  • Changes in Cardano's ledger in future hard folks. We will address this by closely following the latest ledger changes and update the library accordingly.

    [FEASIBILITY]

There will be three milestones for this project: 1) core Plutus Python APIs, 2) Plutus Python SDK, 3) educational sample dApps. See below for details of milestones and their deliverables.

Core Plutus APIs in Python (12 weeks). This milestone provides all necessary Python APIs for developers to create script transactions.

Deliverables:

  • Serialization and deserialization for datum and redeemer

  • Transaction builder that supports script transactions

  • Automatic fee estimation for script transactions

  • Stake delegation for funds locked in Plutus scripts

  • API documentations

Plutus Python SDK (6 weeks). This milestone provides toolings for developers to create, test, and manage their projects in shorter amount of time.

Deliverables:

  • Helper functions for dApp environment setup and simulation

  • Command line interface (CLI) that launches and manages local testnet

  • CLI that bootstraps dApp projects

  • CLI that creates and manages wallets

  • CLI that builds and tests dApps

  • CLI that deploys Plutus scripts to blockchain

Educational dApps (8 weeks). This milestone introduces the Python library to a broader audience by showing how to use the library in real working dApps.

Deliverables:

  • Two end-to-end full stack dApps

  • Backend built on the APIs and SDK from previous milestones

  • Frontend webApp where users will be able to use light browser wallet to use the dApp

  • Comprehensive documentations on the designs and architectures for the dApps

  • Detailed blog posts about building

Total budget: $104,781

Budget breakdown

The budget consists of two parts, software development cost ($104,000) and cloud computing cost ($781). Please see the details below.

<u>Software development cost</u>

Total: $104,000

There will be three milestones in this project:

  • core Plutus Python APIs
  • Plutus Python SDK
  • educational sample dApps.

We are aiming to create Python SDKs with highest standards, which means:

  • the APIs and CLIs should be easy and intuitive to use
  • the code should be clean, easily readable, testable, and well-documented
  • the code should be fully covered by unit tests and integration tests
  • the code should be easily maintainable, and extensible for future changes and new features

Considering all functional and non-functional requirements, we need a full-time senior software engineer to work on the project for 26 weeks. With current market rate in the US, this translates to a budget of $104,000 in total (26 weeks x 40 hours/week x $100/hour).

<u>Cloud computing and storage</u>

Total: $781

In development, large scale testing and experiments require cloud computing resources. We will use AWS EC2 to host cardano-node and cardano-db-sync (or its alternatives).

Computing budget: $521

One t3.xlarge instances for cardano-node and one t3.2xlarge for db-sync (32GB ram required [1]) for for 40 hours per week and for 26 weeks in total. Calculation: [$0.167 (t3.xlarge hourly rate) + $0.3341 (t3.2xlarge hourly rate)] x 40 hours x 26 weeks. [2]

Storage budget: $260

200GB General Purpose SSD (gp2) for two EC2 instances.

Calculation: 2 x 200GB x $0.1/GB-month x 6.5 Months [3]

[1] cardano-db-sync hardware requirement: https://github.com/input-output-hk/cardano-db-sync#system-requirements

[2] AWS t3 instance rates: https://aws.amazon.com/ec2/instance-types/t3/

[3] AWS EBS rates: https://aws.amazon.com/ebs/pricing/

Jerry Chen, a senior software engineer with many experiences Cardano. He built PyCardano [1], a lightweight Cardano library in Python built with his passion in Cardano and blockchain. The library already supports many features, such as transferring funds and minting NFTs. He also created many sample Python scripts [2] that shows how to use PyCardano. This proposal is a continuation of PyCardano, whose ultimate goal is to provide the best Cardano developer experience for Python programmers.

Although PyCardano is not previously a Catalyst proposal, it has gained lots of tractions from the community. Since its first release on 2/15/2022, there has been more than 400 PyPI downloads in a month [3], which showed the strong demand of this tool among developers, as well as the quality and usefulness of this library.

[1] PyCardano: https://github.com/cffls/pycardano

[2] PyCardano examples: https://github.com/cffls/pycardano/tree/main/examples

[3] PyPI download stats: https://pypistats.org/packages/pycardano

[AUDITABILITY]

The progress and development of this project could be tracked by the completion of each milestones listed previously.

12 weeks after funding:

  • Developers will be able to use Plutus Python APIs to create and submit script transactions.

  • Developers will be able to use the API to stake the funds locked in Plutus script to any pool.

  • Developers will be able to use the API to develop basic dApps.

  • Weekly PyPI downloads of the library reaches 100+.

18 weeks after funding:

  • Developers will be able to use the Python Plutus SDK to create, develop, test, manage, and deploy new dApps in less than a week.

  • Weekly PyPI downloads of the library reaches 150+.

26 weeks after funding:

  • Developers will be able to build and deploy a sample dApp in less than 15 minutes.

  • Weekly PyPI downloads of the library reaches 200+.

This is an entirely new Catalyst proposal. However, this proposal is a continuation of the development of PyCardano, an open source project the proposer has been working on for free in the past couple of months.

コミュニティ・アドバイザー・レビュー (1)

Comments

Monthly Reports

We have started Milestone 1 for PyCardano even before the approval of our catalyst proposal, because we are so passionate about Cardano. : ) At the moment, users can already use PyCardano to write basic off-chain code to interact with Plutus scripts. A missing feature is a public API for users to include minting scripts in a transaction. We will work on this API along with some API improvements, and create a detailed example of minting NFT with Plutus script by the end of next month.

Disbursed to Date
$104,781
Status
Still in progress
Completion Target
11/4/2022
Comments 0

Login or Register to leave a comment!

We are very close to finishing milestone 1 (plutus support) of the project. As Vasil hardfork is approaching, we are working on updating the library to support new features that will be introduced in Vasil era. The work is estimated to take two weeks. On completing Vasil support, we will be moving to the milestone 2. In terms of adoption, the weekly download of the library has now reached to 600, comparing to 400 last month, which is an indication of positive adoption growth.

Disbursed to Date
$104,781
Status
Still in progress
Completion Target
11/5/2022
Attachment(s)
Comments 0

Login or Register to leave a comment!

We finished the implementation of Vasil update, and added integration tests for the library. Next month, we will be working on milestone 2 features, such as a command line tool of launch test network and function create testing accounts.

Disbursed to Date
$104,781
Status
Still in progress
Completion Target
3. In the next 6 months
Attachment(s)
Comments 0

Login or Register to leave a comment!

We are working towards the completion of milestone 2. At the same time, we've started working on the final milestone - building educational dApps using PyCardano. The first dApp will be a vesting tool where users can lock funds/nfts in a contract, which could only be released after a specified future time.

Disbursed to Date
$104,781
Status
Still in progress
Completion Target
2. In the next 3 months
Comments 0

Login or Register to leave a comment!

We've completed milestone 2, and now started the work on milestone 3, which is building dApps using PyCardano. The dApp we are building is a vesting app that allows users to grant and vest ADA tokens. The backend of the dApp will be completely built on PyCardano.

Disbursed to Date
$104,781
Status
Still in progress
Completion Target
2. In the next 3 months
Comments 0

Login or Register to leave a comment!

We are actively developing on milestone 3 - building dApps using PyCardano. We have completed the majority part of the offchain code using PyCardano. The remaining work is building the frontend UI and connecting it to the backend server. In terms of library adoption, we are meeting the goal of 250 weekly downloads.

Disbursed to Date
$104,781
Status
Still in progress
Completion Target
1. In the next month
Comments 0

Login or Register to leave a comment!

close

Playlist

  • EP2: epoch_length

    Authored by: Darlington Kofa

    3分 24秒
    Darlington Kofa
  • EP1: 'd' parameter

    Authored by: Darlington Kofa

    4分 3秒
    Darlington Kofa
  • EP3: key_deposit

    Authored by: Darlington Kofa

    3分 48秒
    Darlington Kofa
  • EP4: epoch_no

    Authored by: Darlington Kofa

    2分 16秒
    Darlington Kofa
  • EP5: max_block_size

    Authored by: Darlington Kofa

    3分 14秒
    Darlington Kofa
  • EP6: pool_deposit

    Authored by: Darlington Kofa

    3分 19秒
    Darlington Kofa
  • EP7: max_tx_size

    Authored by: Darlington Kofa

    4分 59秒
    Darlington Kofa
0:00
/
~0:00