Receive and claim gas fees - Blast Developer Documentation (2024)

Existing L2s like Optimism and Arbitrum keep sequencer fees for themselves. Blast redirects sequencer fees to the dapps that induced them, allowing smart contract developers to have an additional source of revenue.

Contracts have two options for their Gas Mode:

  • Void (DEFAULT): base + priority fees go to the sequencer operator
  • Claimable: base + priority fees spent on this contract can be claimed by the contract, net of L1 fees

Smart contracts must interact with the Blast contract located at 0x4300000000000000000000000000000000000002 to change their Gas Mode.

The entity that is allowed to claim the gas fees spent on a contract is known as its “governor”. By default, the governor of a smart contract is the contract itself. The following example sets the Gas Mode to claimable and exposes a function to allow anybody to claim this contract’s gas fees.

interface IBlast { // Note: the full interface for IBlast can be found below function configureClaimableGas() external; function claimAllGas(address contractAddress, address recipient) external returns (uint256);}contract MyContract { IBlast public constant BLAST = IBlast(0x4300000000000000000000000000000000000002); constructor() { // This sets the Gas Mode for MyContract to claimable BLAST.configureClaimableGas(); } // Note: in production, you would likely want to restrict access to this function claimMyContractsGas() external { BLAST.claimAllGas(address(this), msg.sender); }}

Alternatively, you can specify an external governor. Once the governor is changed away from the contract itself, only the governor can set the gas mode, claim gas fees, and reconfigure the governor. In the following example, the governor could be an EOA belonging to the contract creator or another smart contract.

interface IBlast { // Note: the full interface for IBlast can be found below function configureClaimableGas() external; function configureGovernor(address governor) external;}contract MyContract { IBlast public constant BLAST = IBlast(0x4300000000000000000000000000000000000002); constructor(address governor) { BLAST.configureClaimableGas(); // This sets the contract's governor. This call must come last because after // the governor is set, this contract will lose the ability to configure itself. BLAST.configureGovernor(governor); }}

The governor now has the ability to claim the gas fees for this contract by sending a claimAllGas transaction to the Blast contract.

BLAST.claimAllGas(myContractAddress, recipient);

If you claim the gas fees for a contract immediately after the fees are earned, then 50% of the fees will be sent to the claim recipient and 50% will be sent to the sequencer operator. This is known as the “claim rate”, and it starts at 50% and increases to 100% over time. For mainnet, the parameters will be set to a 50% initial claim rate, 30 day maturity period, and 100% final claim rate.

You can think of each transaction’s gas fees as having their own claim rate that evolves independently. As an example, suppose you have 1 ETH in fees from January 1st and 1 ETH in fees from January 15th. When you claim 1 month later on February 1st, you’ll be able to claim 100% of your January 1st fees and 75% of your January 15th fees. Only half a month has passed since your January 15th fees, so the claim rate has increased halfway to its max potential, from 50% to 75%. Your average claim rate for the full 2 ETH of fees will be the weighted average of these two claim rates: 87.5%.

Thinking about the effective claim rate can get very confusing when you have many transactions over time, so for convenience, there are a handful of utility methods to make the claiming process easy.

claimAllGas

function claimAllGas(address contractAddress, address recipient) external returns (uint256);

To claim all of your contract’s gas fees, regardless of your resulting claim rate, you can call claimAllGas. Your resulting claim rate may be anywhere from 50% to 100% depending on how long it has been since the fees were earned.

claimMaxGas

function claimMaxGas(address contractAddress, address recipient) external returns (uint256);

If you’d like to maximize the amount of gas fees claimed and you’re okay waiting for the fees to mature, then you can use claimMaxGas to guarantee a 100% claim rate. By guaranteeing the claim rate, you may not be able to claim all of your gas fees though. Any remaining fees after calling this function will remain in the Blast Gas contract for you to claim later.

claimGasAtMinClaimRate

function claimGasAtMinClaimRate( address contractAddress, address recipient, uint256 minClaimRateBips) external returns (uint256);

This helper allows you to claim the maximum amount of gas fees while guaranteeing a specific claim rate. If you’re comfortable with an 80% claim rate, that translates to 8000 bips, so you would call claimGasAtMinClaimRate(contractAddress, recipient, 8000). Calling this function with a 100% min claim rate is the same as calling claimMaxGas.

The gas fees spent on Blast transactions can be broken up into three components: L1 data availability fees, L2 base fees, and L2 priority fees. The L1 data availability fee ensures that other nodes can trustlessly recover the state of the Blast L2, and it gets burned on the Ethereum L1. The L2 base and priority fees (“sequencer fees”) however either go to the sequencer operator or to the smart contracts that caused the gas to be spent.

Blast allocates sequencer fees to contracts based on the amount of gas that contract consumed in the transaction. This means that contracts that make nested calls to other smart contracts will get a proportional amount of the total gas fees spent on the transation, not the total amount.

In cases where delegatecall is used, gas fees are allocated to the contract that initiated the delegatecall and not the target contract where the implementation logic lives.

Example: Nested Calls

To further demonstrate how gas fees are allocated across nested calls, consider the following example:

  • Contract A (30,000 gas)
    • Contract B (50,000 gas)
    • Contract C (20,000 gas)
      • Contract A (30,000 gas)
      • Contract D (40,000 gas)

Suppose that only contracts A and D have set their Gas Mode to claimable. In this sample transaction, contract A would be allocated 30,000 + 30,000 = 60,000 gas worth of fees, and contract D would be allocated 40,000 gas worth of fees. The gas spent on contracts B and C, 50,000 + 20,000 = 70,000, would be allocated to the sequencer operator.

Example: Proxy / Delegatecall

Now, suppose that contract D is a proxy contract that forwards calls via delegatecall to an implementation contract, contract E.

  • Contract A (30,000 gas)
    • Contract B (50,000 gas)
    • Contract C (20,000 gas)
      • Contract A (30,000 gas)
      • (Proxy) Contract D (1,000 gas)
        • delegatecall Contract E (39,000 gas)

In this modified example, contract D will still be allocated 1,000 + 39,000 = 40,000 gas worth of fees because the execution of contract E’s code happens within the context of contract D.

Calculating Claimable ETH

To determine the maximum amount of ETH that contract A would be able to claim from the examples above, you need to multiply the gas amount by the gas price. If the gas price for this transaction was 15 gwei (10 gwei base + 5 gwei priority), then the ETH amount contract A would be able to claim a maxiumum of 60,000 gas * 15 gwei/gas = 0.0009 ETH.

This section contains low level details on how the Blast Gas contract works. You don’t need to read or understand this section to configure your contracts or claim your gas, but if you’re interested in a optimizing your integration, or just a bit curious, read on.

The Blast Gas contract keeps track of the integral of your contract’s unclaimed fees over time. If you had 1 ETH of unclaimed fees for 1 day, the resulting integral would be 1 ether-day. If you instead had 2 ETH of unclaimed fees for 1 week, then the integral would be 14 ether-days.

To make this integration process clear, let’s build on top of this second scenario. If you suddenly accumulated 1 additional ETH of fees, your contract’s unclaimed fee balance would be 3 ETH, but the integral would still be 14 ether-days. If you waited 1 more day, then the integral would be 17 ether-days. The Blast Gas contract uses this integral to determine the effective maturity of your unclaimed fee balance.

Blast Gas Claim Parameters

There are five parameters that determine how your contract’s accumulated ether-days relates to your claim rate:

  • zeroClaimRate: your claim rate immediately after earning gas fees
  • baseGasSeconds: the number of seconds your gas fees need to mature to receive the baseClaimRate
  • ceilGasSeconds: the number of seconds your gas fees need to mature to receive the ceilClaimRate

Represented visually, this looks like:

Receive and claim gas fees - Blast Developer Documentation (1)

The intended mainnet parameters look like this:

Receive and claim gas fees - Blast Developer Documentation (2)

Custom Gas Fee Claims

The following function is the lowest level claim helper. It allows you to specify exactly how much ETH you’d like to claim and how many ether-seconds you’d like to use to contribute to your claim rate.

function claimGas( address contractAddress, address recipient, uint256 etherToClaim, uint256 etherSecondsToConsume) external returns (uint256);

Claiming 1 ETH at the ceilClaimRate requires ceilGasSeconds ether-seconds. Providing fewer ceilGasSeconds than this would result in an effective claim rate less than the ceilClaimRate, based on the zeroClaimRate and baseClaimRate parameters.

In the interface below, when you see a function like configureX with corresponding configureXOnBehalf version, the difference is that configureX configures the caller and configureXOnBehalf configures the contract corresponding to the contractAddress parameter.

enum YieldMode { AUTOMATIC, VOID, CLAIMABLE}enum GasMode { VOID, CLAIMABLE}interface IBlast { // configure function configureContract(address contractAddress, YieldMode _yield, GasMode gasMode, address governor) external; function configure(YieldMode _yield, GasMode gasMode, address governor) external; // base configuration options function configureClaimableYield() external; function configureClaimableYieldOnBehalf(address contractAddress) external; function configureAutomaticYield() external; function configureAutomaticYieldOnBehalf(address contractAddress) external; function configureVoidYield() external; function configureVoidYieldOnBehalf(address contractAddress) external; function configureClaimableGas() external; function configureClaimableGasOnBehalf(address contractAddress) external; function configureVoidGas() external; function configureVoidGasOnBehalf(address contractAddress) external; function configureGovernor(address _governor) external; function configureGovernorOnBehalf(address _newGovernor, address contractAddress) external; // claim yield function claimYield(address contractAddress, address recipientOfYield, uint256 amount) external returns (uint256); function claimAllYield(address contractAddress, address recipientOfYield) external returns (uint256); // claim gas function claimAllGas(address contractAddress, address recipientOfGas) external returns (uint256); function claimGasAtMinClaimRate(address contractAddress, address recipientOfGas, uint256 minClaimRateBips) external returns (uint256); function claimMaxGas(address contractAddress, address recipientOfGas) external returns (uint256); function claimGas(address contractAddress, address recipientOfGas, uint256 gasToClaim, uint256 gasSecondsToConsume) external returns (uint256); // read functions function readClaimableYield(address contractAddress) external view returns (uint256); function readYieldConfiguration(address contractAddress) external view returns (uint8); function readGasParams(address contractAddress) external view returns (uint256 etherSeconds, uint256 etherBalance, uint256 lastUpdated, GasMode);}
Receive and claim gas fees - Blast Developer Documentation (2024)

FAQs

Receive and claim gas fees - Blast Developer Documentation? ›

Claiming Gas Fees. If you claim the gas fees for a contract immediately after the fees are earned, then 50% of the fees will be sent to the claim recipient and 50% will be sent to the sequencer operator. This is known as the “claim rate”, and it starts at 50% and increases to 100% over time.

Who collects gas fees? ›

Understanding Gas Fees

The concept of gas was introduced as a form of remuneration for validators who maintain and secure the Ethereum blockchain. Validators, who verify and process transactions on the network, receive these fees.

Are gas fees taxable events? ›

Taxes on gas fees:

In some cases, gas fees can offset your tax bill. Gas fees incurred during a sale, swap, or other taxable event can be added to your cost basis. A higher cost basis means lower capital gains. Gas fees incurred during self-transfers cannot be added to your cost basis.

How to earn gas fees? ›

Participants in the Ethereum network can voluntarily operate the blockchain to earn gas fees, provided that they stake—that is, agree not to trade or sell—their ETH. Gas fees on the Ethereum network are determined by three variables: Complexity. Specifically, the amount of gas required to process a transaction.

Who pays gas fees buyer or seller? ›

The buyers pay fees when purchasing fixed-price items, while sellers pay the gas fee when accepting offers.

Who decides gas fees? ›

Fees are determined by the amount of network traffic, the supply of validators, and the demand for transaction verification.

Can I write off gas fees? ›

There are certain instances where you can use your gas receipts for taxes. These instances are if you are a business owner or self-employed and use your vehicle for business. These individuals can deduct car expenses from their tax returns.

How do I report gas expenses on my taxes? ›

You can calculate your driving deduction by adding up your actual expenses or by multiplying the miles you drive by the IRS's standard mileage rate. The per-mile rate for 2023 is 65.5 cents per mile. The rate increases to 67 cents per mile for 2024.

What does gas fee include? ›

A gas fee is the amount of Ether (ETH) required for an Ethereum blockchain network user to conduct a transaction on the network. Gas fees are used to compensate Ethereum miners for their work in verifying transactions and securing the network.

What is the difference between transaction fee and gas fee? ›

A transaction fee is the amount you pay when you do something on a blockchain network, like sending money. The fee is usually paid using the network's own cryptocurrency, such as Ether (ETH) for Ethereum. The formula for calculating transaction fees is: Transaction Fee = Gas Units Used * Price per Gas Unit.

Who benefits from gas fees? ›

The miner who solves the problem fastest gains the authority to validate Ethereum transactions. These validators are eligible to receive a transaction fee termed gas fees. For Ethereum, the gas fees are calculated using several gas fee calculators.

How is the gas fee calculated? ›

Gas fees are calculated by multiplying the gas price by the gas limit. ‌So, if the gas limit is 20,000 and the price per unit is 200 gwei, the fee would be 20,000 * 200 = 4,000,000 gwei or 0.004 ETH. You can also add a tip if you want validators to prioritize your transaction.

Who actually controls gas prices? ›

Petroleum prices are determined by market forces of supply and demand, not individual companies, and the price of crude oil is the primary determinant of the price we pay at the pump.

How do I get rid of gas fees? ›

7 Tips To Avoid Ethereum Gas Fees
  1. Optimize the transaction timing. ...
  2. Take advantage of rebate offers. ...
  3. Choose transaction type carefully. ...
  4. Monitor network congestion to avoid delays. ...
  5. Benefit from gas tokens. ...
  6. Calculate payable gas fees beforehand. ...
  7. Switch to Ethereum 2.0.
Jun 7, 2024

Is the government responsible for gas prices? ›

It's that they have very little control over it. Yes, policies and legislation can certainly play a role, but gas prices are largely dictated by oil prices, and oil prices are dependent upon supply and demand. Presidential control is not as simple as what those posts suggest on social media.

Who charges the most for gas? ›

Western and Pacific states face the most costly gas in the nation, as the five states with the highest prices are California, Hawaii ($4.79), Washington ($4.57), Oregon ($4.33) and Nevada ($4.32).

Top Articles
Peer to Peer Network - Student - ISEA
What is the relative volume indicator and how do you use it when trading?
Tattoo Shops Lansing Il
Free Atm For Emerald Card Near Me
Crossed Eyes (Strabismus): Symptoms, Causes, and Diagnosis
Chalupp's Pizza Taos Menu
Zitobox 5000 Free Coins 2023
Okatee River Farms
Items/Tm/Hm cheats for Pokemon FireRed on GBA
Signs Of a Troubled TIPM
Operation Cleanup Schedule Fresno Ca
Byte Delta Dental
Gdp E124
Lancasterfire Live Incidents
ARK: Survival Evolved Valguero Map Guide: Resource Locations, Bosses, & Dinos
How do I get into solitude sewers Restoring Order? - Gamers Wiki
Vistatech Quadcopter Drone With Camera Reviews
Where to Find Scavs in Customs in Escape from Tarkov
Accident On May River Road Today
Stardew Expanded Wiki
Conan Exiles: Nahrung und Trinken finden und herstellen
Where Is The Nearest Popeyes
Where Is George The Pet Collector
Panic! At The Disco - Spotify Top Songs
Amazing deals for Abercrombie & Fitch Co. on Goodshop!
zom 100 mangadex - WebNovel
Company History - Horizon NJ Health
Lost Pizza Nutrition
Inbanithi Age
Kleinerer: in Sinntal | markt.de
Restaurants Near Calvary Cemetery
15 Downer Way, Crosswicks, NJ 08515 - MLS NJBL2072416 - Coldwell Banker
Ourhotwifes
Weekly Math Review Q4 3
Pitco Foods San Leandro
SOC 100 ONL Syllabus
Blackwolf Run Pro Shop
Sept Month Weather
2023 Fantasy Football Draft Guide: Rankings, cheat sheets and analysis
sacramento for sale by owner "boats" - craigslist
The Wait Odotus 2021 Watch Online Free
COVID-19/Coronavirus Assistance Programs | FindHelp.org
18006548818
Tattoo Shops In Ocean City Nj
Levi Ackerman Tattoo Ideas
Booknet.com Contract Marriage 2
فیلم گارد ساحلی زیرنویس فارسی بدون سانسور تاینی موویز
Mychart University Of Iowa Hospital
Citymd West 146Th Urgent Care - Nyc Photos
Pixel Gun 3D Unblocked Games
Leland Westerlund
Fahrpläne, Preise und Anbieter von Bookaway
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 6230

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.