---
eip: 7791
label: EIP-7791
title: GAS2ETH opcode
status: Draft
type: Standards Track
category: Core
created: 2024-08-13
requires: 2929
official: https://eips.ethereum.org/EIPS/eip-7791
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7791.md
canonical: https://eips.huatuo.xyz/eip-7791/
lang: en
tldr: Draft opcode that lets a contract charge the caller extra gas and pay it as ETH to any address, giving contract authors a usage-based revenue stream.
tags: [evm, opcode, core, fees, public-goods]
---

# EIP-7791: GAS2ETH opcode

> Introduces a new opcode, `GAS2ETH`, to convert gas to ETH

**TL;DR:** Draft opcode that lets a contract charge the caller extra gas and pay it as ETH to any address, giving contract authors a usage-based revenue stream.

## What problem does it solve?

Popular contracts, compilers and libraries create a lot of value and drive demand for blockspace, but there is no built-in way for their authors to earn from usage. Projects resort to custom fees, tokens or donations, each with its own UX.

`GAS2ETH` lets a contract say "this call costs N extra gas, paid to address X". Users already understand paying gas, wallets already estimate it, and the author's income automatically rises and falls with network demand.

## How it works

A new opcode `GAS2ETH` (`0xFC`):

1. Pops `addr` and `gas_amount`.
2. Caps `gas_amount` at the remaining local allowance of the current call and the remaining transaction-wide budget.
3. Computes `wei_val = gas_amount * gas_price` (the transaction's effective gas price).
4. Credits `wei_val` to `addr` without running any code there (like a beacon withdrawal; the transfer cannot fail).
5. Pushes `wei_val`.

**Budgets.** Each transaction has a global `GAS2ETH` budget equal to its gas limit. Each call frame gets a local allowance equal to the gas forwarded to it (capped by the global budget); `DELEGATECALL` shares the caller's allowance. If the frame reverts, its payouts are undone and returned to both budgets. Unused allowance flows back on normal return.

**Accounting.** Gas converted by `GAS2ETH` does not count as block gas used, does not affect the base fee or burn, and is not part of the block producer's fee. It is a direct payment from the transaction signer to `addr`.

**Cost.** The opcode itself costs the same as the proposed `PAY` opcode ([EIP-5920](/eip-5920/)): warm/cold account access per [EIP-2929](/eip-2929/), plus new-account and value-transfer surcharges when applicable.

## Sample code

There is no Solidity keyword for it; a contract would use inline assembly with a raw opcode once a compiler supports it. Illustrative only:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract MeteredLibrary {
    address public immutable author;
    uint256 public constant ROYALTY_GAS = 2_000;

    constructor(address _author) { author = _author; }

    function compute(uint256 x) external returns (uint256) {
        address recipient = author;
        // Hypothetical: needs a compiler that exposes GAS2ETH (0xFC), which
        // pops addr then gas_amount and pushes the wei actually paid.
        // assembly { pop(gas2eth(recipient, ROYALTY_GAS)) }
        recipient; // silence unused-variable warning until then
        return x * x;
    }
}
```

What the caller pays, in plain arithmetic:

```ts
// effective gas price 20 gwei, contract charges 2,000 gas via GAS2ETH
const paidToAuthor = 2_000n * 20_000_000_000n; // 4e13 wei = 0.00004 ETH
```

## Things to know

- Status is **Draft**. Test cases and a reference implementation are still `TBD`, and no fork has scheduled it.
- The opcode silently caps rather than failing when budgets are exhausted, because a contract cannot read its remaining allowance.
- It creates a new griefing incentive: an untrusted callee can convert as much of its forwarded gas as possible into ETH for itself. Forward only the gas you need when calling unknown contracts.
- The total payout in one transaction is bounded by its gas limit, so users are protected from unbounded charges, but wallets would need to show this cost clearly.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7791
