ECIP 1042: GASPAY opcode Source

AuthorIgor Artamonov
TypeStandards Track

ECIP-1042 - GASPAY opcode


Add an operation to consume gas and add amount paid for that gas to token balance.


A useful Smart Contract (i.e. valuable) should expect small reward for its execution. A micropayment could be very small a sub-cent payment but sending an additional value to a contract will make it more complicated and cost of such transfer or contract execution could exceed requested reward.

It’s proposed here to introduce a new EVM Operation that will allow a developer to consume a portion of transaction fee (amount paid for a gas) and transfer it to current Smart Contract.

Using a gas payment provided with transaction provides flexibility and independence from market price of Ether. Gas Price is dynamic value and supposed to represent fair market price of contract execution, therefore making micropayment value proportional to const of transaction and more stable in long term.


Provide a new operation GASPAY a where a is amount of gas to consume, and 0x0 <= a <= 0x0fffff. The payment for that gas goes to contract address. As a return it puts consumed value (Wei) into the stack.

The cost of the operation itself is equal to 1/4 of requested amount of Gas plus 5000 (a/4 + 5000). The payment for that gas is going to miner address, and supposed to compensate potential miner loss from including in a block transaction that doesn’t give all gas fee as a reward to a miner.

Op code value: 0x3d
Mnemonic: GASPAY
δ: 1
α: 1

With the current average price of 23000 MWei per Gas, a smart contract can earn up to $1 per operation, by requesting payment for 1,048,575 of Gas.

Risks consideration

Miners don’t receive payment for all gas in a block

Currently miners expect that all payment for the gas goes to coinbase. After introducing this operation part of this payment could go to smart contracts participated in block transactions. This plays a role only when we have blocks fully packed with transaction, up to the block gas limit, which is a dynamic value and can be controlled by miners.

Because cost of the execution of that operation is a constant and roughly is about 5000 of Gas, then requested cost of execution as a/4 + 5000 will be as much as profitable as including other transactions with same gas limit. With that cost it’s expected that a miner could earn 10%-20% of a requested amount, in addition to cost of actual work spent on execution of that transaction. If gas prices per opcodes are fair, then a miner could be in favour of adding a transaction with GASPAY opcode as it provides slightly more profit to a miner too.

Software must distinguish payment went to contract and to miner

Most of the current 3rd party software expect that whole payment for a gas will go to a miner of the block. It includes dev tools, block explorers and nodes (protocol implementations).

After introducing this new opcode, all this software must be updated according to a new way of gas payment calculation.

Smart Contract language compilers

Solidity and other smart contract language compilers will need to be updated to support additional opcode