ConstantsCodec class

Codec for encoding and decoding Substrate runtime constants

This codec handles runtime constants which are fixed values defined in pallets. Constants are stored in metadata with their SCALE-encoded values and can be accessed and decoded at runtime.

Example:

final registry = MetadataTypeRegistry(metadata);
final constantsCodec = ConstantsCodec(registry);

// Get a specific constant
final existentialDeposit = constantsCodec.getConstant('Balances', 'ExistentialDeposit');
print('Existential Deposit: $existentialDeposit');

// Get all constants for a pallet
final balancesConstants = constantsCodec.getPalletConstants('Balances');
for (final entry in balancesConstants.entries) {
  print('${entry.key}: ${entry.value}');
}

Constructors

ConstantsCodec(MetadataTypeRegistry registry)

Properties

hashCode int
The hash code for this object.
no setterinherited
registry MetadataTypeRegistry
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearCache() → void
Clear the cache
clearPalletCache(String palletName) → void
Clear cache for a specific pallet
getAllConstants() Map<String, Map<String, dynamic>>
Get all constants from all pallets
getConstant(String palletName, String constantName) → dynamic
Get a specific constant value from a pallet
getConstantInfo(String palletName, String constantName) ConstantInfo?
Get constant metadata information
getPalletConstants(String palletName) Map<String, dynamic>
Get all constants for a specific pallet
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited