diff --git a/cw_evm/lib/evm_chain_client.dart b/cw_evm/lib/evm_chain_client.dart index 033dc7143..1935df2af 100644 --- a/cw_evm/lib/evm_chain_client.dart +++ b/cw_evm/lib/evm_chain_client.dart @@ -72,12 +72,12 @@ abstract class EVMChainClient { } } - Future getGasBaseFee() async { + Future getGasBaseFee() async { try { final blockInfo = await _client!.getBlockInformation(isContainFullObj: false); final baseFee = blockInfo.baseFeePerGas; - return baseFee!.getInWei.toInt(); + return baseFee?.getInWei.toInt(); } catch (_) { return 0; } @@ -110,19 +110,19 @@ abstract class EVMChainClient { EthereumAddress.fromHex(contractAddress), ); - final transferFunction = contract.function('transferFrom'); + final transfer = contract.function('transfer'); - final estimatedGas = await _client!.estimateGas( + // Estimate gas units + final gasEstimate = await _client!.estimateGas( sender: senderAddress, - to: toAddress, - value: value, - data: transferFunction.encodeCall([ - senderAddress, + to: EthereumAddress.fromHex(contractAddress), + data: transfer.encodeCall([ toAddress, value.getInWei, ]), ); - return estimatedGas.toInt(); + + return gasEstimate.toInt(); } } catch (_) { return 0; diff --git a/cw_evm/lib/evm_chain_wallet.dart b/cw_evm/lib/evm_chain_wallet.dart index 2ab1c17a0..760c50a04 100644 --- a/cw_evm/lib/evm_chain_wallet.dart +++ b/cw_evm/lib/evm_chain_wallet.dart @@ -387,8 +387,6 @@ abstract class EVMChainWalletBase estimatedFeesForTransaction = BigInt.from(estimateFees); - debugPrint('Estimated Fees for Transaction: $estimatedFeesForTransaction'); - if (output.sendAll && transactionCurrency is! Erc20Token) { totalAmount = (erc20Balance.balance - estimatedFeesForTransaction);