Casper RPC
How to use it
// yarn add @tatumio/tatum
import { TatumSDK, Casper, Network } from '@tatumio/tatum'
const tatum = await TatumSDK.init<Casper>({ network: Network.CASPER })
const blockHash = 'a4b607420ae737f9cd474af73c9f5e908f61edd2e57d48371d15835127b46aaf' // Replace with actual block hash
const blockHeight = 3229836 // Replace with actual block height
const resultByHash = await tatum.rpc.chainGetBlock({ hash: blockHash })
const resultByHeight = await tatum.rpc.chainGetBlock({ height: blockHeight })
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs
Overview
chain_get_block
is an RPC method on the Casper blockchain that allows you to retrieve information about a specific block by its hash. This method is essential for developers and auditors who want to inspect the details of a particular block, including its transactions, state changes, and proofs.
Parameters
The chain_get_block
method accepts the following parameters:
hash
: The hash of the block to retrieve.
Orheight
Identify and retrieve the Block with its height.
Return Object
The chain_get_block
method returns an object with the following fields:
block
: An object containing details about the block.hash
: The block hash. Example:"a4b607420ae737f9cd474af73c9f5e908f61edd2e57d48371d15835127b46aaf"
header
: An object containing the block header.parent_hash
: The hash of the parent block. Example:"96970c822ac090607d30db53842d2a6a60fd621fa9f9feb75c737cfa339b2a4e"
state_root_hash
: The state root hash. Example:"d43e9911a3ca4b405ca47bf7a76d1f3e4224d283cebb97c8e03cb66cb727e266"
body_hash
: The hash of the block body. Example:"35eb1774e1c1e073e9ff6c1a4422de33c54cf05dd4050d9215be069d8a86a624"
random_bit
: A boolean indicating the random bit. Example:true
accumulated_seed
: The accumulated seed. Example:"9ed6be1af3cc233ff437de9a8458414ce9ec3f18c0162128ead80e0786e066aa"
timestamp
: The timestamp of the block. Example:"2024-06-13T09:11:42.848Z"
era_id
: The era ID. Example:14017
height
: The block height. Example:3099175
protocol_version
: The protocol version. Example:"1.5.6"
body
: An object containing the block body.proposer
: The proposer of the block. Example:"01d2b6b397578ed3d46ebd94525a96b787d767494d94496a68b645a8bc21b66806"
deploy_hashes
: A list of deploy hashes included in the block. Example:["7ea7142d12d263748e5162e747fbbd1612122e339321feb787ea95a5a62a89c9"]
transfer_hashes
: A list of transfer hashes included in the block. Example:[]
proofs
: An array of objects containing the public key and signature of the block's validators.public_key
:"01000e6fce753895c0d08d5d6af62db4e9b0d070f10e69e2c6badf977b29bbeeee"
signature
:"01b26db8428d821331a520b20ef9d2f5105e8267f7e6350c72a287e0957d5c58c2f192109ff3290758f5e8550e1f4009cd0b41a8d01dbc2108dc3972df0c796701"
- ...
Response
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"block": {
"hash": "a4b607420ae737f9cd474af73c9f5e908f61edd2e57d48371d15835127b46aaf",
"header": {
"parent_hash": "96970c822ac090607d30db53842d2a6a60fd621fa9f9feb75c737cfa339b2a4e",
"state_root_hash": "d43e9911a3ca4b405ca47bf7a76d1f3e4224d283cebb97c8e03cb66cb727e266",
"body_hash": "35eb1774e1c1e073e9ff6c1a4422de33c54cf05dd4050d9215be069d8a86a624",
"random_bit": true,
"accumulated_seed": "9ed6be1af3cc233ff437de9a8458414ce9ec3f18c0162128ead80e0786e066aa",
"timestamp": "2024-06-13T09:11:42.848Z",
"era_id": 14017,
"height": 3099175,
"protocol_version": "1.5.6"
},
"body": {
"proposer": "01d2b6b397578ed3d46ebd94525a96b787d767494d94496a68b645a8bc21b66806",
"deploy_hashes": [
"7ea7142d12d263748e5162e747fbbd1612122e339321feb787ea95a5a62a89c9"
],
"transfer_hashes": []
},
"proofs": [
{
"public_key": "01000e6fce753895c0d08d5d6af62db4e9b0d070f10e69e2c6badf977b29bbeeee",
"signature": "01b26db8428d821331a520b20ef9d2f5105e8267f7e6350c72a287e0957d5c58c2f192109ff3290758f5e8550e1f4009cd0b41a8d01dbc2108dc3972df0c796701"
},
{
"public_key": "0100a8faa48e4b20966105c610d8a5f80c4248b337686c51213297d88afe0ff84e",
"signature": "0111a1aa4554c922e853a6fbe2d369549b7963715800f19f6f02bf725c401c47b5d970a884416e4120f32de128a9ceb3e5172b4cdaec0eaed983197728eaf31f00"
},
...
]
}
}
}
Notes
- This method returns the JSON representation of a block from the network.
- The ongoing validity of the chain depends on block verification, which includes both a record of deploys and transfers.
For more detailed information, refer to the official Casper documentation