grandpa_roundState
Returns the state of the current GRANDPA finality round on Astar. GRANDPA (GHOST-based Recursive ANcestor Deriving Prefix Agreement) is the finality gadget used by Substrate chains.
Use Cases#
- Finality monitoring - Track consensus progress for cross-chain DeFi, multi-VM smart contracts, and XCM-enabled interoperability with Ethereum and Cosmos
- Validator analysis - Monitor prevote/precommit participation
- Chain health checks - Detect finality delays or stalls
Parameters#
This method takes no parameters.
Returns#
| Field | Type | Description |
|---|---|---|
setId | u64 | Current authority set ID |
best | RoundState | Best round state |
background | Vec<RoundState> | Background rounds |
RoundState Structure#
| Field | Type | Description |
|---|---|---|
round | u64 | Round number |
totalWeight | u64 | Total validator weight |
thresholdWeight | u64 | Weight needed for supermajority |
prevotes | Prevotes | Prevote information |
precommits | Precommits | Precommit information |
Code Examples#
- cURL
- JavaScript
- Python
curl https://api-astar.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "grandpa_roundState",
"params": [],
"id": 1
}'
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
const roundState = await api.rpc.grandpa.roundState();
console.log('Set ID:', roundState.setId.toString());
console.log('Best round:', roundState.best.round.toString());
console.log('Total weight:', roundState.best.totalWeight.toString());
console.log('Threshold:', roundState.best.thresholdWeight.toString());
await api.disconnect();
import requests
url = 'https://api-astar.n.dwellir.com/YOUR_API_KEY'
payload = {
'jsonrpc': '2.0',
'method': 'grandpa_roundState',
'params': [],
'id': 1
}
response = requests.post(url, json=payload)
result = response.json()['result']
print(f"Set ID: {result['setId']}")
print(f"Round: {result['best']['round']}")
print(f"Total weight: {result['best']['totalWeight']}")
Understanding GRANDPA Rounds#
- Prevote phase - Validators vote on best block they've seen
- Precommit phase - Validators commit to finalize if supermajority prevoted
- Finalization - Block is finalized when 2/3+ weight precommits
Related Methods#
chain_subscribeFinalizedHeads- Subscribe to finalized blockschain_getFinalizedHead- Get current finalized hashbeefy_getFinalizedHead- BEEFY finality (if enabled)