You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, @DiwakarThapa
Think you need estimateGas function. It estimates a minimal amount of gas required to run a transaction. To do it the Ethereum node tries to run it and counts how much gas it consumes for computations. Setting the transaction gas limit lower than the estimate will most likely result in a failing transaction.
Usage example
letweb3=Web3.InfuraMainnetWeb3()letsendToAddress=EthereumAddress("recepient_address")letkeystore=try!EthereumKeystoreV3(password:"")letkeystoreManager=KeystoreManager([tempKeystore!])
web3.addKeystoreManager(keystoreManager)letcontract= web3.contract(Web3.Utils.coldWalletABI, at: sendToAddress, abiVersion:2)
guard let writeTX = contract?.write("fallback")else{return}// you can use any other tx method
writeTX.transactionOptions.from = tempKeystore!.addresses?.first // its your address
writeTX.transactionOptions.value =BigUInt("1.0",.eth)// value in ethletestimate=try writeTX.estimateGasPromise().wait()print(estimate)// here you'll get gas estimation
Hello,
I wanted to know is there any function in web3swift to validate minimum amount required to make transaction ?
The text was updated successfully, but these errors were encountered: