You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: When getting a nonce by following doc https://polkadot.js.org/docs/api/examples/promise/transfer-events
current nonce is incorrect and replies with error message: VEC: Unable to decode on index 0 createType(Lookup0):: Unknown type passed to AccountId constructor, found typeof object RPC-CORE: queryStorageAt(keys: Vec<StorageKey>, at?: BlockHash): Vec<StorageChangeSet>:: createType(Vec<StorageKey>):: createType(Lookup0):: Unknown type passed to AccountId constructor, found typeof object
Better way to get nonce is this:let currentNonce = (await api.rpc.system.accountNextIndex(baseAccount.address)).toBigInt();
When sending txn to substrate network, following structure fits the best:
let currentNonce = (await api.rpc.system.accountNextIndex(baseAccount.address)).toBigInt();
const transferExtrinsic = api.tx.balances.transfer(transfers.recipient, transfers.amount);
const hash = await new Promise<string>((resolve, reject) => {
transferExtrinsic
.signAndSend(baseAccount, { nonce: currentNonce }, ({ status, dispatchError }) => {
if (status.isInBlock || status.isFinalized) {
const hash = status.isInBlock ? status.asInBlock.toString() : status.asFinalized.toString();
console.log(`Transaction included in block: ${hash}`);
if (!dispatchError) {
resolve(hash);
} else {
console.error('Transaction failed with dispatch error:', dispatchError.toString());
reject(new Error('Transaction failed with dispatch error'));
}
}
}).catch(reject);
});
Polkadot API doc should be updated appropriately as per ^10.11.2 version
The text was updated successfully, but these errors were encountered:
Dante9988
changed the title
Polkadot API Transfer event Nonce issue
Polkadot API Transfer event Nonce issue when using api.query.system
Jun 25, 2024
Dante9988
changed the title
Polkadot API Transfer event Nonce issue when using api.query.system
Polkadot API Transfer event Nonce issue when using api.query.system.account
Jun 25, 2024
Description: When getting a nonce by following doc https://polkadot.js.org/docs/api/examples/promise/transfer-events
current nonce is incorrect and replies with error message:
VEC: Unable to decode on index 0 createType(Lookup0):: Unknown type passed to AccountId constructor, found typeof object RPC-CORE: queryStorageAt(keys: Vec<StorageKey>, at?: BlockHash): Vec<StorageChangeSet>:: createType(Vec<StorageKey>):: createType(Lookup0):: Unknown type passed to AccountId constructor, found typeof object
Better way to get nonce is this:
let currentNonce = (await api.rpc.system.accountNextIndex(baseAccount.address)).toBigInt();
When sending txn to substrate network, following structure fits the best:
Polkadot API doc should be updated appropriately as per ^10.11.2 version
The text was updated successfully, but these errors were encountered: