getBlockTime
All the specifications for getBlockTime RPC Method on Solana
Returns the estimated production time of a block.
Parameters required for this RPC call
The Block number, identified by Slot. This is a u64 number.
curl https://rpc.shyft.to?api_key=YOUR-API-KEY -s -X \
POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockTime",
"params": [
377268280
]
}
'import { Connection, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection("https://rpc.shyft.to?api_key=YOUR-API-KEY", "confirmed");
let slotNumber = 377268280;
let blockTime = await connection.getBlockTime(slotNumber);
console.log("Block time:", blockTime);
{
"jsonrpc": "2.0",
"result": 1574721591, //estimated production time, as Unix timestamp
"id": 1
}Last updated
Was this helpful?