Runtime Errors

v393

Every failed extrinsic returns a DispatchError with one of 15 variants. Some variants wrap nested error enums with more specific codes. In total there are 44 error variants across all levels.

How Runtime Errors Work

When an extrinsic fails, the runtime returns a DispatchError. This is a Rust enum with 15 variants. Simple errors like BadOrigin are self-contained. Others like Module, Token, and Arithmetic wrap a nested enum with more specific error codes.

Module errors are the most common. They come from individual pallets and require decoding the pallet index and error index to identify the specific error.

DispatchError Variants

IndexNameDescriptionDetails
0Other Some unclassified error occurred--
1CannotLookup Failed to look up some data (account, storage key, etc.)--
2BadOrigin The origin of the call does not have the required permission--
3Module nestedPallet-specific error — decode via pallet index + error index to find the exact errorView
4ConsumerRemaining Cannot remove account: there are still consumers referencing it--
5NoProviders Cannot create account: there are no providers to allow creation--
6TooManyConsumers Cannot add a new consumer: the account has too many consumers--
7Token nestedToken/balance operation failed — see nested TokenErrorView
8Arithmetic nestedArithmetic operation failed — see nested ArithmeticErrorView
9Transactional nestedTransactional storage layer error — see nested TransactionalErrorView
10Exhausted Resources exhausted (e.g., all allowable extrinsics weight consumed)--
11Corruption The state is corrupt; this is a bug in the runtime--
12Unavailable Some resource (e.g., a preimage) is unavailable right now--
13RootNotAllowed Root origin is not allowed for this operation--
14Trie nestedTrie/proof verification error — see nested TrieErrorView

Nested Error Enums

These enums provide specific error codes when a DispatchError variant wraps additional detail.

Module Errors

ModuleError

21 pallets 326 errors

Wraps pallet-specific errors with pallet index and error bytes

SystemGrandpaBalancesSubtensorModuleUtilitySudoMultisigPreimage +13 more

For Developers

Decode a DispatchError from an extrinsic result:

// Using polkadot.js API
const tx = api.tx.subtensorModule.addStake(hotkey, amount);
const result = await tx.signAndSend(coldkey);

// Check for DispatchError
result.events.forEach(({ event }) => {
  if (api.events.system.ExtrinsicFailed.is(event)) {
    const [dispatchError] = event.data;
    if (dispatchError.isModule) {
      // Module error - decode pallet + error index
      const decoded = api.registry.findMetaError(dispatchError.asModule);
      console.log(`${decoded.section}.${decoded.name}: ${decoded.docs}`);
    } else {
      // Non-module error (BadOrigin, Token, Arithmetic, etc.)
      console.log(dispatchError.toString());
    }
  }
});