system_accountNextIndex
Returns the next valid transaction index (nonce) for an account.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
accountId | string | Yes | SS58 address or hex AccountId. Moonbase Alpha uses 20-byte AccountId; hex like ${S.accountId} works. |
cURL
curl -X POST https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"system_accountNextIndex","params":["0x879364b326a766a45b4b52a941f4574f7f6a6a64"]}'
JavaScript (polkadot.js)
import { ApiPromise, WsProvider } from '@polkadot/api';
async function main() {
const api = await ApiPromise.create({ provider: new WsProvider('${S.wsBase}') });
const nonce = await api.rpc.system.accountNextIndex('${S.accountId}');
console.log('Next nonce:', nonce.toString());
await api.disconnect();
}
Notes
- For Substrate signing, pass the same nonce when constructing a signed extrinsic.
- Combine with
payment_queryInfo
to estimate fees before submission.