sendTransaction method

Future<String> sendTransaction(
  1. EVMRPC rpc
)

Sends the signed transaction to the Ethereum network via the provided RPC.

Throws an exception if there are validation errors or if the RPC request fails.

Implementation

Future<String> sendTransaction(EVMRPC rpc) async {
  // Check for validation errors before sending the transaction
  _checkError();
  // Convert the signed transaction to raw hex format
  final rawHex =
      BytesUtils.toHexString(signedSerializedTransaction(), prefix: "0x");
  // Send the raw transaction hex to the Ethereum network
  final result =
      await rpc.request(RPCSendRawTransaction(transaction: rawHex));
  // Return the transaction hash upon successful submission
  return result;
}