Result

Variant 42 v393

Result

About This Type

Standard Rust Result type: Ok(()) or Err(DispatchError).

The return type of most pallet dispatchable calls. Ok indicates success; Err contains a DispatchError explaining what went wrong.

Encoding: Variant: 0x00 = Ok (no payload), 0x01 = Err (followed by DispatchError encoding).

Variants (2)

IndexNameFieldsDocs
0Ok
1Err

SCALE Encoding

Rule
Variant: 0x00 = Ok (no payload), 0x01 = Err (followed by DispatchError).
Size
variable (1+ bytes)

Examples

Success (Ok) = Ok(())
0x00
00 Variant index 0 = Ok, no payload
Failure (Err) = Err(DispatchError::BadOrigin)
0x0102
01 Variant index 1 = Err
02 DispatchError variant 2 = BadOrigin

Code Examples

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

const registry = new TypeRegistry();

// Encode Result — variant "Ok"
const value = registry.createType("Result", { Ok: { value: 0 } });
console.log("Hex:", value.toHex());

Type Parameters

T = ()
E = DispatchError

Referenced By (10)

Type Information

Type ID
42
Kind
Variant
Path
Result
Runtime
v393