decode static method

dynamic decode(
  1. Uint8List data
)

Decodes RLP-encoded data.

Returns either a Uint8List for single items or a List for sequences.

Example:

RLP.decode(Uint8List.fromList([0x83, 0x64, 0x6f, 0x67])); // 'dog' as bytes

Implementation

static dynamic decode(Uint8List data) {
  if (data.isEmpty) {
    throw RlpException('Cannot decode empty data');
  }

  final (result, consumed) = _decode(data, 0);

  if (consumed != data.length) {
    throw RlpException('Invalid RLP: extra bytes after decoding');
  }

  return result;
}