# Ledger
# ledger_getAccountBlocks
Return account blocks by address
Parameters:
Address
: Account addressHash
: Hash of account block, optional. For the latest block, filling innull
TokenTypeId
: Token type id, optional. This is used to get the transactions associated with certain token. Otherwise, filling innull
uint64
: Number of account blocks
Return:
list<AccountBlock>
: Detail ofAccountBlock
is described in Common Models
Example:
# ledger_getAccountBlockByHash
Return account block by hash
Parameters:
Hash
: Hash of account block
Return:
AccountBlock
: Detail ofAccountBlock
is described in Common Models
Example:
# ledger_getAccountBlockByHeight
Return account block by height
Parameters:
Address
: Account addressuint64
: Height of account block
Return:
AccountBlock
: Detail ofAccountBlock
is described in Common Models
Example:
# ledger_getAccountBlocksByAddress
Return account blocks in descent order by address
Parameters:
Address
: Account addressuint64
: Page index, start with 0uint64
: Page size
Return:
- List<
AccountBlock
>: Detail ofAccountBlock
is described in Common Models
- List<
Example:
# ledger_getLatestAccountBlock
Return the latest account block
Parameters:
Address
: Account address
Return:
AccountBlock
: Detail ofAccountBlock
is described in Common Models
Example:
# ledger_getSnapshotChainHeight
Return current snapshot chain height
Parameters:
none
Return:
string of uint64
: The current height of snapshot chain
Example:
# ledger_getSnapshotBlockByHash
Return snapshot block by hash
Parameters:
Hash
Hash of snapshot block
Returns:
Object
: Snapshot blockproducer
:string
Snapshot block producerhash
:Hash
Hash of snapshot blockpreviousHash
:Hash
Hash of previous snapshot blockheight
:uint64
Height of snapshot blockpublicKey
:ed25519.PublicKey
Producer's public keysignature
:[]byte
Signaturetimestamp
:time
Timestamp of snapshot block producedseed
:uint64
Random seed generated by the same producer in prior roundnextSeedHash
:Hash
Hash of random seed generated in current roundsnapshotData
:map[types.Address]HashHeight
Snapshot content
Example:
# ledger_getSnapshotBlockByHeight
Return snapshot block by height
Parameters:
uint64
Height of snapshot block
Returns:
Object
: Snapshot blockproducer
:string
Snapshot block producerhash
:Hash
Hash of snapshot blockpreviousHash
:Hash
Hash of previous snapshot blockheight
:uint64
Height of snapshot blockpublicKey
:ed25519.PublicKey
Producer's public keysignature
:[]byte
Signaturetimestamp
:time
Timestamp of snapshot block producedseed
:uint64
Random seed generated by the same producer in prior roundnextSeedHash
:Hash
Hash of random seed generated in current roundsnapshotData
:map[types.Address]HashHeight
Snapshot content
Example:
# ledger_getChunks
Return snapshot blocks and snapshot account blocks by height range
Parameters:
string
Start height, inclusivestring
End height, inclusive
Returns:
SnapshotBlock
: Snapshot blockproducer
:string
Snapshot block producerhash
:Hash
Hash of snapshot blockpreviousHash
:Hash
Hash of previous snapshot blockheight
:uint64
Height of snapshot blockpublicKey
:ed25519.PublicKey
Producer's public keysignature
:[]byte
Signaturetimestamp
:time
Timestamp of snapshot block producedseed
:uint64
andom seed generated by the same producer in prior roundnextSeedHash
:Hash
ash of random seed generated in current roundsnapshotData
:map[types.Address]HashHeight
Snapshot content
AccountBlocks
: Snapshot account blocks. Detail ofAccountBlock
is described in Common Models
Example:
# ledger_getAccountInfoByAddress
Return account info by address
Parameters:
Address
: Account address
Return:
AccountInfo
: Detail ofAccountInfo
is described in Common Models
Example:
# ledger_getLatestSnapshotHash
Return latest snapshot block hash
Return:
Hash
: Hash of latest snapshot block
Example:
# ledger_sendRawTransaction
Send a raw transaction by filling in an account block
Parameters:
Object
:AccountBlock
Mandatory:blockType
:byte
Block typeheight
:string
Heighthash
:Hash
Hash of AccountBlockpreviousHash
:Hash
Hash of previous block in the account chain. Fill 0 if there is no previous blockaddress
:Address
Account addresspublicKey
:[]byte
Account's public keysignature
:[]byte
Signature
Optional: below fields should be filled upon sending transaction through pow, otherwise can be ignored or filled with null
difficulty
:*string
PoW difficultynonce
:[]byte
Nonce
Optional: below fields should be filled depending on the transaction type (send or receive)
sendBlockHash
:Hash
Hash of corresponding request transaction. Required for response transactiontoAddress
:Address
Account address to send the transaction to. Required for request transactiontokenId
:TokenTypeId
The token ID in which the transaction is settled. Required for request transactionamount
:*string
Transaction amount. Required for request transactionfee
:*string
Transaction fee. Fill "0" or null for all transactionsdata
:[]byte
Additional data the transaction carries. This field can be specified in request transaction for user account as additional comment or formalized data used to call a contract. Ignore or fill with null if not used.
Returns:
null
Example:
# ledger_getUnreceivedBlocksByAddress
Return all unreceived transactions by address
Parameters:
Address
: Account addressuint64
: Page index, start with 0uint64
: Page size
Return:
list<AccountBlock>
: Detail ofAccountBlock
is described in Common Models
Example:
# ledger_getUnreceivedBlocksInBatch
Return unreceived transactions in batch
Parameters:
PagingQueryBatch
: Account addressAddress
: Account addressuint64
: Page index, start with 0uint64
: Page size
Return:
map<string Address, list<AccountBlock>>
Detail ofAccountBlock
is described in Common Models
Example:
# ledger_getUnreceivedTransactionSummaryByAddress
Return unreceived transaction summary by address
Parameters:
Address
- Account address
Return:
AccountInfo
: Detail ofAccountInfo
is described in Common Models
Example:
# ledger_getUnreceivedTransactionSummaryInBatch
Return unreceived transaction summary in batch
Parameters:
list<Address>
- List of account address
Return:
list<AccountInfo>
: Detail ofAccountInfo
is described in Common Models
Example:
# ledger_getVmLogs
Return event logs generated in the given response block of contract
Parameters:
Hash
: Hash of contract account block
Return:
List<VmLog>
: Event logs
Example:
# ledger_getVmLogsByFilter
Return event logs generated in contract response blocks by specified height range and topics
Parameters:
FilterParam
addressHeightRange
:map[Address]Range
Query logs of the specified contract account address with given range. At least one address must be specified.fromHeight
:uint64
Start height.0
means starting from the latest account blocktoHeight
:uint64
End height.0
means no specific ending account block
topics
:[][]Hash
Prefix of topicspageIndex
:uint64
page index.pageSize
:uint64
page size. The value should be less than 1000
Returns:
Array<VmlogMessage>
result
:Array<VmlogMessage>
accountBlockHash
:Hash
Hash of account blockaccountBlockHeight
:uint64
Height of account blockaddress
:Address
Address of accountvmlog
:VmLog
Event log of smart contracttopics
:Array<string hash>
Event signature and indexed field. The signature can be generated from ABIdata
:string base64
Non-indexed field of event, can be decoded based on ABI
removed
:bool
Iftrue
, the log has been rolled back
# ledger_getPoWDifficulty
Return PoW difficulty for sending transaction
This method first calculates the required amount of quota based on transaction parameters, and then determines whether the account has sufficient quota. If no, it returns PoW difficulty that is necessary for sending the transaction.
If the method returns with error, usually it is because the transaction data is too long, or the transaction is not able to obtain quota by calculating PoW. For example, if PoW has been calculated for the previous transaction, the new transaction of the account is not permitted to do PoW again in the same snapshot block.
Parameters:
GetPoWDifficultyParams
address
:string address
Address of accountpreviousHash
:string hash
Hash of the previous account blockblockType
:byte
Block typetoAddress
:string address
Address of transaction's recipient, required for request transactiondata
:string base64
Additional data that the transaction may carry, optional
Returns:
GetPoWDifficultyResult
requiredQuota
:string uint64
Quota required for sending the transactiondifficulty
:string bigint
PoW difficulty. If''
, sending the transaction does not need PoWqc
:string bigint
Congestion factor * 1e18isCongestion
:bool
Iftrue
, there is a network congestion. In this case, sending the transaction will consume more quota
Example: