For this quick ‘how-to’, we will be using Jupyter Notebook. Jupyter is a great tool for Python programmers to develop and explore in as they combine the high feedback of a REPL with the presentation and saving of a program.
If you are a Python programmer, chances are you already have Jupyter installed. If not, follow this guide to get started. After that, just start the notebook:
Contracting has a super high level client that allows you to develop smart contracts without any knowledge of the underlying mechanics of the execution system. This makes it perfect for new comers to the library.
from contracting.client import ContractingClient
client = ContractingClient()
If initializing the client hangs, that means your database is not running and Contracting can’t connect to where it stores data.
The following will be our first smart contract. Recreate it in your notebook.
def add(a: int, b: int):
return private_add(a, b)
def private_add(a, b):
return a + b
Off the bat, notice three things:
>> ['hello_world', 'submission']
If the 'hello_world' contract now appears in the returned list, you’ve successfully submitted your first smart contract. Congrats!
NOTE: For submitting closures, the name of the contract is automatically taken from the name of the closure. def my_func(): becomes my_func in the smart contract state space, etc. You can override this by passing the name argument into submit.
Telegram: t.me/lamdenchatDiscord: discord.gg/xjBgcAAUpSReddit: reddit.com/r/lamden