0

I understand that there are 2 endpoints for smart contracts. Call() for running view/pure function and SendTransaction() for state-changing transactions. Obviously a state-changing transaction sent to Call() would be reverted, but what happens in the inverse? Could the transaction still be mined and added to the chain? And can gas be consumed if gas was added?

1 Answer 1

1

It works the same as any other transactions: You can call a view or pure function in a transaction, and the transaction can be mined as usual. It just won't do anything of course, since it's a view or pure function.

4
  • 1
    Just to add also that the gas has to be paid even if it's a view function Jan 18, 2021 at 16:41
  • @Lauri Peltonen doesn't it only cost gas when it is called another contract and not a client?
    – RhinoBomb
    Jan 18, 2021 at 16:58
  • If it's in a real transaction, it always costs gas, doesn't matter if there's another contract or not Jan 18, 2021 at 17:00
  • Note that calls also use gas, in the same way as transactions, but you don't have to pay for it. Calls where the gas required goes over the block gas limit will not work.
    – Morten
    Jan 18, 2021 at 17:42

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.