serialized property

  1. @override
Uint8List get serialized
override

Used for Signing the transaction

Implementation

@override
Uint8List get serialized {
  if (hasSignature == false) {
    throw Exception("Transaction is not signed, cannot serialize");
  }

  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;
  final _accessList = accessList.map((item) {
    return [
      item.address.replaceFirst("0x", ""),
      item.storageKeys,
    ];
  }).toList();
  final _signatureYParity = signatureYParity.toBI.bigIntToBytes.toHex;
  final _signatureR = signatureR.toHex;
  final _signatureS = signatureS.toHex;

  List<dynamic> buffer = [
    chainId.toBI.bigIntToBytes.toHex,
    _nonce,
    _gasPrice,
    _gasLimit,
    _to,
    _value,
    _data,
    _accessList,
    _signatureYParity,
    _signatureR,
    _signatureS,
  ];

  return Uint8List.fromList(
    [0x01, ...rlpEncode(buffer).hexToBytes],
  );
}