buildTransaction method
- required String sender,
- required String recipient,
- required Uint8List seed,
- required EvmFeeInformation<
EvmGasPrice> ? feeInfo, - required Uint8List? data,
- required BigInt? value,
- List<
AccessListItem> ? accessList,
Used to create a raw Transactions Fetches the gasPrice and gasLimit from the network Fetches the nonce from the network Signs the transaction
Implementation
Future<RawEvmTransaction> buildTransaction({
required String sender,
required String recipient,
required Uint8List seed,
required EvmFeeInformation? feeInfo,
required Uint8List? data,
required BigInt? value,
List<AccessListItem>? accessList,
}) async {
final unsignedTx = await buildUnsignedTransaction(
sender: sender,
recipient: recipient,
feeInfo: feeInfo,
data: data,
value: value,
accessList: accessList,
);
final signature = Signature.createSignature(
switch (unsignedTx) {
RawEVMTransactionType0() => unsignedTx.serializedUnsigned(type.chainId),
RawEVMTransactionType1() => unsignedTx.serializedUnsigned,
RawEVMTransactionType2() => unsignedTx.serializedUnsigned,
},
txType: switch (unsignedTx) {
RawEVMTransactionType0() => TransactionType.Legacy,
RawEVMTransactionType1() => TransactionType.Type1,
RawEVMTransactionType2() => TransactionType.Type2,
},
derivePrivateKeyETH(seed),
chainId: type.chainId,
);
final signedTx = unsignedTx.addSignature(signature);
return signedTx;
}