getU256Decoder

function getU256Decoder(config?): FixedSizeDecoder<bigint, 32>;

Returns a decoder for 256-bit unsigned integers (u256).

This decoder deserializes u256 values from thirty-two bytes in little-endian format by default. You may specify big-endian storage using the endian option.

For more details, see getU256Codec.

Parameters

ParameterTypeDescription
configNumberCodecConfigOptional settings for endianness.

Returns

FixedSizeDecoder<bigint, 32>

A FixedSizeDecoder<bigint, 32> for decoding u256 values.

Example

Decoding a u256 value.

const decoder = getU256Decoder();
const value = decoder.decode(new Uint8Array([
  0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
])); // 42n

See

getU256Codec

On this page