Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.6 KB

README.md

File metadata and controls

41 lines (28 loc) · 1.6 KB

Python Smart Contracts for Cardano

This is a prototypical implementation of smart contracts for Cardano which are written in a subset of valid Python.

Important note This project is a PoC and not ready for use. For a project that is already workable, check out OpShin

The general philosphy of this project is to write a compiler that ensure the following:

If the program compiles then:

  1. it is a valid Python program
  2. the output running it with python is the same as running it on-chain.

This specificially means that not every valid python program is a valid smart contract. Not all language features of python will or can be supported. The reasons are mainly of practical nature (i.e. we can't infer types when functions like eval are allowed).

For your program to be accepted, make sure to only make use of language constructs supported by the compiler. You will be notified of which constructs are not supported when trying to compile.

Architecture

This program consists of a few independent components:

  1. An aggressive static type inferencer
  2. Rewriting tools to simplify complex python expressions
  3. A compiler from a subset of python into UPLC/pluto
  4. The UPLC/pluto toolchain in python

Running

Write your program in python. You may start with the example.py. Then run

python3 -m uplc compile example.py

Note: this is the final desired state. I am currently too lazy to both with setting up the module so just put your code into the string at test.py and run python3 test.py