I need help on how to charge a transaction fee in ethereum smart contract using web3? Also which web3 API can be used to check the validation of enough gas on the frontend of smart contract?

  • You charge fee in the contract, what does web3 has to do with this??? Jun 30 '19 at 10:25
  • In most cases, the needed gas price to pay and the gas limit would be automatically calculated for you by the web3 library and you wouldn't have to actively think about it. Aug 23 at 11:22

Do you want to estimate the fee of the transaction?

let gasPrice = new BigNumber(15).times(1000000000);
let gasLimit = new BigNumber(21000);
let estimateFee = new BigNumber(gasPrice.times(gasLimit)).dividedBy(1000000000000000000).toString();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.