All URIs are relative to http://localhost
Method | HTTP request | Description |
---|---|---|
block | POST /block | Get a Block |
blockTransaction | POST /block/transaction | Get a Block Transaction |
BlockResponse block(blockRequest)
Get a Block
Get a block by its Block Identifier. If transactions are returned in the same call to the node as fetching the block, the response should include these transactions in the Block object. If not, an array of Transaction Identifiers should be returned so /block/transaction fetches can be done to get all transaction information. When requesting a block by the hash component of the BlockIdentifier, this request MUST be idempotent: repeated invocations for the same hash-identified block must return the exact same block contents. No such restriction is imposed when requesting a block by height, given that a chain reorg event might cause the specific block at height `n` to be set to a different one.
import Rosetta from 'rosetta';
let apiInstance = new Rosetta.BlockApi();
let blockRequest = new Rosetta.BlockRequest(); // BlockRequest |
apiInstance.block(blockRequest, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
blockRequest | BlockRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
BlockTransactionResponse blockTransaction(blockTransactionRequest)
Get a Block Transaction
Get a transaction in a block by its Transaction Identifier. This endpoint should only be used when querying a node for a block does not return all transactions contained within it. All transactions returned by this endpoint must be appended to any transactions returned by the /block method by consumers of this data. Fetching a transaction by hash is considered an Explorer Method (which is classified under the Future Work section). Calling this endpoint requires reference to a BlockIdentifier because transaction parsing can change depending on which block contains the transaction. For example, in Bitcoin it is necessary to know which block contains a transaction to determine the destination of fee payments. Without specifying a block identifier, the node would have to infer which block to use (which could change during a re-org). Implementations that require fetching previous transactions to populate the response (ex: Previous UTXOs in Bitcoin) may find it useful to run a cache within the Rosetta server in the /data directory (on a path that does not conflict with the node).
import Rosetta from 'rosetta';
let apiInstance = new Rosetta.BlockApi();
let blockTransactionRequest = new Rosetta.BlockTransactionRequest(); // BlockTransactionRequest |
apiInstance.blockTransaction(blockTransactionRequest, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
Name | Type | Description | Notes |
---|---|---|---|
blockTransactionRequest | BlockTransactionRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json