getI256Decoder

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

Returns a decoder for 256-bit signed integers (i256).

This decoder deserializes i256 values from 32 bytes. The decoded value is always a bigint.

For more details, see getI256Codec.

Parameters

ParameterTypeDescription
configNumberCodecConfigOptional configuration to specify endianness (little by default).

Returns

FixedSizeDecoder<bigint, 32>

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

Example

Decoding an i256 value.

const decoder = getI256Decoder();
const value = decoder.decode(new Uint8Array([
  0xd6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
])); // -42n

See

getI256Codec

On this page