I'm currently writing my first smart contract and I'm trying to figure out how to inject gas into the contract, of course, if it's possible.
I'm not sure If I got it correctly. With every transaction client pays the fee, in gas, and this gas will be used to execute called smart contract function.
In brief, I deploy the contract do I need to provide gas to it? Can I somehow force clients to do that?
By the way, this.balance of contract is used as gas storage?
Cheers!
Best Answer
When deploying what you have to pay is the fee of the transaction that was used to put the contract in the blockchain. Whenever someone wants to use your contract (invoke a function), he needs to send a transaction for that. And as you have correctly mentioned,
the one who send the transaction will have to pay the gas cost of executing that particular function in the contract.
You may refer this question as well.
Hope this helps!
EDIT - If it's a call for a
constant
function,view
orpure
, there won't be a transaction initiated, hence no gas cost. Check this for more onview
andpure
functions.