Imagine I've created a voting contract, and I'm the owner of this contract. I'm going to deploy it and create a front end to interact with it.

Within my contract i've everything secured to add authorized voters and possible winning candidates.

With all set, after the deployement, I don't want that my voters actually pay to vote in someone, so as owner I want also take care of all transaction fees.

Here's the first question: Is it possible a scenario like this? As contract deployer/owner, also handle all fees that are used to do contract state changes?

Next question: Imagine that an unauthorized voter is trying to bypass this authorization and spam my vote function. As the owner of the contract and handler of all fees, i dont want to be charged if something like this occur. So summary, do "requires" actually consume gas if no change in the contract state occurs?

  • You cannot revoke the gas-fee (think about it - it is paid to a miner, not to you). You can, however, transfer some ether back to the sender, in order to compensate for the alleged gas-fee. – goodvibration Sep 3 at 11:55
  • In the case of require / assert / revert, however, you will not even be able to do that, because the entire transaction will be reverted (and the compensation will not be transferred to the sender). However, so long as you use require (and not assert), and so long as you do it early enough within the flow of the function, the less gas-fee will be inflicted on the user. So you could technically reduce this fee to a very small amount. – goodvibration Sep 3 at 11:58
  • @goodvibration: why not just answer the question? I don't understand why you made a comment and not an answer? – Thomas Jay Rush Sep 5 at 22:59

Your Answer

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

Browse other questions tagged or ask your own question.