starknet_blockHashAndNumber
Get the most recent accepted block hash and number
Parameters
This method does not accept parameters.
Request
{
"jsonrpc": "2.0",
"method": "starknet_blockHashAndNumber",
"params": [],
"id": 1
}
Returns
The latest block hash and number
Object with latest block hash and number
Errors
Code | Message |
---|---|
32 | There are no blocks |
Examples
- cURL
- JavaScript
curl -X POST https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "starknet_blockHashAndNumber",
"params": [],
"id": 1
}'
import { RpcProvider } from 'starknet';
const provider = new RpcProvider({
nodeUrl: 'https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY',
});
const payload = {
method: 'starknet_blockHashAndNumber',
params: []
};
const result = await provider.fetchEndpoint(payload.method, payload.params);
console.log(result);