Option
Variant 51 v393Option
About This Type
Optional value: Some(value) or None.
Used when a value may or may not be present. Common in storage queries where a key may not exist.
Encoding: Variant: 0x00 = None, 0x01 = Some(value). Exception: Option<bool> uses 0x00=None, 0x01=true, 0x02=false.
Variants (2)
| Index | Name | Fields | Docs |
|---|---|---|---|
| 0 | None | none | |
| 1 | Some |
SCALE Encoding
- Rule
- Variant: 0x00 = None, 0x01 = Some(value).
- Size
- variable (1+ bytes)
Examples
None
0x0000 Variant index 0 = NoneSome(42u32) = Some(42)
0x012a00000001 Variant index 1 = Some2a 00 00 00 42 as u32 little-endianCode Examples
import { TypeRegistry } from "@polkadot/types";
const registry = new TypeRegistry();
// Encode Option — variant "None"
const value = registry.createType("Option", "None");
console.log("Hex:", value.toHex());Type Parameters
T = u32
Referenced By (157)
#39 SubtensorModule::Event via SubnetLeaseCreated.end_block#57 Sudo::Event via KeyChanged.old#62 Scheduler::Event via Dispatched.id#62 Scheduler::Event via RetrySet.id#62 Scheduler::Event via RetryCancelled.id#62 Scheduler::Event via CallUnavailable.id#62 Scheduler::Event via PeriodicFailed.id#62 Scheduler::Event via RetryFailed.id#62 Scheduler::Event via PermanentlyOverweight.id#112 WeightsPerClass via max_extrinsic#112 WeightsPerClass via max_total#112 WeightsPerClass via reserved#143 SubtensorModule::Call via swap_hotkey.netuid#143 SubtensorModule::Call via swap_hotkey_v2.netuid#143 SubtensorModule::Call via register_network_with_identity.identity#143 SubtensorModule::Call via remove_stake_full_limit.limit_price#143 SubtensorModule::Call via register_leased_network.end_block#143 SubtensorModule::Call via add_stake_burn.limit#164 Multisig::Call via as_multi.maybe_timepoint#164 Multisig::Call via approve_as_multi.maybe_timepoint
and 137 more...
Type Information
- Type ID
- 51
- Kind
- Variant
- Path
- Option
- Runtime
- v393