Block
defaultBlock
The default block is used for certain methods. You can override it by passing in the defaultBlock as the last parameter. The default value is "latest"
.
Property
Default block parameters can be one of the following:
Number: A block number
"genesis"
- String: The genesis block"latest"
- String: The latest block (current head of the blockchain)
Default is "latest"
.
Example
getBlockNumber
Returns the current block number.
Parameters
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Number
- The number of the most recent block.
Example
getBlock
Returns a block matching the block hash or block number.
Parameters
blockHashOrBlockNumber
String | Number
The block hash or block number. Or the string "genesis"
, or "latest"
.
returnTransactionObjects
Boolean
(optional, default false
) If true
, the returned block will contain all transactions as objects, if false
it will only contains the transaction hashes.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Object
- The block object:
blockScore
QUANTITY
Former difficulty. Always 1 in the BFT consensus engine
extraData
String
The "extra data" field of this block.
gasUsed
Number
The total used gas by all transactions in this block.
governanceData
DATA
RLP encoded governance configuration
hash
32-byte String
Hash of the block. null
when it is a pending block.
logsBloom
256-byte String
The bloom filter for the logs of the block. null
when it is a pending block.
number
Number
The block number. null
when it is a pending block.
parentHash
32-byte String
Hash of the parent block.
receiptsRoot
32-byte DATA
The root of the receipts trie of the block.
reward
20-byte DATA
The address of the beneficiary to whom the block rewards were given.
size
Number
Integer the size of this block in bytes.
stateRoot
32-byte String
The root of the final state trie of the block.
timestamp
Number
The unix timestamp for when the block was collated.
timestampFoS
QUANTITY
The fraction of a second of the timestamp for when the block was collated.
totalBlockScore
QUANTITY
Integer of the total blockScore of the chain until this block.
transactions
Array
Array of transaction objects, or 32-byte transaction hashes depending on the returnTransactionObjects
parameter.
transactionsRoot
32-byte String
The root of the transaction trie of the block.
voteData
DATA
RLP encoded governance vote of the proposer
Example
getBlockReceipts
Returns a list of transaction receipts included in a block identified by the given block hash.
Parameters
blockHash
String
Hash of a block.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Array
- Receipts included in a block. If the target block contains no transaction, an empty array []
is returned.
Example
getBlockTransactionCount
Returns the number of transaction in a given block.
Parameters
blockHashOrBlockNumber
String | Number
The block number or hash. Or the string "genesis"
, or "latest"
.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Number
- The number of transactions in the given block.
Example
getBlockWithConsensusInfo
Returns a block with consensus information matched by the given block hash or block number.
Parameters
blockHashOrBlockNumber
String | Number
The block hash or block number. Or the string "genesis"
or "latest"
.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Object
- A block object with consensus information (a proposer and a list of committee members) The block object contains:
blockScore
QUANTITY
Former difficulty. Always 1 in the BFT consensus engine
committee
Array
Array of addresses of committee members of this block. The committee is a subset of validators participated in the consensus protocol for this block.
extraData
String
The "extra data" field of this block.
gasUsed
QUANTITY
The total used gas by all transactions in this block.
governanceData
DATA
RLP encoded governance configuration
hash
32-byte DATA
Hash of the block. null
when it is a pending block.
logsBloom
256-byte String
The bloom filter for the logs of the block. null
when it is a pending block.
number
QUANTITY
The block number. null
when it is a pending block.
parentHash
32-byte DATA
Hash of the parent block.
proposer
20-byte DATA
The address of the block proposer.
receiptsRoot
32-byte DATA
The root of the receipts trie of the block.
reward
20-byte DATA
The address of the beneficiary to whom the block rewards were given.
size
QUANTITY
Integer the size of this block in bytes.
stateRoot
32-byte DATA
The root of the final state trie of the block.
timestamp
QUANTITY
The unix timestamp for when the block was collated.
timestampFoS
QUANTITY
The fraction of a second of the timestamp for when the block was collated.
totalBlockScore
QUANTITY
Integer of the total blockScore of the chain until this block.
transactions
Array
Array of transaction objects.
transactionsRoot
32-byte DATA
The root of the transaction trie of the block.
voteData
DATA
RLP encoded governance vote of the proposer
Examples
getCommittee
Returns a list of all validators in the committee at the specified block. If the parameter is not set, returns a list of all validators in the committee at the latest block.
Parameters
defaultBlock
Number | String
(optional) If you pass this parameter, it will not use the default block set with caver.klay.defaultBlock.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Array
- Addresses of all validators in the committee.
Example
getCommitteeSize
Returns the size of the committee at the specified block. If the parameter is not set, returns the size of the committee at the latest block.
Parameters
defaultBlock
Number | String
(optional) If you pass this parameter, it will not use the default block set with caver.klay.defaultBlock.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Number
- The size of the committee.
Example
getCouncil
NOTE: getValidators
is replaced with this method and is not supported anymore.
Returns a list of all validators of the council at the specified block. If the parameter is not set, returns a list of all validators of the council at the latest block.
Parameters
defaultBlock
Number | String
(optional) If you pass this parameter, it will not use the default block set with caver.klay.defaultBlock.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Array
- Addresses of all validators of the council.
Example
getCouncilSize
Returns the size of the council at the specified block. If the parameter is not set, returns the size of the council at the latest block.
Parameters
defaultBlock
Number | String
(optional) If you pass this parameter, it will not use the default block set with caver.klay.defaultBlock.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Number
- The size of the council.
Example
getStorageAt
Gets the storage at a specific position of an address.
Parameters
address
String
The address to get the storage from.
position
Number
The index position of the storage.
defaultBlock
Number | String
(optional) If you pass this parameter, it will not use the default block set with caver.klay.defaultBlock.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns String
- The value in storage at the given position.
Example
isMining
Returns true
if client is actively mining new blocks.
Parameters
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Boolean
- true
if the client is mining, otherwise false
.
Example
isSyncing
Checks if the node is currently syncing and returns either a syncing object or false
.
Parameters
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Object|Boolean
- A sync object when the node is currently syncing or false
:
startingBlock
Number
The block number where the sync started.
currentBlock
Number
The block number where at which block the node currently synced to already.
highestBlock
Number
The estimated block number to sync to.
knownStates
Number
The estimated states to download.
pulledStates
Number
The already downloaded states.
Example
Last updated