getBlockHeight - Solana
Example code for the getBlockHeight JSON-RPC method. Complete guide on how to use getBlockHeight 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": "getBlockHeight",
"params": [{"commitment": "finalized"}],
"id": "getblock.io"
}'const { Connection } = require('@solana/web3.js');
const connection = new Connection('https://go.getblock.io/<ACCESS-TOKEN>/', 'finalized');
const blockHeight = await connection.getBlockHeight();
console.log(blockHeight);import requests
response = requests.post(
'https://go.getblock.io/<ACCESS-TOKEN>/',
headers={'Content-Type': 'application/json'},
json={
'jsonrpc': '2.0',
'method': 'getBlockHeight',
'params': [{"commitment": "finalized"}],
'id': 'getblock.io'
}
)
print(response.json()['result'])Response
Response Parameters
Parameter
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Was this helpful?