Coder Social home page Coder Social logo

eddienuta / elrond-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from multiversx/mx-deprecated-sdk-monorepo

0.0 1.0 0.0 2.16 MB

Elrond - Command Line Tools and Python SDK for interacting with the Elrond Network (in general) and Smart Contracts (in particular).

License: GNU General Public License v3.0

Python 16.41% JavaScript 39.54% HTML 3.61% CSS 16.25% Makefile 0.59% TypeScript 9.21% C 1.11% LLVM 13.29%

elrond-sdk's Introduction

erdpy

Build Status

Development is in progress. See CHANGELOG.

For tutorials, go to wiki.

For Python SDK examples, see examples.

Elrond - Command Line Tools and Python SDK for interacting with Smart Contracts.

One can use erdpy to build, test and debug Elrond smart contracts, deploy them on the testnet and interact with contracts by issuing function calls (transactions).

Erdpy also acts as a wrapper over the Elrond REST API.

Installation

Ubuntu

Make sure that you have installed Python3 (version 3.6 or later) and Pip3 in advance:

python3 --version
pip3 --version

Then issue the following command:

pip3 install --user --upgrade --no-cache-dir erdpy

Test installation as follows:

pip3 show erdpy
erdpy --version

If erdpy command is not found (not registered correctly), issue the command:

source ~/.profile

If you encounter encoding-related issues at installation time, such as:

UnicodeDecodeError: 'ascii' codec can't decode byte

Then please set PYTHONIOENCODING before running the install command:

PYTHONIOENCODING=utf8 pip3 install --user --upgrade --no-cache-dir erdpy

MacOS

Make sure that you have installed Python3 (version 3.6 or later) and Pip3 in advance:

python3 --version
pip3 --version

Add this line to ~/.bash_profile or ~/.zshrc (if you’re using zsh) before installing the package (make sure to replace the placeholders below):

export PATH=/Users/YOUR_USERNAME/Library/Python/YOUR_PYTHON_VERSION/bin:${PATH}

For example:

export PATH=/Users/elrond/Library/Python/3.7/bin:${PATH}

Then issue the following command:

pip3 install --user --upgrade --no-cache-dir erdpy

Test installation as follows:

pip3 show erdpy
erdpy --version

Command-line interface

List project templates

Display the list of project templates (smart contracts templates):

$ erdpy templates
$ erdpy templates --json

These templates are downloaded from different sources, as configured in templates_config.py and are written in rust, C or Solidity.

Create new project

The following command creates a sample project called hello based on the template ultimate-answer (written in C):

$ erdpy new --template ultimate-answer --directory ./examples hello
$ erdpy new --template adder --directory ./examples myadder

Build a project

In order to build a project you only have to specify its directory. Let's build the projects under /example:

erdpy build ./examples/hello
erdpy build ./examples/myadder

The first one is written in C, while the second in rust. As you can see, the commands are similar.

Run smart contract unit tests

In order to run JSON unit tests, add the unit tests in the project of the smart contract, in a folder named test. Then run the following command:

erdpy --verbose test ./examples/hello --wildcard="*"

Deploy contract on testnet

Deploy a smart contract on the testnet (make sure the contract is built in advance):

erdpy --verbose deploy ./examples/contracts/hello --pem="./examples/keys/alice.pem" --proxy="https://api.elrond.com"

Query contract values on testnet

Inspect values stored in the smart contract by performing a call to a pure, getter function:

erdpy --verbose query erd1qqqqqqqqqqqqqpgqde8eqjywyu6zlxjxuxqfg5kgtmn3setxh40qen8egy --function="getUltimateAnswer" --proxy="https://api.elrond.com"

Call contract functions on testnet

Call a function of an existing smart contract:

erdpy --verbose call erd1qqqqqqqqqqqqqpgqde8eqjywyu6zlxjxuxqfg5kgtmn3setxh40qen8egy --pem="./examples/keys/alice.pem" --function="increment" --proxy="https://api.elrond.com"

Issue regular transactions against the testnet

Prepare, then send transactions:

erdpy --verbose tx-prepare ./myplayground --tag="foobar" --pem="./examples/keys/alice.pem" --nonce=42 --receiver=erd188nydpkagtpwvfklkl2tn0w6g40zdxkwfgwpjqc2a2m2n7ne9g8q2t22sr --value=100000

erdpy --verbose tx-send ./myplayground/tx-foobar.json --proxy=https://api.elrond.com

erdpy --verbose tx-prepare-and-send --pem="./examples/keys/alice.pem" --receiver=erd188nydpkagtpwvfklkl2tn0w6g40zdxkwfgwpjqc2a2m2n7ne9g8q2t22sr --value=100000 --proxy=https://api.elrond.com

Validators features

Features: Stake, UnStake, UnBound, UnJail, ChangeRewardAddress

erdpy --verbose stake-prepare ./myplayground --tag="foobar" --nonce=100 --pem="./examples/keys/alice.pem" --number-of-nodes=1 --nodes-public-keys="blsKey1" --value="2500000000000000000000000" --proxy=https://api.elrond.com --reward-address="bech32address--is-optional"
erdpy --verbose stake --pem="./examples/keys/alice.pem" --number-of-nodes=1 --nodes-public-keys="blsKey1" --value="2500000000000000000000000" --proxy=https://api.elrond.com --reward-address="bech32address--is-optional" --gas-limit=5000000 (optional if use --estimate-gas)  --estimate-gas (optional)
erdpy --verbose unstake --pem="./examples/keys/alice.pem" --nodes-public-keys="blsKey1" --proxy=https://api.elrond.com --gas-limit=5000000 (optional if use --estimate-gas)  --estimate-gas (optional)
erdpy --verbose unbond --pem="./examples/keys/alice.pem" --nodes-public-keys="blsKey1" --proxy=https://api.elrond.com --gas-limit=5000000 (optional if use --estimate-gas)  --estimate-gas (optional)
erdpy --verbose unjail --pem="./examples/keys/alice.pem" --value=2500000000000000000000 --nodes-public-keys="blsKey1" --proxy=https://api.elrond.com --gas-limit=5000000 (optional if use --estimate-gas)  --estimate-gas (optional)
erdpy --verbose change-reward-address --pem="./examples/keys/alice.pem" --reward-address="newbech32address" --proxy=https://api.elrond.com --gas-limit=5000000 (optional if use --estimate-gas)  --estimate-gas (optional)
erdpy --verbose claim --pem="./examples/keys/alice.pem" --proxy=https://api.elrond.com --gas-limit=5000000 (optional if use --estimate-gas)  --estimate-gas (optional)

Miscellaneous features

Get information such as the number of shards, the gas price, the chain ID and so on:

erdpy network num-shards --proxy="https://api.elrond.com"
erdpy network chain-id --proxy="https://api.elrond.com"
erdpy network last-block-nonce --shard-id="1" --proxy="https://api.elrond.com"

Get details about a specific account (address on the blockchain):

erdpy account get --address="erd188nydpkagtpwvfklkl2tn0w6g40zdxkwfgwpjqc2a2m2n7ne9g8q2t22sr" --proxy="https://api.elrond.com"
erdpy account get --nonce --address="erd188nydpkagtpwvfklkl2tn0w6g40zdxkwfgwpjqc2a2m2n7ne9g8q2t22sr" --proxy="https://api.elrond.com"
erdpy account get --balance --address="erd188nydpkagtpwvfklkl2tn0w6g40zdxkwfgwpjqc2a2m2n7ne9g8q2t22sr" --proxy="https://api.elrond.com"

Get estimated costs for transactions, in gas units. Note that there are 3 types of transactions:

  • move-balance
  • sc-deploy
  • sc-call
erdpy cost gas-price --proxy="https://api.elrond.com"
erdpy cost transaction move-balance --data="foobar" --proxy="https://api.elrond.com"
erdpy cost transaction sc-deploy --sc-path="./examples/hello" --proxy="https://api.elrond.com"
erdpy cost transaction sc-call --sc-address="erd1qqqqqqqqqqqqqpgqde8eqjywyu6zlxjxuxqfg5kgtmn3setxh40qen8egy" --function="increment" --proxy="https://api.elrond.com"

Wallet features

erdpy wallet generate ./myaccount.pem
erdpy wallet generate ./myaccount.pem --mnemonic="foo bar ..."
erdpy wallet bech32 --encode 000000000000000005006e4f90488e27342f9a46e1809452c85ee7186566bd5e
erdpy wallet bech32 --decode erd1qqqqqqqqqqqqqpgqde8eqjywyu6zlxjxuxqfg5kgtmn3setxh40qen8egy

Contribute

One can contribute by creating pull requests, or by opening issues for discovered bugs or desired features.

elrond-sdk's People

Contributors

andrei-marinica avatar andreibancioiu avatar camilbancioiu avatar miiu96 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.