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.1.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.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydero-jonlindg-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f775297cba858ad61bcc74775bbf4e0c9a89ec883ebb5437b81b599d3d0aa786
MD5 ce0df9f5d26d11bd869ea1bdf4368a87
BLAKE2b-256 d8a710c4cd5b04a443815a4ddb62f44088762dbe4d7ee1b3f2ed580f03cf68db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydero_jonlindg-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab63def25058b35d5d1c8c8b3732224bc78a29850ed80e90ece816a9a6dd1b4c
MD5 82d988d2da04c41f071a57ea02bcb138
BLAKE2b-256 64b2127b14a6244fa91cb3a96c129a71195445cf6f2b7c036f4dca20ef7dd126

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