Diem Developers

Transactions and states

The two fundamental concepts at the heart of the Diem Blockchain are

  • Transactions: Transactions represent the exchange of data and Diem Coins between any two accounts on the Diem Blockchain.
  • States: The ledger state (state) represents the current snapshot of data on the blockchain. At any point in time, the blockchain has a ledger state.

When a submitted transaction is executed, the state of the Diem Blockchain changes.


When a Diem Blockchain participant submits a transaction, they are requesting the ledger state to be updated with their transaction information.

A signed transactionsigned transaction - A signed transaction is a raw transaction with a digital signature. on the blockchain contains the following information:

  • Signature: The sender uses a digital signature to verify that they signed the transaction.
  • Sender address: The sender's account addressaccount address - The address of a Diem payment system account is a 16-byte value. Users can claim addresses using digital signatures. The account address is derived from a cryptographic hash of a user’s public verification key concatenated with a signature scheme identifier byte. The Diem payment system supports two signature schemes: Ed25519 (for single-signature transactions) and MultiEd25519 (for multi-signature transactions). To sign a transaction sent from an account address, the user, or the custodial client representing the user, must use the private key that corresponds to that account..
  • Sender public key: The public authentication key that corresponds to the private authentication key used to sign the transaction.
  • Program: The program comprises:
    • A Move bytecode transaction script: The Move transaction script is an arbitrary program that encodes transaction logic and interacts with resources published in the blockchain's distributed database. Move is a next generation language for secure, sandboxed, and formally verified programming.
    • An optional list of inputs to the script. For a peer-to-peer transaction, these inputs contain the recipient's information and the amount transferred to them.
    • An optional list of Move bytecode modules to publish.
  • Gas price (in specified currency/gas units): This is the amount the sender is willing to pay per unit of to execute the transaction. Gas is a way to pay for computation and storage. A gas unit is an abstract measurement of computation with no inherent real-world value.
  • Maximum gas amount: The maximum gas amountmaximum gas amount - The maximum amount of gas the sender is ready to pay for a specific transaction. The gas charged is equal to the gas price multiplied by units of gas required to process this transaction. If the result is less than the max gas amount, the transaction has been successfully executed. If the transaction runs out of gas while it is being executed or the account runs out of balance during execution, then the sender is charged for gas used and the transaction fails. is the maximum gas units the transaction is allowed to consume.
  • Gas currency code: The currency code used to pay for gas.
  • Sequence number: This is an unsigned integer that must be equal to the sender's account sequence numbersequence number - The sequence number for an account indicates the number of transactions that have been submitted and committed on chain from that account. It is incremented every time a transaction sent from that account is executed or aborted and stored in the blockchain. A transaction is executed only if it matches the current sequence number for the sender account. This helps sequence multiple transactions from the same sender and prevents replay attacks. If the current sequence number of an account A is X, then a transaction T on account A is executed only if T’s sequence number is X. These transactions are held in the mempool until they are the next sequence number for that account (or until they expire). When the transaction is applied, the sequence number of the account becomes X+1. An account has a strictly increasing sequence number. at the time of execution.
  • Expiration time: The transaction ceases to be valid after this time.

Ledger state

The Diem Blockchain's ledger state or global statestate - A state in the Diem protocol is a snapshot of the distributed database. A transaction modifies the database and produces a new and updated state. comprises the state of all accounts in the blockchain. Each validator node in the blockchain must know the global state of the latest version of the blockchain's distributed database (versioned database) to execute any transaction.

Versioned database

All of the data in the Diem Blockchain is persisted in a single-versioned distributed database. A version number is an unsigned 64-bit integer that corresponds to the number of transactions the system has executed.

This versioned database allows validator nodes to:

  • Execute a transaction against the ledger state at the latest version.
  • Respond to client queries about ledger history at both current and previous versions.

Transactions change state


Figure 1.0 represents how executing transaction TN changes the state of the Diem Blockchain from SN-1 to SN.

In the figure:

Accounts A and BRepresent Alice's and Bob's accounts on the Diem Blockchain
SN-1Represents the (N-1)th state of the blockchain. In this state, Alice's account A has a balance of 110 Diem Coins, and Bob's account B has a balance of 52 Diem Coins.
TNThis is the n-th transaction executed on the blockchain. In this example, it represents Alice sending 10 Diem Coins to Bob.
FIt is a deterministic function. F always returns the same final state for a specific initial state and a specific transaction. If the current state of the blockchain is SN-1, and transaction TN is executed on state SN-1, the new state of the blockchain is always SN. The Diem Blockchain uses the Move language to implement the deterministic execution function F.
SNThis is the n-th state of the blockchain. When the transaction TN is applied to the blockchain, it generates the new state SN (an outcome of applying F to SN-1 and TN). This causes Alice’s account balance to be reduced by 10 to 100 Diem Coins and Bob’s account balance to be increased by 10 to 62 Diem Coins. The new state SN shows these updated balances.

Updated 12 days ago

Transactions and states

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.