1

When is Ethereum gas fee calculated during execution of contract. I was wondering if i take out flash loan and if the trade happened to be profitable, will the profit be able to offset transaction fee or I would have to pay upfront?

1 Answer 1

4

When you create a transaction you set two parameters:

  • gas: Maximum amount of gas to be used
  • gasPrice: Price to pay for each gas unit

To execute the transaction your account needs to have at least gas * gasPrice ether.

Before executing your account is charged with gas * gasPrice.

After the transaction has completed its execution unused gas and refunded gas are returned to your account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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