serializedUnsigned method

Uint8List serializedUnsigned([
  1. int? chainId
])

Implementation

Uint8List serializedUnsigned([int? chainId]) {
  final _nonce = nonce.bigIntToBytes.toHex;
  final _gasPrice = gasPrice.bigIntToBytes.toHex;
  final _gasLimit = gasLimit.bigIntToBytes.toHex;
  final _to = to.replaceFirst("0x", "");
  final _value = value.bigIntToBytes.toHex;
  final _data = data.toHex;

  List<String> buffer = [
    _nonce,
    _gasPrice,
    _gasLimit,
    _to,
    _value,
    _data,
  ];

  /// EIP-155: If the chainId is present, add it to the buffer before encoding
  if (chainId != null) {
    buffer.addAll([
      chainId.toBI.bigIntToBytes.toHex,
      "",
      "",
    ]);
  }

  return rlpEncode(buffer).hexToBytes;
}