Docs

Docs

  • Develop
  • Validate
  • Integrate
  • Learn

›Signing Transactions

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

Signing Transactions

How to serialize and sign the Transaction payload

Transactions must be signed with the Sender's Private Key before submitting them to the Elrond Network. Signing is performed with the Ed25519 algorithm.

General structure

An unsigned transaction has the following fields:

FieldTypeRequiredDescription
noncenumberYesThe account sequence number
valuestringYes (can be "0")The value to transfer, represented in atomic units:EGLD times denomination
receiverstringYesThe address of the receiver (bech32 format)
senderstringYesThe address of the sender (bech32 format)
gasPricenumberYesThe gas price to be used in the scope of the transaction
gasLimitnumberYesThe maximum number of gas units allocated for the transaction
datastringNoArbitrary information about the transaction, base64-encoded.
chainIDstringYesThe chain identifier.
versionnumberYesThe version of the transaction (e.g. 1).

A signed transaction has the additional signature field:

FieldTypeDescription
signaturestringThe digital signature consisting of 128 hex-characters (thus 64 bytes in a raw representation)

Serialization for signing

Before signing a transaction, one has to serialize it, that is, to obtain its raw binary representation - as a sequence of bytes. This is achieved through the following steps:

  1. order the fields of the transaction with respect to their appearance order in the table above (nonce is first, version is last).
  2. discard the data field if it's empty.
  3. convert the data payload to its base64 representation.
  4. obtain a JSON representation (UTF-8 string) of the transaction, maintaining the order of the fields. This JSON representation must contain no indentation and no separating spaces.
  5. encode the resulted JSON (UTF-8) string as a sequence of bytes.

For example, given the transaction:

nonce = 7
value = "10000000000000000000"  # 10 EGLD
receiver = "erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r"
sender = "erd1l453hd0gt5gzdp7czpuall8ggt2dcv5zwmfdf3sd3lguxseux2fsmsgldz"
gasPrice = 1000000000
gasLimit = 70000
data = "for the book"
chainID = "1"
version = 1

By applying steps 1-3 (step 4 is omitted in this example), one obtains:

{"nonce":7,"value":"10000000000000000000","receiver":"erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r","sender":"erd1l453hd0gt5gzdp7czpuall8ggt2dcv5zwmfdf3sd3lguxseux2fsmsgldz","gasPrice":1000000000,"gasLimit":70000,"data":"Zm9yIHRoZSBib29r","chainID":"1","version":1}

If the transaction has an empty no data field:

nonce = 8
value = "10000000000000000000"  # 10 ERD
receiver = "erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r"
sender = "erd1l453hd0gt5gzdp7czpuall8ggt2dcv5zwmfdf3sd3lguxseux2fsmsgldz"
gasPrice = 1000000000
gasLimit = 50000
data = ""
chainID = "1"
version = 1

Then it's serialized form (step 5 is omitted in this example) is as follows:

{"nonce":8,"value":"10000000000000000000","receiver":"erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r","sender":"erd1l453hd0gt5gzdp7czpuall8ggt2dcv5zwmfdf3sd3lguxseux2fsmsgldz","gasPrice":1000000000,"gasLimit":50000,"chainID":"1","version":1}

Ed25519 signature

Elrond uses the Ed25519 algorithm to sign transactions. In order to obtain the signature, one can use generic software libraries such as PyNaCl, tweetnacl-js or components of Elrond SDK such as elrond-core-js, erdpy, erdjs or erdwalletjs-cli.

The raw signature consisting of 64 bytes has to be hex-encoded afterwards and placed in the transaction object.

Ready to broadcast

Once the signature field is set as well, the transaction is ready to be broadcasted. Following the examples above, their ready-to-broadcast form is as follows:

# With data field
nonce = 7
value = "10000000000000000000"  # 10 EGLD
receiver = "erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r"
sender = "erd1l453hd0gt5gzdp7czpuall8ggt2dcv5zwmfdf3sd3lguxseux2fsmsgldz"
gasPrice = 1000000000
gasLimit = 70000
data = "Zm9yIHRoZSBib29r"
chainID = "1"
version = 1
signature = "1702bb7696f992525fb77597956dd74059b5b01e88c813066ad1f6053c6afca97d6eaf7039b2a21cccc7d73b3e5959be4f4c16f862438c7d61a30c91e3d16c01"
# Without data field
nonce = 8
value = "10000000000000000000"  # 10 EGLD
receiver = "erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r"
sender = "erd1l453hd0gt5gzdp7czpuall8ggt2dcv5zwmfdf3sd3lguxseux2fsmsgldz"
gasPrice = 1000000000
gasLimit = 50000
data = ""
chainID = "1"
version = 1
signature = "4a6d8186eae110894e7417af82c9bf9592696c0600faf110972e0e5310d8485efc656b867a2336acec2b4c1e5f76c9cc70ba1803c6a46455ed7f1e2989a90105"
← Custom Wallet ConnectTools for signing →
  • General structure
  • Serialization for signing
  • Ed25519 signature
  • Ready to broadcast
Made withby the Elrond team.
GithubChat
Main siteWalletExplorerBridgeDocsGrowthMaiarMaiar Exchange