ModuleError

Composite 27 v393

sp_runtime::ModuleError

About This Type

Error originating from a specific pallet (module).

Contains the pallet index and error index, which can be looked up in runtime metadata to determine the exact error name and description.

Encoding: 1 byte pallet index + 4 bytes error data (first byte is the error index within the pallet).

Fields (2)

#NameType
0indexu8
1error[u8; 4]

SCALE Encoding

Rule
2 fields encoded consecutively in declaration order. No field names or delimiters.
Size
sum of field sizes

Examples

Struct with 2 fields = index: u8, error: [u8; 4]
0x<field0><field1>
field 0 index: u8
field 1 error: [u8; 4]

Code Examples

import { TypeRegistry } from "@polkadot/types";

const registry = new TypeRegistry();

// Encode ModuleError
const value = registry.createType("ModuleError", {
  index: 42,
  error: 0
});
console.log("Hex:", value.toHex());

Referenced By (1)

Type Information

Type ID
27
Kind
Composite
Path
sp_runtime::ModuleError
Runtime
v393