buildTransaction method

Future<RawEvmTransaction> buildTransaction({
  1. required String sender,
  2. required String recipient,
  3. required Uint8List seed,
  4. required EvmFeeInformation<EvmGasPrice>? feeInfo,
  5. required Uint8List? data,
  6. required BigInt? value,
  7. 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;
}