sendTransaction method

Future<TransactionResponse> sendTransaction(
  1. TransactionRequest request
)

Submits transaction to the network to be mined.

The transaction must be valid (i.e. the nonce is correct and the account has sufficient balance to pay for the transaction).

Implementation

Future<TransactionResponse> sendTransaction(
    TransactionRequest request) async {
  try {
    return TransactionResponse._(await _call<_TransactionResponseImpl>(
        'sendTransaction', [request.impl]));
  } catch (error) {
    final err = dartify(error);
    switch (err['code']) {
      case 4001:
        throw EthereumUserRejected();
      default:
        if (err['message'] != null)
          throw EthereumException(
            err['code'],
            err['message'],
            err['data'],
          );
        else if (err['reason'] != null)
          throw EthersException(
            err['code'],
            err['reason'],
            err as Map<String, dynamic>,
          );
        else
          rethrow;
    }
  }
}