getBlocks - Solana
Example code for the getBlocks JSON-RPC method. Complete guide on how to use getBlocks JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Config Object
Field
Type
Required
Description
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "getBlocks",
"params": [397234556, 397234561],
"id": "getblock.io"
}'const { Connection } = require('@solana/web3.js');
const connection = new Connection('https://go.getblock.io/<ACCESS-TOKEN>/', 'confirmed');
const blocks = await connection.getBlocks(397234556, 397234561);
console.log(blocks);import requests
response = requests.post(
'https://go.getblock.io/<ACCESS-TOKEN>/',
headers={'Content-Type': 'application/json'},
json={
'jsonrpc': '2.0',
'method': 'getBlocks',
'params': [397234556, 397234561],
'id': 'getblock.io'
}
)
print(response.json()['result'])Response
Response Parameters
Parameter
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Was this helpful?