Docs

Docs

  • Develop
  • Validate
  • Integrate
  • Learn

›Integrators

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

Creating Transactions

Transaction structure

As described in section Signing Transactions, a ready-to-broadcast transaction is structured as follows:

{
    "nonce": 42,
    "value": "100000000000000000",
    "receiver": "erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r",
    "sender": "erd1ylzm22ngxl2tspgvwm0yth2myr6dx9avtx83zpxpu7rhxw4qltzs9tmjm9",
    "gasPrice": 1000000000,
    "gasLimit": 70000,
    "data": "Zm9vZCBmb3IgY2F0cw==",
    "chainID": "1",
    "version": 1,
    "signature": "5845301de8ca3a8576166fb3b7dd25124868ce54b07eec7022ae3ffd8d4629540dbb7d0ceed9455a259695e2665db614828728d0f9b0fb1cc46c07dd669d2f0e"
}

SDK and tools support for creating and signing transactions

There are SDKs or tools with support for interacting with the Elrond blockchain, so one can use one of the following SDKs to perform transactions creation and signing:

  • erdjs - JavaScript SDK
  • erdpy - Python SDK
  • erdgo - Golang SDK
  • erdjava - Java SDK
  • elrond-core-js library
  • lightweight JS CLI wrapper over our elrond-core-js library
  • lightweight HTTP utility, which wraps the elrond-core-js library

General network parameters

General network parameters, such as the chain ID, the minimum gas price, the minimum gas limit and the oldest acceptable transaction version are available at the API endpoint Get Network Configuration.

{
    "config": {
        "erd_chain_id": "1",
        "erd_gas_per_data_byte": 1500,
        "erd_min_gas_limit": 50000,
        "erd_min_gas_price": 1000000000,
        "erd_min_transaction_version": 1,
        ...
    }
}

Nonce management

Each transaction broadcasted to the Network must have the nonce field set consistently with the account nonce. In the Network, transactions of a given sender address are processed in order, with respect to the transaction nonce.

The account nonce can be fetched from the API: Get Address Nonce.

The nonce must be a strictly increasing number, scoped to a given sender. The sections below describe common issues and possible solutions when managing the nonce for transaction construction.

Issue: competing transactions

Broadcasted transactions that reach the mempool having the same sender address and the same nonce are competing transactions, and only one of them will be processed (the one providing a higher gas price or, if they have the same gas price, the one that arrived the second - but keep in mind that arrival time is less manageable).

tip

Avoid competing transactions by maintaining a strictly increasing nonce sequence when broadcasting transactions of the same sender address.

Although an explicit transaction cancellation trigger is not yet available in the Network, cancellation of a transaction T1 with nonce 42 could be possible if one broadcasts a second transaction T2 with same nonce 42, with higher gas price (and without a value to transfer) immediately (e.g. 1 second) after broadcasting T1.

Issue: nonce gaps

If broadcasted transactions have their nonces higher than the current account nonce of the sender, this is considered a nonce gap, and the transactions will remain in the mempool unprocessed, until new transactions from the same sender arrive to resolve the nonce gap - or until the transactions are swept from the mempool (sweeping takes place regularly).

tip

Avoid nonce gaps by regularly fetching the current account nonce, in order to populate the nonce field correctly before broadcasting the transactions. This technique is also known as periodically recalling the nonce.

Issue: fetching a stale account nonce

You should take care when fetching the current account nonce from the API immediately after broadcasting transactions.

Example:

  1. Time 12:00:01 - the sender's nonce is recalled, and its value is 42
  2. Time 12:00:02 - the sender broadcasts the transaction T1 with nonce 42
  3. Time 12:00:03 - the sender's nonce is recalled again, in order to broadcast a new transaction. The nonce is still 42. It is stale, not yet incremented on the Network (since T1 is still pending or being processed at this very moment).
  4. Time 12:00:04 - the sender broadcasts T2 with nonce 42, which will compete with T1, as they have the same nonce.
tip

Avoid fetching stale account nonces by periodically recalling the nonce.

Avoid recalling the nonce in between rapidly sequenced transactions from the same sender . For rapidly sequenced transactions, you have to programmatically manage, keep track of the account nonce using a local mirror (copy) of the account nonce and increment it appropriately.

Gas limit computation

Please follow Gas and Fees.

Signing transactions

Please follow Signing Transactions.

Simulate transaction execution

important

Documentation about transaction simulation is preliminary and subject to change.

← Accounts ManagementQuerying the Blockchain →
  • Transaction structure
  • SDK and tools support for creating and signing transactions
  • General network parameters
  • Nonce management
    • Issue: competing transactions
    • Issue: nonce gaps
    • Issue: fetching a stale account nonce
  • Gas limit computation
  • Signing transactions
  • Simulate transaction execution
Made withby the Elrond team.
GithubChat
Main siteWalletExplorerBridgeDocsGrowthMaiarMaiar Exchange