Skip to content

Ledger Contract

Back to Native Contracts

Provides read-only access to blockchain data — blocks, transactions, and their metadata.

Methods

MethodSignatureReturnSafeEmbedded Runtime Behavior
currentIndexcurrentIndex()uint256Current block height. Maps from block.number.
currentHashcurrentHash()bytes32Hash of the current block.
getBlockgetBlock(uint256)BlockReturns a cached or synthetic block when the index is at or below the current height; returns null for future heights.
getBlockgetBlock(bytes32)BlockReturns a matching cached/synthetic block when available; detailed chain lookup is not modeled.
getTransactiongetTransaction(bytes32)TransactionReturns a transaction only when it exists in the embedded runtime cache; otherwise null.
getTransactionHeightgetTransactionHeight(bytes32)int256Returns current height for cached transactions, otherwise -1.
getTransactionFromBlockgetTransactionFromBlock(uint256,uint256)TransactionCurrently stubbed; per-block transaction lookup is not modeled and this returns null.
getTransactionSignersgetTransactionSigners(bytes32)Signer[]Returns an empty array; transaction signers are not modeled.
getTransactionVMStategetTransactionVMState(bytes32)uint8Returns the default HALT state (1); detailed per-transaction VM state is not modeled.

INFO

The compiler auto-maps block.number to Ledger.currentIndex() and blockhash(n) to Ledger.getBlock(n).hash. See Units and Globally Available Variables for the full list of auto-mapped block context values.


MIT Licensed