This question already has an answer here:

The contract contains ether. Can I buy the gas within the contract code?

marked as duplicate by eth Jun 25 '16 at 21:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You want to steal the gas ? find an exploit in the smart contract code! If there is no hack/exploit you can't. Otherwise if you're talking about the gas fees, only the miner who mines the block wins the gas. – Ellis Jun 25 '16 at 15:36
  • no, if i see, that msg.gas is small, i want bay gas for miner. – SkyN Jun 25 '16 at 18:02

Yes and no.

The gas has to be paid for, up front, by the original sender. There's no way to add more gas inside a transaction.

However, it's possible for a contract to reimburse the sender. It's also possible for the transaction to have a gasPrice of 0, and then the contract reimburses the miner via sending to msg.coinbase. In the latter case, a miner would have to be specifically programmed to accept that kind of transaction.

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