Skip to main content

Python wrapper for interacting with the DERO blockdag

Project description

pydero

Pydero is a python wrapper for interacting with smart contracts on the DERO STARGATE testnet. Installing smart contracts is currently not supported, only executing a function on an already installed smart contract on the DERO block dag or query the value of stored variables in the smart contract. Executing a function requires a running dero cli-wallet with the flag --rpc-server. Retrieving the value of a stored variable requires a derod process running.

usage

First import the relevant classes

from pydero import Contract, Connection

Instantiate a python Contract object by the command

contract = Contract(abi=abi,connection=connection,scid=scid)

connection should be an instance of the Connection class, scid should be a string with the scid of the smart contract on the dero blockdag. abi should be a dictionary of the form corresponding to the functions and parameters of the smart contract and the parameter types should be strings that are either "Uint64" or "String". For example, if the contract has two functions called Function1 and Function2, the first with one Uint64 and one String parameter and the second with no parameters, the abi is

from collections import OrderedDict
abi={"Function1":OrderedDict({"ParameterName1":"Uint64","ParameterName2":"String"}),"Function2":{}}

The order of function parameters is important, and therefore it is recommended to use an OrderedDict instead. Instead of specifying the abi manually, it can be loaded from the dero blockdag. This requires a valid scid and a working connection to a dero daemon.

contract.set_abi_from_db()

To call a function on the contract, we simple do

contract.Function1(123,"abc")

To obtain the value of a stored variable called Foo:

contract.get_attribute("Foo")

We can also query different information form the running wallet, for example

connection.get_balance()

We can also query the daemon for information, for example

connection.get_last_block_header()

See the python scripts simple_test.py and test2.py for more examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydero-jonlindg-1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydero_jonlindg-1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file pydero-jonlindg-1.0.tar.gz.

File metadata

  • Download URL: pydero-jonlindg-1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8

File hashes

Hashes for pydero-jonlindg-1.0.tar.gz
Algorithm Hash digest
SHA256 b5c406ca4bbefdf15914a60d3d1d280b0c166ced3e382f9266267793764f829a
MD5 0e7c7ff53c5076242f04ff0ebbd53cf0
BLAKE2b-256 755d220d1a9be5136714d16e8e198d186b6ff36912558ab0967acd71b874d972

See more details on using hashes here.

File details

Details for the file pydero_jonlindg-1.0-py3-none-any.whl.

File metadata

  • Download URL: pydero_jonlindg-1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8

File hashes

Hashes for pydero_jonlindg-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3451b911c654d634316b8b3e906c8a7455b08a009bd2125c71904a29d3e125c7
MD5 3c9a646071659b2d0bbe920fda447de6
BLAKE2b-256 fab2e03f480f13c258e158b7a9c7fec989cbfbf1b4036f5d290260942898517d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page