account_nextIndex - Midnight

Example code for the account_nextIndex JSON-RPC method. Complete guide on how to use account_nextIndex JSON-RPC in GetBlock Web3 documentation.

This method returns the next nonce (account index) to use for the next extrinsic submitted by an account. Use it before constructing a transaction to avoid nonce collisions.

Parameters

Parameter
Type
Required
Description

address

string

Yes

SS58-encoded account address

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "account_nextIndex",
    "params": [
        "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
    ],
    "id": "getblock.io"
}'

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": 42
}

Response Parameters

Field
Type
Description

result

integer

The next nonce (account index) for this account

Use Cases

  • Obtaining the correct nonce before signing and submitting an extrinsic

  • Pre-flight checks in wallet UIs

  • Detecting pending extrinsics by comparing on-chain vs latest nonce

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?