Docs

Docs

  • Develop
  • Validate
  • Integrate
  • Learn

›Developers

Welcome to Elrond

  • Welcome to Elrond

Technology

  • Architecture Overview
  • Glossary
  • Entities
  • Chronology
  • Secure Proof of Stake
  • Adaptive State Sharding
  • The Elrond WASM VM
  • Cross Shard Transactions

Wallet

  • Wallets - Overview
  • Web Wallet
  • Maiar Web Wallet Extension
  • Webhooks
  • Ledger

Tokens

  • Native Tokens
  • ESDT tokens
  • NFT tokens

Validators

  • Validators - Overview
  • System Requirements
  • Install a Mainnet Node

    • Scripts & User config
    • Installing a Validator Node
    • Optional Configurations
    • How to use the Docker Image

    Install a Testnet/Devnet Node

    • Scripts & User config
    • Installing a Validator Node
    • Manage a validator node
    • How to use the Docker Image

    Manage your keys

    • Validator Keys
    • Wallet Keys
    • Protecting your keys

    Staking, Unstaking, Unjailing

    • Staking, unstaking and unjailing
    • Staking
    • Unjailing
    • The Staking Smart Contract
  • The Delegation Manager
  • Convert An Existing Validator Into A Staking Pool
  • Merging A Validator Into An Existing Delegation Smart Contract
  • Rating
  • Elrond Node upgrades
  • Node redundancy
  • Import DB
  • Node CLI
  • Node Databases
  • Useful Links & Tools
  • FAQs

Developers

  • Developers - Overview
  • Tutorials

    • Build a dApp in 15 minutes
    • Build a Microservice for your dApp
    • The Crowdfunding Smart Contract (part 1)
    • The Crowdfunding Smart Contract (part 2)
    • The Counter Smart Contract
    • Custom Wallet Connect

    Signing Transactions

    • Signing Transactions
    • Tools for signing
    • Signing programmatically

    Gas and Fees

    • Overview
    • EGLD transfers (move balance transactions)
    • System Smart Contracts
    • User-defined Smart Contracts

    Developer reference

    • The Elrond Serialization Format
    • Smart contract annotations
    • Smart contract modules
    • Smart contract to smart contract calls
    • Smart Contract Developer Best Practices
    • Code Metadata
    • Smart Contract API Functions
    • Storage Mappers
    • Rust Testing Framework
    • Rust Testing Framework Functions Reference
    • Rust Smart Contract Debugging
    • Random Numbers in Smart Contracts

    Developers Best Practices

    • Basics
    • BigUint Operations
    • The dynamic allocation problem
    • Multi-values

    Mandos tests reference

    • Mandos Overview
    • Mandos Structure
    • Mandos Simple Values
    • Mandos Complex Values
    • Embedding Mandos code in Go
  • Constants
  • Built-In Functions
  • Account storage
  • Setup a Local Testnet
  • Set up a Local Testnet (advanced)
  • Creating Wallets

SDK and Tools

  • SDKs and Tools - Overview
  • REST API

    • REST API overview
    • api.elrond.com
    • Gateway overview
    • Addresses
    • Transactions
    • Network
    • Nodes
    • Blocks
    • Virtual Machine
    • Versions and Changelog
  • Proxy
  • Elasticsearch
  • erdpy

    • erdpy
    • Installing erdpy
    • Configuring erdpy
    • erdpy CLI
    • Deriving the Wallet PEM file
    • Sending bulk transactions
    • Writing and running erdpy scripts
    • Smart contract interactions

    erdjs

    • erdjs
    • Cookbook
    • Extending erdjs
    • Writing and testing interactions
    • Migration guides
    • Signing Providers for dApps
  • erdgo
  • erdcpp
  • erdjava
  • erdkotlin
  • erdwalletjs-cli

Integrators

  • Integrators - Overview
  • EGLD integration guide
  • ESDT tokens integration guide
  • Observing Squad
  • Accounts Management
  • Creating Transactions
  • Querying the Blockchain

Setup a Local Testnet

This guide describes how to set up a local mini-testnet using erdpy. The purpose of a local mini-testnet is to allow developers to experiment with and test their Smart Contracts, in addition to writing unit and integration tests.

The mini-testnet contains:

  • Validator Nodes (two, by default)
  • Observer Nodes (two, by default)
  • A Seednode
  • An Elrond Proxy

If not specified otherwise, the mini-testnet starts with one Shard plus the Metachain (each with one Validator and one Observer).

Prerequisites: erdpy

In order to install erdpy, follow the instructions at install erdpy.

erdpy version

Make sure your erdpy version is 1.3.2 or higher.

Prerequisites: Node and Proxy

Run the following command, which will fetch the prerequisites (elrond-go, elrond-proxy-go, golang and testwallets) into ~/elrondsdk:

$ erdpy testnet prerequisites

Testnet Configuration

Let's configure the following network parameters in erdpy, so that subsequent command invocations (of erdpy) will not require you explicitly provide the --proxy and --chainID arguments:

$ erdpy config set chainID local-testnet
$ erdpy config set proxy http://localhost:7950

Then, in a folder of your choice add a file names testnet.toml with the content below.

$ mkdir MySandbox && cd MySandbox
$ touch testnet.toml
testnet.toml
[networking]
port_proxy = 7950
tip

erdpy allows you to customize the configuration of the local mini-testnet in much greater detail, but for the sake of simplicity, in the example above we've only set the TCP port of the Elrond Proxy.

Then, configure and build the local testnet as follows:

$ cd MySandbox
$ erdpy testnet config

Upon running this command, a new folder called testnet will be added in the current directory. This folder contains the Node & Proxy binaries, their configurations, plus the development wallets.

warning

The development wallets (Alice, Bob, Carol, ..., Mike) are publicly known - they should only be used for development and testing purpose.

The development wallets are minted at genesis and their keys (both PEM files and Wallet JSON files) can be found in the folder testnet/wallets/users.

Starting the Testnet

erdpy testnet start

This will start the Seednode, the Validators, the Observers and the Proxy.

important

Note that the Proxy starts with a delay of about 30 seconds.

Sending transactions

Let's send a simple transaction using erdpy:

Simple Transfer
erdpy tx new --recall-nonce --data="Hello, World" --gas-limit=70000 \
 --receiver=erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx \
 --pem=~/elrondsdk/testwallets/latest/users/alice.pem \
 --send

You should see the prepared transaction and the transaction hash in the stdout (or in the --outfile of your choice). Using the transaction hash, you can query the status of the transaction against the Proxy or against erdpy itself:

$ curl http://localhost:7950/transaction/1dcfb2227e32483f0a5148b98341af319e9bd2824a76f605421482b36a1418f7
$ erdpy tx get --hash=1dcfb2227e32483f0a5148b98341af319e9bd2824a76f605421482b36a1418f7

Deploying and interacting with Smart Contracts

Let's deploy a Smart Contract using erdpy. We'll use the simple Counter as an example.

If you need guidance on how to build the Counter sample contract, please follow the Counter SmartContract Tutorial.

Deploy Contract
erdpy --verbose contract deploy --bytecode=./counter.wasm \
 --recall-nonce --gas-limit=5000000 \
 --pem=~/elrondsdk/testwallets/latest/users/alice.pem \
 --outfile=myCounter.json \
 --send

Upon deployment, you can check the status of the transaction and the existence of the Smart Contract:

$ curl http://localhost:7950/transaction/0db61bab8e78779ae009300988c6be0949086d93e2b7adfddd5e6375a4b6eeb7 | jq
$ curl http://localhost:7950/address/erd1qqqqqqqqqqqqqpgqj5zftf3ef3gqm3gklcetpmxwg43rh8z2d8ss2e49aq | jq

If everything is fine (transaction status is executed and the code property of the address is set), you can interact with or perform queries against the deployed contract:

Call Contract
erdpy --verbose contract call erd1qqqqqqqqqqqqqpgqj5zftf3ef3gqm3gklcetpmxwg43rh8z2d8ss2e49aq \
 --recall-nonce --gas-limit=1000000 --function=increment \
 --pem=~/elrondsdk/testwallets/latest/users/alice.pem --outfile=myCall.json \
 --send

Query Contract
erdpy --verbose contract query erd1qqqqqqqqqqqqqpgqj5zftf3ef3gqm3gklcetpmxwg43rh8z2d8ss2e49aq --function=get

Simulating transactions

At times, you can simulate transactions instead of broadcasting them, by replacing the flag --send with the flag --simulate. For example:

Simulate: Call Contract
all-nonce --gas-limit=1000000 --function=increment \
 --pem=~/elrondsdk/testwallets/latest/users/alice.pem --outfile=myCall.json \
 --simulate
Simulate: Simple Transfer
erdpy tx new --recall-nonce --data="Hello, World" --gas-limit=70000 \
 --receiver=erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx \
 --pem=~/elrondsdk/testwallets/latest/users/alice.pem \
 --simulate
← Account storageSet up a Local Testnet (advanced) →
  • Prerequisites: erdpy
  • Prerequisites: Node and Proxy
  • Testnet Configuration
  • Starting the Testnet
  • Sending transactions
  • Deploying and interacting with Smart Contracts
  • Simulating transactions
Made withby the Elrond team.
GithubChat
Main siteWalletExplorerBridgeDocsGrowthMaiarMaiar Exchange