Contract Deployment
You can deploy smart contracts in CosmPy using LedgerContract. For this, you will need the path to where the contract is stored (in this case simple.wasm), a LedgerClient and a Wallet:
from cosmpy.aerial.contract import LedgerContract
PATH = "../simple.wasm"
contract = LedgerContract(PATH, ledger_client)
contract.deploy({}, wallet)
You can now start interacting with the contract. To get the address of where the contract is deployed on the network:
You can query the values of the contract's state variables:
You can also set these values. The following sets the state variable value to foobar:
Let's check if this was set correctly:
result = contract.query({"get": {"owner": str(wallet.address())}})
print("State after set:", result)
Similarly, you can clear the state variables: