Explain how smart contracts, gas fees and staking work on Ethereum.
Ether is related to bitcoin, but it is not a competing version of it. Ethereum was designed for a different purpose, so if you own ether, you hold a different kind of thing from bitcoin.
Take Darren, who already understands bitcoin. His friend Farah mentions that she owns ether, and Darren assumes it is a rival coin trying to do bitcoin's job. Farah has in fact staked her ether, locking it up to help run the network for a yield. She recently paid a S$15 fee to swap one token, a digital asset created on a blockchain, for another (an example figure). Both of those things only happen because Ethereum can do something the bitcoin network does not.
The bitcoin ledger is mostly a list of transfers: an amount, a sender and a receiver. Ethereum, which went live in 2015, keeps that kind of record as well, and it can also store small programs and run them. These are called smart contracts, a name that promises a little more than it delivers, because no lawyer or court has any part in them. A smart contract is code stored at an address, a public account number, on the blockchain. Whenever someone sends a transaction to that address, the code does precisely what it was written to do.
Contracts are put to several uses. One might keep tokens locked until certain conditions are met and then pay them out. Another might operate an exchange where people trade tokens directly with one another, with no company standing between them; Farah's swap went through one of these. A contract can also create a brand new token, or run lending between people at interest rates set by code. When you reach lesson 2.3, Tokens, DeFi and the questions to ask any of them, you'll find that most of the tokens there are smart contracts running on Ethereum or on blockchains built as copies of its design.
Each computer that keeps a copy of Ethereum has to run every one of these programs to confirm the outcome. That takes computing work, and someone has to pay for the work. Ethereum's own coin, ether, written ETH, exists mainly for this purpose inside the system: fees are paid in it.
The network prices each operation a transaction asks for in units of gas. Under the protocol's rules, sending ether from one address to another with nothing else involved takes 21,000 gas. A swap through an exchange contract needs many times that amount, since the contract runs far more code. Most of Farah's S$15 comes from this: she asked the network to execute an exchange contract, which costs far more gas than moving ether between two addresses.
Each unit of gas has a price, quoted in gwei, and one gwei is a billionth of one ether. The price you pay moves with demand. Busy periods push it up and quiet periods bring it down, and when a crowd of users all try to transact at the same moment, your fee on Ethereum can jump sharply.
The rule is fee = gas used x gas price. To apply it, start with how much gas your transaction consumes, which is 21,000 for a plain ether transfer and many times more for a contract interaction such as a swap. Next, look up the gas price in gwei, which depends on how busy the network is at the time. Multiply the two to get the fee in gwei, then convert that to ETH, remembering that each gwei is one billionth of an ether.
Suppose gas is priced at 20 gwei, a made-up figure. A plain transfer then comes to 21,000 x 20 = 420,000 gwei, or 0.00042 ETH. A contract interaction that consumes 150,000 gas at the same 20 gwei comes to 3,000,000 gwei, which is 0.003 ETH and roughly seven times more than the plain transfer.
When it began, Ethereum secured its ledger with proof of work, the same mining method bitcoin uses, which you met in lesson 1.2, Why proof of work makes the ledger hard to rewrite. An upgrade in September 2022, known as the Merge, moved Ethereum off proof of work, and mining on Ethereum ended. According to the Ethereum Foundation, the network's energy use dropped by a very large amount after the Merge.
In its place came proof of stake. Rather than spending electricity on a guessing puzzle, validators put up ether as a deposit and lock it away. The protocol chooses validators to propose new blocks and to check them, and pays them in ether for doing this honestly. If a validator breaks the rules, for instance by signing two versions of a block that conflict with each other, the protocol can destroy part of that deposit. This penalty is called slashing, and the validator may also be removed from the validator set.
The security idea carries over from mining, with a different cost attached. Under proof of work, an attacker has to spend more on hardware and power than the honest miners do. Under proof of stake, an attacker needs to control a large share of all the ether that is staked, and puts that ether at risk of being lost.
Farah's yield is a staking reward, a payment for helping keep the network secure. If she staked through an exchange or another service, she gave her ether to that company so it could stake on her behalf, and she now relies on that company as well as on the protocol. MAS does not let licensed exchanges stake retail customers' tokens, a rule module 3 returns to.
Darren has two separate things to judge. The first is ether's price. It rests on demand for the network and for ether itself, with no earnings behind it, much as bitcoin's price does in lesson 1.3.
The second is the risk carried by any contracts he might use on Ethereum. That risk sits on top of the price risk, and no movement in ether's price fixes it. A contract carries out its code literally, and sometimes the code permits things its authors never intended. Anyone who finds such a bug can use it to take funds, which is called an exploit. Because a confirmed transaction cannot be undone, you often have no one to appeal to after an exploit.
Over the years, bugs and exploits have caused large losses, in some cases from contracts holding the savings of many users. Some projects hire outside firms to review their code before launch, which reduces the risk without removing it, and many contracts are never reviewed by anyone.
When a platform tells you your money is held in a smart contract, the questions to put to it are:
who wrote the code who checked it whether anyone can change it after you deposit
You can see all of this in practice by opening a real transaction on a block explorer, a public website that shows every Ethereum transaction. On the explorer, each transaction page shows you the gas used, the gas price, the total fee in ether, and whether the transaction went to an ordinary address or to a contract.
Look up one Ethereum transaction on a public block explorer, noting its gas fee and any contract it used. Then write one sentence each on what a smart contract does, how the fee was worked out, and how staking secures Ethereum.
Junxiong-WFG Organisation is an authorised representative of AIA Financial Advisers Private Limited (Reg. No. 201715016G).