Smart Contracts & Ethereum: The EVM, Gas & Decentralized Applications

Smart contracts represent one of the most significant innovations in financial technology since the advent of electronic trading. For finance professionals, understanding smart contracts is increasingly essential — they underpin decentralized finance (DeFi) protocols managing billions in assets, enable automated market making, and are reshaping how we think about contractual agreements. This guide explains what smart contracts are, how Ethereum works, and the economic mechanics of gas fees.

What Is a Smart Contract?

A smart contract is a program stored on a blockchain that automatically executes when predetermined conditions are met. Unlike traditional contracts that require lawyers, courts, or intermediaries to enforce, smart contracts are self-executing — the code itself is the enforcement mechanism.

Key Concept

Think of a smart contract like a vending machine: you insert money (meet the condition), and the machine automatically dispenses your product (executes the contract). No human intervention is needed, and the outcome is deterministic — the same input always produces the same output.

The term “smart contract” was coined by cryptographer Nick Szabo in 1994, years before Bitcoin existed. Szabo recognized that computer protocols could embed contractual clauses, making breach expensive or impossible. Ethereum, launched in 2015, was the first platform to make this vision practical at scale.

For finance professionals, the key applications include:

  • Escrow — funds held in a contract and released automatically when conditions are verified
  • Conditional payments — payouts triggered by external events (via oracles)
  • Automated settlement — trades that settle on-chain without traditional clearinghouses
  • Tokenized assets — securities, commodities, or real estate represented as blockchain tokens

The fundamental insight is that code is law — enforcement is automatic, not legal. This creates both opportunities (trustless transactions between strangers) and risks (bugs are also automatically enforced).

The Ethereum Virtual Machine (EVM)

The Ethereum Virtual Machine (EVM) is the runtime environment for smart contracts on Ethereum. Every node in the network runs the same EVM, executing the same code and reaching the same results — this is what makes the blockchain a “world computer.”

Key characteristics of the EVM:

Feature Description
Account-based model Unlike Bitcoin’s UTXO model, Ethereum tracks explicit account balances and transaction counters (nonces)
Contract accounts Smart contracts have their own addresses, can hold ETH, and store persistent data
State transitions Transactions trigger contract execution, changing the global state
Determinism Same input always produces same output — required for consensus
Isolation Contracts execute in a sandboxed environment with no access to external systems

The EVM executes bytecode compiled from higher-level languages. While technically any language could compile to EVM bytecode, Solidity is by far the most widely used. Solidity is a curly-bracket language influenced by C++, Python, and JavaScript — designed specifically for writing smart contracts with features like inheritance, libraries, and complex user-defined types.

Other languages include Vyper (Python-like, security-focused) and Yul (low-level, for optimization), but Solidity dominates the ecosystem.

Gas: Why It Exists and How It Works

Gas is Ethereum’s practical response to a fundamental computer science constraint: the Halting Problem. Alan Turing proved in 1936 that it’s mathematically impossible to determine in advance whether an arbitrary program will eventually stop or run forever. Gas doesn’t solve this problem — it bounds computation economically.

This creates a problem for a decentralized network. If someone deploys a contract with an infinite loop, every node would get stuck trying to execute it. Gas solves this by metering computation:

Gas Fee Formula
Gas Fee = Gas Units × Gas Price
Total cost equals computational work times price per unit

Every EVM operation costs a fixed amount of gas. Simple operations (addition, comparison) cost 3-5 gas. Storage writes cost 20,000 gas. A simple ETH transfer requires 21,000 gas; contract interactions require more. When a transaction runs out of gas before completing, all state changes revert — but the gas consumed is still paid.

Key Concept

Gas is NOT Ether (ETH). Gas is a unit measuring computational work. You pay for gas using ETH, at a price denominated in Gwei (1 Gwei = 0.000000001 ETH). The distinction matters: gas units are fixed per operation, but gas price fluctuates with network demand.

Gas Price, Gas Limit, and EIP-1559

Before August 2021, Ethereum used a simple auction: users bid gas prices, and miners included the highest-paying transactions. This led to unpredictable fees and frequent overpayment.

EIP-1559 (London upgrade, August 2021) fundamentally changed the fee model:

Component Description
Base Fee Algorithmically adjusted per block based on network congestion. This portion is burned (destroyed), reducing ETH supply.
Priority Tip Optional tip to validators to prioritize your transaction. Goes to the block proposer.
Max Fee User’s ceiling — you won’t pay more than this regardless of base fee.
Gas Limit Maximum gas units you’re willing to consume. Unused gas is refunded.

The burn mechanism means that during periods of high activity, more ETH may be burned than issued as block rewards — creating potential deflation. However, ETH is only net deflationary when burn exceeds issuance; this depends on network activity levels.

Gas Fee Calculation Example

An ETH transfer requires 21,000 gas units. At a base fee of 20 Gwei plus a 2 Gwei priority tip:

Gas Fee = 21,000 × (20 + 2) Gwei = 462,000 Gwei = 0.000462 ETH

At $2,500/ETH, this equals approximately $1.16.

Complex operations like token swaps (150,000+ gas) or NFT mints (100,000+ gas) cost proportionally more.

Decentralized Applications (dApps)

A decentralized application (dApp) combines a traditional frontend (web or mobile interface) with smart contract backends. The key difference from traditional apps: business logic executes on-chain, not on centralized servers.

Users interact with dApps through wallet software like MetaMask. The wallet holds private keys, signs transactions, and broadcasts them to the network. Every interaction that modifies blockchain state requires a transaction — and therefore gas.

Major categories of dApps include:

  • Decentralized exchanges (DEXs) — trade tokens with reduced reliance on traditional intermediaries
  • Lending protocols — borrow and lend crypto assets algorithmically
  • NFT marketplaces — buy, sell, and mint non-fungible tokens
  • Derivatives platforms — futures, options, and synthetic assets
  • DAOs — decentralized autonomous organizations with on-chain governance

Important caveat: while smart contract logic is decentralized, many dApps still rely on centralized components — frontends hosted on traditional servers, off-chain indexers, and price oracles. “Decentralized” exists on a spectrum.

DeFi Overview: Lending, DEXs, and Yield Farming

Decentralized Finance (DeFi) refers to financial services built on smart contracts, replicating traditional finance functions while reducing reliance on traditional intermediaries. The key metric is Total Value Locked (TVL) — the aggregate value of assets deposited in DeFi protocols.

DeFi Category How It Works Example Protocols
Lending Deposit crypto as collateral, borrow other assets. Interest rates set algorithmically based on supply/demand. Aave, Compound
DEXs Automated Market Makers (AMMs) use liquidity pools instead of order books. Prices set by mathematical formulas. Uniswap, SushiSwap, Curve
Yield Farming Deposit assets to earn protocol tokens as rewards. Often involves moving funds between protocols to maximize returns. Yearn, Convex

DeFi lending typically requires over-collateralization — borrowers must deposit more value than they borrow (often 150%+ collateral ratio). If collateral value drops below the threshold, the position is liquidated automatically by the protocol, with the liquidator receiving a bonus.

For liquidity providers in DEXs, a key risk is impermanent loss — the opportunity cost of providing liquidity versus simply holding the assets. When asset prices diverge significantly, LPs may end up with less value than if they had just held.

Pro Tip

DeFi does not eliminate risk — it changes the risk profile. Smart contract bugs, oracle manipulation, governance attacks, and impermanent loss are all DeFi-specific risks that don’t exist in traditional finance. Always audit protocol risks before depositing.

For stablecoins and their role in DeFi, see our article on Digital Payment Systems and CBDCs.

NFTs: Non-Fungible Tokens

Non-Fungible Tokens (NFTs) are blockchain tokens where each unit is unique and distinguishable. While ETH and most cryptocurrencies are fungible (one ETH equals any other ETH), NFTs have distinct identities and properties.

The technical standard is ERC-721, which defines how NFT contracts track ownership and enable transfers. Key characteristics:

  • Ownership on-chain — the blockchain records who owns each token
  • Metadata often off-chain — images and descriptions typically stored on IPFS or centralized servers, with the NFT containing a pointer
  • Transferable — ownership can be sold, gifted, or programmatically transferred
  • Composable — NFTs can interact with other smart contracts (gaming, DeFi collateral)

Common use cases include digital art, collectibles, gaming items, event tickets, and domain names. For finance professionals, NFTs represent digital property rights with verifiable provenance.

Important Clarification

Owning an NFT does NOT automatically grant copyright or intellectual property rights. The NFT is a record of ownership for the token itself — the underlying rights depend on the creator’s terms. Additionally, royalty enforcement on secondary sales is not universal; many marketplaces allow royalty-free trading.

Layer 2 Solutions: Rollups

Ethereum’s base layer (Layer 1) processes approximately 15-30 transactions per second. During high demand, this creates congestion and expensive gas fees. Layer 2 (L2) solutions address this by processing transactions off-chain while deriving substantial security from Ethereum.

The dominant L2 architecture is rollups, which execute transactions off-chain but post compressed transaction data or proofs to Ethereum:

Optimistic Rollups

  • Assume transactions are valid by default
  • Fraud proofs: anyone can challenge invalid transactions within a window (typically 7 days)
  • Examples: Optimism, Arbitrum, Base
  • Trade-off: withdrawal delays due to challenge period

ZK Rollups

  • Generate cryptographic validity proofs
  • Proofs mathematically guarantee correctness
  • Examples: zkSync, StarkNet, Polygon zkEVM
  • Trade-off: more complex, higher computation costs

L2s reduce fees by 10-100x while maintaining substantial security guarantees from Ethereum. However, trust assumptions vary between implementations — some L2s have centralized sequencers, upgradeable contracts, or other training wheels. “Inherits L1 security” is directionally correct but oversimplified.

For more on Ethereum’s consensus mechanism, see our article on Proof of Stake.

Smart Contracts vs Traditional Contracts

Smart contracts and traditional legal contracts serve similar purposes — defining agreements and enforcement mechanisms — but operate fundamentally differently.

Smart Contracts

  • Code-based: logic expressed in programming languages
  • Self-executing: runs automatically when conditions met
  • Often immutable once deployed (unless upgrade logic exists)
  • Transparent: code is public on Ethereum mainnet
  • Reduced reliance on intermediaries for execution
  • Deterministic outcomes: same inputs produce same outputs
  • Limited to on-chain assets and verifiable data

Traditional Contracts

  • Language-based: expressed in natural language
  • Require enforcement: courts, arbitration, or threats thereof
  • Amendable: parties can modify terms by mutual agreement
  • Often private: terms known only to parties involved
  • Require intermediaries: lawyers, courts, escrow agents
  • Subject to interpretation: ambiguity resolved by humans
  • Can govern any asset type or obligation

Neither is universally superior. Smart contracts excel at trustless transactions with verifiable on-chain conditions. Traditional contracts handle ambiguity, edge cases, and real-world enforcement better. Many real-world agreements use hybrid approaches — legal contracts referencing smart contract execution.

Limitations of Smart Contract Platforms

Despite their potential, smart contracts have significant limitations that finance professionals must understand:

Critical Limitation

Smart contracts are NOT automatically legally binding. They are code, not legal documents. Execution happens regardless of legality, intent, or error. Whether a smart contract constitutes a valid legal agreement depends on jurisdiction and whether traditional contract requirements (offer, acceptance, consideration) are met.

1. The Oracle Problem — Smart contracts cannot natively access off-chain data. To settle a contract based on stock prices, weather, or sports scores, you need an oracle — an external data feed. This reintroduces trust: you must trust the oracle provider, creating a potential single point of failure.

2. Immutability Risk — For truly immutable contracts, bugs cannot be patched after deployment. The only options are migration (deploying a new contract and convincing users to switch) or accepting the bug. Some contracts use upgradeable proxy patterns, but these reintroduce centralization and trust in admin keys. Major exploits like The DAO hack (2016, ~$60M) and various DeFi exploits demonstrate the risks of both approaches.

3. Scalability — Every full node must execute every transaction to validate the chain. This creates inherent throughput limits. Layer 2 solutions help but add complexity.

4. Gas Volatility — Transaction costs are unpredictable during network congestion. A transaction that cost $1 in calm markets might cost $50 during an NFT mint or market crash.

5. Complexity = Attack Surface — Ethereum’s expressiveness comes with security risks. More complex protocols have more potential vulnerabilities. Solidity’s design has produced recurring bug classes (reentrancy, integer overflow, access control).

Common Mistakes About Ethereum and Smart Contracts

Even sophisticated investors make these errors when first approaching smart contracts:

1. Assuming smart contracts are legally binding — They’re code, not law. Automatic execution does not equal legal enforceability. Some jurisdictions (Arizona, Tennessee) explicitly protect contracts from being denied effect solely for containing smart contract terms, but this doesn’t make every smart contract a valid legal agreement.

2. Equating immutability with security — Immutable code means bugs are also immutable. A contract that “can’t be changed” offers no protection if the original code was flawed. Security requires audits, formal verification, and time-tested deployment.

3. Believing DeFi eliminates all risk — DeFi changes the risk profile: it reduces certain risks (counterparty default, custodial theft) while introducing others (smart contract bugs, oracle manipulation, impermanent loss, governance attacks). Risk is transformed, not eliminated.

4. Confusing gas price with ETH price — Gas price (in Gwei) and ETH price (in USD) are independent. You can have cheap gas and expensive ETH, or expensive gas and cheap ETH. Your USD transaction cost depends on both.

5. Assuming all L2s are equally secure — Layer 2 implementations vary significantly in their trust assumptions. Some have centralized sequencers, upgradeable contracts, or limited fraud proof systems. “Rollup” doesn’t automatically mean “as secure as Ethereum.”

6. Thinking NFT ownership equals asset ownership — Owning an NFT is owning a token that points to something. The underlying asset (image, rights, physical item) may or may not be conveyed depending on the creator’s terms.

Frequently Asked Questions

A smart contract is a program stored on a blockchain that automatically executes when predetermined conditions are met. Think of it like a vending machine: insert money (meet the condition), receive product (automatic execution). No human intervention is required, and the outcome is deterministic. Smart contracts enable trustless transactions — two parties who don’t know or trust each other can transact because the code enforces the agreement.

Ethereum has limited block space — approximately 15-30 transactions per second on the base layer. The EIP-1559 mechanism adjusts the base fee based on how full each block is relative to a target size. Fees spike during market volatility, popular NFT mints, or DeFi events. Layer 2 solutions (Arbitrum, Optimism, zkSync) reduce fees by 10-100x by processing transactions off-chain while posting proofs to Ethereum.

Ethereum transitioned from proof-of-work to proof-of-stake on September 15, 2022 — an event called “The Merge.” Validators now stake 32 ETH as collateral instead of mining with energy-intensive hardware. This reduced Ethereum’s energy consumption by approximately 99.95%. Validators are randomly selected to propose blocks and earn rewards from priority tips and issuance, while the base fee is burned.

Yes. For immutable smart contracts, bugs cannot be patched after deployment. Even upgradeable contracts face risks — admin keys can be compromised or misused. Exploits have caused billions in losses, including The DAO hack (2016, ~$60M in ETH) and numerous DeFi protocol exploits. Security audits, formal verification, and bug bounties reduce but cannot eliminate risk. The mantra “code is law” means bugs are also law — if a vulnerability exists, it can be exploited.

ERC-20 defines fungible tokens — each unit is identical and interchangeable, like dollar bills or shares of stock. One USDC equals any other USDC. ERC-721 defines non-fungible tokens (NFTs) — each token is unique with distinct properties, like baseball cards or property deeds. The standards specify different interfaces for how contracts track ownership and enable transfers.

Not automatically — it depends on jurisdiction and contract formation. Smart contracts are code, not legal documents; they execute regardless of legality or intent. However, some jurisdictions explicitly recognize smart contracts: Arizona and Tennessee protect contracts from being denied effect solely for containing smart contract terms, and England and Wales Law Commission concluded that current law can support “smart legal contracts.” Whether a specific smart contract is enforceable depends on whether traditional contract requirements (offer, acceptance, consideration, capacity) are met.

Disclaimer

This article is for educational and informational purposes only and does not constitute investment, legal, or financial advice. Smart contract technology carries significant risks including code vulnerabilities, regulatory uncertainty, and potential total loss of funds. Gas fees, protocol mechanics, and legal interpretations may change. Always conduct your own research and consult qualified professionals before interacting with smart contracts or DeFi protocols.