Docs

Docs

  • Develop
  • Validate
  • Integrate
  • Learn

›Signing Transactions

Welcome to Elrond

  • Welcome to Elrond

Technology

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

Wallet

  • Web Wallet
  • Ledger

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 Node

    • Scripts & User config
    • Installing & updating
    • Manage your testnet node

    Install a Devnet Node

    • Scripts & User config
    • Installing & updating
    • Manage your devnet node

    Manage your keys

    • Validator Keys
    • Wallet Keys
    • Protecting your keys

    Staking, Unstaking, Unjailing

    • Staking, unstaking and unjailing
    • Staking
    • Unjailing
  • Rating
  • Node CLI
  • Useful Links & Tools
  • FAQs

Developers

    Tutorials

    • The Counter Smart Contract
    • Start Building - Crowdfunding Tutorial
    • The Crowdfunding Smart Contract (part 2)

    Signing Transactions

    • Signing Transactions
    • Tools for signing
    • Signing programmatically
  • ESDT tokens
  • The Staking Smart Contract
  • Developer reference

    • Mandos tests reference
    • The Elrond Serialization Format
  • Setup a Local Testnet
  • Setup a Local Testnet (advanced)
  • Creating Wallets

SDK and Tools

    REST API

    • REST API
    • Addresses
    • Transactions
    • Network
    • Nodes
    • Blocks
    • Virtual Machine
    • Versions and Changelog
  • Proxy
  • erdpy

    • erdpy
    • Installing erdpy
    • Configuring erdpy
    • erdpy CLI
    • Deriving the Wallet PEM file
    • Sending bulk transactions
    • Writing and running erdpy scripts
  • erdjs
  • erdgo
  • erdjava
  • erdwalletjs-cli

Integrators

  • Observing Squad
  • Accounts Management
  • Creating Transactions
  • Querying the Blockchain

Detailed comparison

  • Overview
  • Elrond vs. Ethereum Serenity
  • Elrond vs. Zilliqa
  • Elrond vs. Dfinity
  • Elrond vs. Algorand
  • Elrond vs. Harmony

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"
← The Crowdfunding Smart Contract (part 2)Tools for signing →
  • General structure
  • Serialization for signing
  • Ed25519 signature
  • Ready to broadcast
Made withby the Elrond team.
GithubChat
Main siteWalletExplorerBridgeDocs