ArithmeticError

Variant 29 v393

sp_arithmetic::ArithmeticError

About This Type

Error from arithmetic operations: Overflow, Underflow, or DivisionByZero.

Returned when on-chain math produces an invalid result. Part of DispatchError.

Variants (3)

IndexNameFieldsDocs
0Underflownone
1Overflownone
2DivisionByZeronone

SCALE Encoding

Rule
1-byte variant index followed by variant-specific field data. 3 possible variants.
Size
variable (1+ bytes)

Examples

Underflow
0x00
00 Variant index 0 = Underflow
Overflow
0x01
01 Variant index 1 = Overflow
DivisionByZero
0x02
02 Variant index 2 = DivisionByZero

Code Examples

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

const registry = new TypeRegistry();

// Encode ArithmeticError — variant "Underflow"
const value = registry.createType("ArithmeticError", "Underflow");
console.log("Hex:", value.toHex());

Referenced By (1)

Type Information

Type ID
29
Kind
Variant
Path
sp_arithmetic::ArithmeticError
Runtime
v393