EIP-6968 · Stagnant · Core · 2023-05-01
EIP-6968: Contract Secured Revenue on an EVM based L2
Proposes that EVM-based L2s share part of each transaction's base fee with the contracts that consumed the gas, giving developers protocol-level revenue (Contract Secured Revenue).
What problem does it solve?
On Ethereum, transaction fees go to the protocol (the burned base fee) and to the block producer (the tip). The developers of the contracts that users actually interact with receive nothing at the protocol level, so they have to add their own fees or token schemes to fund development or public goods.
Contract Secured Revenue (CSR) gives a share of fees back to the contracts that did the work. EIP-6968 explicitly does not propose this for Ethereum L1. It describes how an EVM-based L2 could adopt CSR to attract developers and fund public goods.
How it works
- Gas tracking per address. During a transaction the client keeps
gas_used_by_address. Each instruction's gas is charged to the contract currently executing. For call and create instructions, only the caller's own cost is counted (total cost minus the gas forwarded to the child frame, per EIP-150). On an out-of-gas error, the frame's remaining gas is counted too. - Revenue recipient. By default a contract's revenue goes to itself. A new opcode
SETREVENUERECIPIENT(0x49), costing 3 gas, lets a contract point its revenue at another address. The mapping is rebuilt every transaction, so a contract has to call the opcode during execution for the redirect to apply. - Payout. After the transaction, each tracked address's recipient is credited:
revenue = gas_used * (base_fee_per_gas // REVENUE_SHARE_QUOTIENT) # REVENUE_SHARE_QUOTIENT = 5
With a quotient of 5, roughly one fifth of the base fee for the gas a contract used is redirected to it instead of being burned. Externally owned accounts receive nothing, because they do not execute code.
Splitting by gas used, rather than paying everything to the transaction's to address, rewards every contract in a composed call chain and works with smart contract wallets, which are often the first contract called.
Sample code
A contract redirecting its revenue to a treasury. Solidity has no keyword for the new opcode, so this is pseudocode for what the contract would execute on a chain implementing the EIP:
// inside doWork(), before the main logic
PUSH20 <treasury address>
SETREVENUERECIPIENT // opcode 0x49, 3 gas, pops 1 item
// ... rest of the function; gas used by this contract in this
// transaction now earns revenue for <treasury address>
Client-side payout logic:
for addr, gas in gas_used_by_address.items():
recipient = revenue_recipient.get(addr, addr)
state.add_balance(recipient, gas * (header.base_fee_per_gas // REVENUE_SHARE_QUOTIENT))
Things to know
- Status: Stagnant. It is a design for L2s to consider, not something Ethereum L1 will adopt.
- The spec text is inconsistent: the fee-mechanism paragraph says
base_fee * REVENUE_SHARE_QUOTIENT, while the payout formula divides by it. The payout formula (division, about 20 %) is the one that makes sense. - Opcode
0x49was later assigned toBLOBHASHon Ethereum by EIP-4844, so a chain adopting this would need a different opcode. - Paying contracts per unit of gas creates an incentive to burn gas deliberately. The spec notes possible effects on block size and complexity but does not fully analyse gas-farming.