send method

Future<TransactionResponse> send({
  1. required String method,
  2. List args = const [],
  3. required BigInt gas,
  4. BigInt? value,
})

Implementation

Future<TransactionResponse> send(
    {required String method,
    List<dynamic> args = const [],
    required BigInt gas,
    BigInt? value}) async {
  final iface = Interface(abi);
  final encode = iface.encodeFunctionData(method, args);
  print(encode);
  try {
    return TransactionResponse._(
        await promiseToFuture<_TransactionResponseImpl>(_sendTransaction(
            RequestTransaction(
                type: 'SMART_CONTRACT_EXECUTION',
                from: signer,
                to: address,
                data: encode,
                gas: gas.toString(),
                value: value?.toString()))));
  } catch (error) {
    final errorString = error.toString();
    const message = "Error: evm: execution reverted";
    if (errorString.contains(message)) {
      throw KlaytnEvmExcutionReverted(
          message, jsonDecode(dartify(errorString.replaceAll(message, ""))));
    } else if (errorString.contains("User denied transaction signatur")) {
      throw KlaytnUserRejected();
    } else {
      rethrow;
    }
  }
}