# grandpa_roundState - Astar RPC Method

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

```bash
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
  }'
```

```javascript
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();
```

```python
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

1. **Prevote phase** - Validators vote on best block they've seen
2. **Precommit phase** - Validators commit to finalize if supermajority prevoted
3. **Finalization** - Block is finalized when 2/3+ weight precommits

## Related Methods

- [`chain_subscribeFinalizedHeads`](https://www.dwellir.com/docs/astar/chain_subscribeFinalizedHeads) - Subscribe to finalized blocks
- [`chain_getFinalizedHead`](https://www.dwellir.com/docs/astar/chain_getFinalizedHead) - Get current finalized hash
- [`beefy_getFinalizedHead`](https://www.dwellir.com/docs/astar/beefy_getFinalizedHead) - BEEFY finality (if enabled)
