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-1.0.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-1.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pydero-1.0.0.tar.gz.

File metadata

  • Download URL: pydero-1.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8971ad2205484e3538aac54a8c3ef42b573c18255ef74934c6c5e9b102994633
MD5 43e63c9025cc8b332810c4e0c0b2ed6f
BLAKE2b-256 be190d5d832c1d6c6ba84d410637d95f4f671daf38e36930e2387dd625efbff2

See more details on using hashes here.

File details

Details for the file pydero-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pydero-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9507f7a04a3dd859a19adf27517066916c95040ebdc89c5da80a1e755ac7f0b8
MD5 b038699aed9e36e848870c44787e82d2
BLAKE2b-256 7dcd8020f61763e5638578af6a1378693c63fda022cea02dca259c22ee3db196

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