serialized property
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 _maxFeePerGas = maxFeePerGas.bigIntToBytes.toHex;
final _maxPriorityFeePerGas = maxPriorityFeePerGas.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,
_maxPriorityFeePerGas,
_maxFeePerGas,
_gasLimit,
_to,
_value,
_data,
_accessList,
_signatureYParity,
_signatureR,
_signatureS,
];
return Uint8List.fromList(
[0x02, ...rlpEncode(buffer).hexToBytes],
);
}