3

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

SkyN
  • 175
  • 3
  • 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

1 Answers1

3

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.

Matthew Schmidt
  • 7,290
  • 1
  • 24
  • 35