Blocks
From Nxtwiki
Get Block
Get a block object given a block ID or block height.
Request:
- requestType is getBlock
- block is the block ID (optional)
- height is the block height (optional if block provided)
- timestamp is the timestamp (in seconds since the genesis block) of the block (optional if height provided)
- includeTransactions is true to include transaction details (optional)
- includeExecutedPhased is true to include approved and executed phased transactions (optional)
- requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
- requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Note: block overrides height which overrides timestamp.
Response:
- previousBlockHash (S) is the 32-byte hash of the previous block
- payloadLength (N) is the length (in bytes) of all transactions included in the block
- totalAmountNQT (S) is the total amount (in NQT) of the transactions in the block
- generationSignature (S) is the 32-byte generation signature of the generating account
- generator (S) is the generating account number
- generatorPublicKey (S) is the 32-byte public key of the generating account
- baseTarget (S) is the base target for the next block generation
- payloadHash (S) is the 32-byte hash of the payload (all transactions)
- generatorRS (S) is the Reed-Solomon address of the generating account
- nextBlock (S) is the next block ID
- numberOfTransactions (N) is the number of transactions in the block
- blockSignature (S) is the 64-byte block signature
- transactions (A) is an array of transaction IDs or transaction objects (if includeTransactions provided, refer to Get Transaction for details)
- executedPhasedTransactions (A) is an array of transaction IDs or transaction objects (if includeExecutedPhased provided, refer to Get Transaction for details)
- version (N) is the block version
- totalFeeNQT (S) is the total fee (in NQT) of the transactions in the block
- previousBlock (S) is the previous block ID
- cumulativeDifficulty (S) is the cumulative difficulty for the next block generation
- block (S) is the block ID
- height (N) is the zero-based block height
- timestamp (N) is the timestamp (in seconds since the genesis block) of the block
- lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
- requestProcessingTime (N) is the API request processing time (in millisec)
Get Block Example
http://localhost:7876/nxt?
requestType=getBlock&
block=8455642159445842600
{
"previousBlockHash": "c0574d7a7b8497373dbead497c2dc7f60fdcfc8c5a9fcb48f7d373acc9bbb099",
"payloadLength": 1189,
"totalAmountNQT": "100000000",
"generationSignature": "c5098d37267bc71134fc8572a87b4af8727a2e5139d60fe8833fab98af22244a",
"generator": "11693867635361772359",
"generatorPublicKey": "fbb72a280228af5c8c74c7c754a290e1539f839553c00bc560cac7bfdb324a7c",
"baseTarget": "1530224444",
"payloadHash": "633992be640a593ba04e31ca4028deed70bbf47cff333e2a0372a4e2a4aba205",
"generatorRS": "NXT-TWU9-P3E4-HCDM-CQ9L6",
"nextBlock": "5937170741469897491",
"requestProcessingTime": 175,
"numberOfTransactions": 6,
"blockSignature": "ff65a82e385c135cf9bd5be0861e9e5d3d3174fbd993e5b7f57935ec4...",
"transactions": [
"15184285173972564233",
"15200280108574630445",
"15200507403046301754",
"15900338016714606285",
"17881859777840687131",
"18361738217269620028"
],
"version": 3,
"totalFeeNQT": "600000000",
"previousBlock": "4005816059437078464",
"cumulativeDifficulty": "10229109959119715",
"block": "8455642159445842600",
"height": 275730,
"timestamp": 29797208
}
Get Block Id
Get a block ID given a block height.
Request:
- requestType is getBlockId
- height is the block height
- requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
- requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
- block (S) is the block ID
- lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
- requestProcessingTime (N) is the API request processing time (in millisec)
Get Block Id Example
http://localhost:7876/nxt?
requestType=getBlockId&
height=0
{
"block": "2680262203532249785",
"requestProcessingTime": 1
}
Get Blocks
Get blocks from the blockchain in reverse block height order.
Request:
- requestType is getBlocks
- timestamp is the earliest block (in seconds since the genesis block) to retrieve (optional)
- firstIndex is first block to retrieve (optional, default is zero or the last block on the blockchain)
- lastIndex is the last block to retrieve (optional, default is firstIndex + 99)
- includeTransactions is true to include transaction details (optional)
- includeExecutedPhased is true to include approved and executed phased transactions (optional)
- requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
- requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
- blocks (A) is an array of blocks retrieved (refer to Get Block for details)
- lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
- requestProcessingTime (N) is the API request processing time (in millisec)
Get Blocks Example
http://localhost:7876/nxt?
requestType=getBlocks&
lastIndex=1
{
"blocks": [
{
"previousBlockHash": "f88c75a36317e1795348330cb9a944f33153b517ebdf05d9f3f9a606e997618d",
"payloadLength": 981,
"totalAmountNQT": "0",
"generationSignature": "02f7462b62270c0028c379d838d3a192cf0b782995f3bb1929a5378d26e7e8a9",
"generator": "2218289317977832095",
"generatorPublicKey": "98ccf5d5173b13e4c9eab2631372f61ce8ba506db559d73b285073a689872e75",
"baseTarget": "151761236",
"payloadHash": "82f8c8ca1f8f2252172ed1e9836d5228432fcb18aecfa7d55a119efcd242321c",
"generatorRS": "NXT-TGNZ-E8VK-69EX-3L9LX",
"numberOfTransactions": 5,
"blockSignature": "76a3f7f966256c4985262fb4622190b2b9a19b900f6ce443ab7d581e3176c...",
"transactions": [
"10545999940082849455",
"16751328983055099280",
"1257496316971695605",
"2048859884870801838",
"5105170273384355243"
],
"version": 3,
"totalFeeNQT": "500000000",
"previousBlock": "8782326465060769016",
"block": "7299310714263322546",
"height": 281683,
"timestamp": 30416681
},
{
"previousBlockHash": "edc2d65d24883b9b32c46da4eec3792a69a5ff9a9b1e629c4e7e0224432c87c9",
"payloadLength": 0,
"totalAmountNQT": "0",
"generationSignature": "8c4944c7a9ef5700d1b89660fdf83bcbd3dbbfbe191fef005d0f248a573816fe",
"generator": "15766845356521829337",
"generatorPublicKey": "11636697faf4ade736cedf6c528bec0142353c4d93fce05cdb818c49e0390422",
"baseTarget": "303522472",
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorRS": "NXT-2EYT-C522-VL6G-FQSMP",
"nextBlock": "7299310714263322546",
"numberOfTransactions": 0,
"blockSignature": "90464d183ed01cb0930ef527e746eaa092d1558697c369cc9246add5f6eec...",
"transactions": [],
"version": 3,
"totalFeeNQT": "0",
"previousBlock": "11185683789279314669",
"block": "8782326465060769016",
"height": 281682,
"timestamp": 30416671
}
],
"requestProcessingTime": 2
}
Get EC Block
Get Economic Cluster block data.
Request:
- requestType is getECBlock
- timestamp is the timestamp (in seconds since the genesis block) of the EC block (optional, default (or zero) is the current timestamp)
- requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
- requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Note: If timestamp is more than 15 seconds before the timestamp of the last block on the blockchain, errorCode 4 is returned.
Response:
- ecBlockHeight (N) is the EC block height
- ecBlockId (S) is the EC block ID
- timestamp (N) is the timestamp (in seconds since the genesis block) of the EC block
- lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
- requestProcessingTime (N) is the API request processing time (in millisec)
Get EC Block Example
http://localhost:7876/nxt?
requestType=getECBlock
{
"ecBlockHeight": 281777,
"requestProcessingTime": 2,
"ecBlockId": "6565813579609649593",
"timestamp": 30427868
}