neo-devpack-solidity 0.22.0

Production-focused Solidity-to-NeoVM compilation system
Documentation
---
title: "EIP-3198 — BASEFEE Opcode"
description: "EIP-3198 — BASEFEE Opcode mapped to Neo N3."
---

# EIP-3198 — BASEFEE Opcode

[Back to Protocol-Level EIPs](/standards-mirror/protocol-eips)

<StandardsMirror>

<StandardEntry
  id="eip-3198"
  title="EIP-3198 — BASEFEE Opcode"
  eip="3198"
  status="Final"
  neoMapping="Policy.GetFeePerByte"
  category="Fees"
  parityLabel="Native"
  parityClass="sm-pill-native"
>

<template #spec>

## EIP-3198: BASEFEE Opcode

[EIP-1559](./eip-1559) added a base fee to blocks. EIP-3198 added the `BASEFEE` opcode (`block.basefee`
in Solidity) so contracts can read the current block's base fee. Used by
fee-aware contracts and on-chain MEV mitigation logic.

### Neo Equivalent

The PolicyContract native is the equivalent: contracts read fee parameters via
`Policy.GetFeePerByte()` and `Policy.GetExecFeeFactor()`. The fee model is
deterministic per-block but doesn't auto-adjust; values change only when committee
nodes vote a change.


::: tip Live on Neo TestNet
Both implementations are deployed on Neo N3 TestNet (network magic `894710606`).

| Implementation | Contract Hash | Deploy Tx |
| --- | --- | --- |
| **Solidity** (`neo-solc`) | `0x8ed358aea7789a0d2c60a42c692c469bf1da60a0` | (reused — see [`0x8ed358aea7789a0d2c60a42c692c469bf1da60a0`]https://dora.coz.io/contract/neo3/testnet/0x8ed358aea7789a0d2c60a42c692c469bf1da60a0) |
| **Neo C#** (`nccs`) | `0x32b98cb268f39b8ced382e7fe6d160833ab4f630` | (reused — see [`0x32b98cb268f39b8ced382e7fe6d160833ab4f630`]https://dora.coz.io/contract/neo3/testnet/0x32b98cb268f39b8ced382e7fe6d160833ab4f630) |

Checked-in snapshot: Solidity 1 / 2 assertions pass; Neo C# 1 / 1 assertions pass. This is a validation snapshot, not an all-green parity certification; see [TestNet Results](/standards-mirror/deployments/RESULTS) for failure details.

Source pairs: [`docs/standards-mirror/deployments/eip-3198/`](https://github.com/r3e-network/neo-devpack-solidity/tree/main/docs/standards-mirror/deployments/eip-3198).
:::

</template>

<template #solidity>

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

contract FeeAware {
    /// @notice Estimate cost of a method given the current base fee.
    function estimateCost(uint256 expectedGasUsed) external view returns (uint256 wei_) {
        return expectedGasUsed * block.basefee;
    }

    /// @notice Refuse to operate if base fee is unreasonably high
    /// (e.g. avoid burning user funds during a gas spike).
    modifier reasonableBaseFee() {
        require(block.basefee < 200 gwei, "base fee too high");
        _;
    }
}
```

</template>

<template #csharp>

```csharp
using System.Numerics;
using Neo;
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Attributes;
using Neo.SmartContract.Framework.Native;

namespace R3E.Examples;

[DisplayName("FeeAware")]
public class FeeAware : SmartContract
{
    /// <summary>Network fee per byte from the policy contract.</summary>
    public static long FeePerByte() => Policy.GetFeePerByte();

    /// <summary>Estimate the network fee for a transaction of given size.</summary>
    public static long EstimateNetworkFee(uint txSize)
        => txSize * Policy.GetFeePerByte();

    /// <summary>Multiplier applied to per-op system fees.</summary>
    public static uint ExecFeeFactor() => Policy.GetExecFeeFactor();
}
```

</template>

</StandardEntry>

</StandardsMirror>