Ethereum essentials: How to transact on Ethereum, understand gas fees, and use blockchain explorers
A guide to mastering gas fees, etherscan transaction details, and the coinbase fee market black box.
Dear frontrunners,
In this issue, we’re going to go deep on Ethereum network fees, etherscan, and coinbase. Why? The first step to frontrunning isn’t making more money, it’s controlling the money you make. What I see across the web3 and crypto ecosystem is a large ‘hand-waive’ of how fees are calculated. An over-emphasis on how to perform a specific trade, while ignoring the mechanics of transaction fees and how it impacts profitability. If you ignore the details, you are doomed to fail. Master the details and control your destiny.
This guide is part 1 of 3 in the Frontrun Ethereum-essentials handbook:
Guide 1 - Gas fees, etherscan, and centralized exchanges - 👈👈 you are here
Guide 2 - layer 2 roll-ups and corresponding fees
Guide 3 - Lend, borrow and borrow again: an introduction to leverage
In this issue you will:
Understand how coinbase calculates its network fees
Learn why the coinbase (or any centralized exchange) network fee is different from the transaction fee calculated on etherscan
Review ethereum’s transaction fees (also called gas) and how it is calculated in etherscan
Understand the components that make up a transaction (gas) fee including:
base, max, tip, limit, txn savings, burnt
Learn what an externally owned account (EOA) is and how it differs from a contract account
Practice with real numbers - there is no magic hand waiving to mastery.
Tools you’ll need:
Access to etherscan - bookmark this now
A centralized exchange - like coinbase
A web wallet - like metamask
Spreadsheet software - like google spreadsheets
We will end with a call to action on how to perform this analysis with your own wallet.
Setting the stage:
We start with 2 wallets, one on a centralized exchange (coinbase) and another web wallet e.g. metamask.
There are too many blockchain data aggregators on the market, and I recommend staying away from all of them until you understand how to navigate etherscan. Your first 100 transactions should be analyzed using etherscan alone.
Using etherscan to view my web wallet, we are able to reconcile that the starting balance in my web wallet is 0.0930775409022667 eth. This aligns with table 1.
Moving ethereum off a centralized exchange, and the associated fees:
Although the process of sending eth from a centralized exchange (CEX) like coinbase is easy, the entire network fee calculation process is obscure and you don’t really know how much you’re paying in transaction fees (also called gas) vs the amount really charged to coinbase. Here’s a hint: they’re making a profit on every transaction.
Let’s dive into a transaction where I send $150 from my coinbase wallet to my web wallet, as depicted below.
You can see coinbase deducts its “network” fee prior to the transaction being completed. 0.09481549 eth ($150.00 USD) was sent to my web wallet and coinbase deducted 0.000294 eth (~$.47 USD) from the total available ETH balance leaving me with a balance of 0.08709183 eth or about ~$137.79. The coinbase ‘network fee’ is not a magic box, it ranges between between 1 and 60 basis points depending on the aggregate trade volume in a 30 day window.
In our example the fee is calculated as $.47/$150 = .31% or 31 basis points.
Again the 0.000294 eth (~$.47 USD) is not deducted from the 0.09481549 eth ($150.00 USD, it is a debit from the existing pool balance in addition to the 0.09481549 eth ($150.00 USD) being transferred.
We can actually prove this by reconciling the difference between the coinbase starting amount, the coinbase network fee and the amount sent, as outlined below.
This leads us to our next question: how much did I actually receive in my web wallet?
It’s important to really understand transaction fees associated with every action or you will get ripped off. Recall from image 1 that the starting web wallet balance (in eth) was 0.0930775409022667. After the coinbase deposit, the ending balance is 0.187893030902266 which means the amount deposited is 0.09481549. This aligns with the amount coinbase said it would send after accounting for network fees. Do this math, everytime.
(web wallet ending balance) - (web wallet starting balance) = .1878930309 - .0930775409 = .09481549 = amount sent by coinbase
Now that we know coinbase sent the amount it actually committed to sending, the next set of questions you should ask are related to fees…like “what are coinbase network fees?”, “how is it different from the gas fees on etherscan”..and most importantly…
What was I actually charged to complete this transaction?
This could be confusing because coinbase network fee is .000294 eth but the fee transaction fee calculated by etherscan is 0.00297431828938025 eth.
To be clear, we paid .000294 eth (outlined in image 2) to facilitate this transaction. The amount in etherscan is the transaction fee coinbase paid to execute a smart contract which sent eth to 14 different wallet addresses.
We can extrapolate this as follows:
The coinbase network fee is inclusive of gas fees and the coinbase maker/taker fee (the 31 basis points described in table 2)
The eth sent out of coinbase to my web wallet is sent via a contract account and not an ‘externally owned address’ (EOA)
Ethereum has two types of 'accounts’ - externally owned accounts and contract accounts:
EOAs are controlled by users. This control occurs often through software such as a web wallets. Externally owned accounts are simple accounts without any associated code or data storage. This type of Ethereum account is controlled by and cryptographically signed using a private key in the "real world."
A contract account is controlled by code executed by the Ethereum Virtual Machine. It is also referred to as a smart contract. Contract accounts have associated code and data storage, but not private keys. They "control themselves.” These accounts do so in the way determined by their smart contract code.
We know that both types of accounts can send, hold and receive eth tokens and interact with smart contracts. In our case, we see that a coinbase EOA wallet 0x7830c87C02e56AFf27FA8Ab1241711331FA86F43 is interacting with a coinbase contract account wallet 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43.
EOAs are human-controlled (these are our web wallets) and involve no coding to be operational. EOAs are controlled by private keys. Contract accounts behave in accordance with an on-chain call or message (interaction) from a human-controlled EOA or virtual entity (other contracts). This is based on language it is able to compute or understand. As contracts “control themselves” unlike EOAs, they get their ‘orders’ from coded protocols to know what to do.
In the context of this coinbase transaction, we see that an externally owned account 0x7830c87c02e56aff27fa8ab1241711331fa86f43 made a call to the coinbase smart contract at address 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 which has a balance > $91mm.
0x7830c87c02e56aff27fa8ab1241711331fa86f43 appears to be a coinbase wallet which holds at any given time around $150,000 USD of etheruem. My theory is that when money is deposited into coinbase it is stored in a cold-wallet, and when a request to withdraw is made, the coinbase algos route the transaction to a hot wallet like the one depicted below for execution to its smart contract.
..but when we look at the transaction hash associated with this specific deposit to my web wallet…
…we can see its composition of 14 transfers each with a gas limit of 90,000. The smart contract, or contract account, is executing a transfer 14 times, to 14 different wallets, of which mine is included.
…this gives us better insight into gas fees, and our original question, why is the coinbase network fee different from the transaction fee in etherscan: it is because a smart contract is being executed. The smart contract is sending 14 transactions to groups of wallets. Coinbase is charged a transaction fee by the blockchain for this transfer, which it then passes on to the sender. The amount paid by the sender is inclusive of the ‘taker fee’ coinbase charges, which is coinbase’s profit on the transaction. For the $150 I sent to my web wallet, coinbase charged me $.47.
This is important to understand because when you review the transaction details for CEX to web wallet transactions ( what you see when you click the ‘view block explorer’ link on coinbase) you are re-directed to the transaction detail associated with the coinbase EOA wallet making a call to the contract account) ..…
….you will see the gas price of the transaction was 0.000000017419140787 eth, or $4.72, yet we only paid $.47 cents (image 1).
To make sense of this, we need to understand how transaction fees (or gas fees) are calculated.
Conceptually we visualize the transaction fees dynamic as follows:
A transaction is performed
Gas is supplied based on the max you’re willing to spend
A tip can be added to prioritize your transaction in the validator pool
Smart contract code is executed
Any unused gas is sent back
base fee is burned (removed from the network)
Tip is given to the validator (the people staking ethereum in PoS world)
Gas is how much you pay the ethereum network to perform the transaction (in our example, sending eth from address 1 to address 2). It is required by the network as a mechanism to pay for security. Gas is a composition of:
Base fee - is the minimum amount a transaction pays to be included in a block.
It is also the amount of ethereum removed from the network
This is a catalyst to ethereum’s vision as ‘ultra-sound money’, eth the asset goes up as the total available pool goes down (from burning)
By requiring a fee on every transaction within the network, we can prevent bad actors from spamming.
Max priority aka tip - This is an incentive to validators (people who stake eth) to include our transaction in their validation block.
Max fee - The maximum amount a transaction will pay covering the base fee plus the max priority.
The transaction will always pay the base fee per gas block and also the priority fee, as long as the combined amount of the two fees do not exceed the transaction’s maximum, the ‘max fee’
Base fee, max priority, and max fee are measured in ‘gas’ or gwei’ which is 10x^-(9) Ethereum. Using our example below:
The base fee is 15.419 gwei
Coinbase is telling the blockchain that we will pay at most 34 gwei per gas
The amount of gwei we’re willing to pay the validator as a tip is 2
There is a 4th parameter called the ‘gas limit’:
Gas limits define the total amount of gas contract or EOA is authorized to consume. Putting the base fee, tip, max fee and limit together, the calculation of gas itself is defined as:
gas fee = Gas (limit) * (Base fee + tip)
Let’s break it down:
We can re-create the ‘transaction fee’, which is again just us sending $150USD of eth to a web wallet, as follows:
Alternatively, we can use the proposed gas price, multiple it by the amount of gas used, and convert it back to eth then USD as follows:
…but what about ‘txn savings’ fee’ and ‘burnt fee’?
What is ‘burnt’:
We know from the previous calculation that coinbase supplied 2,974,318.29 gwei or 0.00263281828938025 of eth worth of gas, as ‘base fee’, or around $4.17 USD.
This amount has been removed from network. When eth maxis talk about ‘ethereum as ultrasound money’, this is what they mean: the value of Ethereum goes up as the availability of the underlying asset decreases (from being burned).
What is ‘tipped’:
This leaves the priority fee aka the ‘tip’, which is provided to the validator (people who stake eth) for including our transaction in the block.
We’ve now isolated 2 variables in the gas construct:
The base fee is the deflationary amount removed from the network - $4.17
The tip is the amount paid to the validator - $.54
This is within one cent of the amount calculated on etherscan:
Txn savings is the amount refunded to the coinbase contract address. It represents an amount ‘saved’ .For this transaction, the contract was willing to pay up to :
0.002974318 eth (the transaction fee) + 0.002831181711 eth (txn savings)
but received a refund of 0.002831181711, the txn savings as unused gas.
this is step 5 of the ‘any unused gas is sent back’ depicted in image 11
Note that this 0.002831181711 eth is the amount returned to the coinbase wallet (not yours) after the base fee and priority tip have been paid. Recall that in each transaction, a ‘limit’ is placed which presents the aggregate eth a transaction is willing to pay to have the transaction included by the validator. Whatever is not consumed is returned.
In USD, this contract account:
Paid $4.17 as a base fee - which has been burned
Paid $.54 as a tip to the validator
Paid an additional ~$4.45 - $4.48 in fees to cover this transaction, which was refunded to the smart contract as a ‘txn savings’ or savings fee.
Wow that was alot.
This is why I slightly despise the current state of the fiat on-ramp and defi integration landscape. It is really easy to get lost in the numbers, which means you lose, every time. Remember our thesis: the first step to wealth is not making more money, it’s controlling the money you already have. Coinbase charged me $.47 to send $150. Does that sound cheap? Maybe. But consider the entire smart contract which is comprised of 14 transactions. If coinbase charged $.47 for all 14 transactions in the contract that represents $6.58 worth of fees. After paying the eth fees of $4.71 it leaves coinbase with around $1.87 of profit on that specific smart contract transaction alone.
A simpler version:
Once you’re off the centralized exchange, gas fees become easier. Here is a simple transaction of sending eth from one EOA wallet ( aka web wallet) to another EOA wallet.
To send 0.056424674734223223 of eth cost about .000147 eth or $.22 as follows:
Action for frontrunners:
Perform this action on two transactions of your own.
First, move eth from a centralized exchange of your choice to your web wallet. Review the transaction details, and calculate the transaction fee (base fee, tip) as well as the amount saved and burned.
Then, perform the same analysis using an EOA to EOA transaction: send eth from your web wallet to a hardware wallet or another wallet of your choice.
Assess the level of ease in calculating fees associated with task 2 vs task 1. Finally, reference the supporting documentation below on your journey to frontrunning. I’ve included my google spreadsheet in link 1.
You are the master of your destiny,
John Cook
September 2nd, 2022
San Francisco, CA
www.frontruncrypto.com
Supporting content: