Schedule Live Demo
How Ethereum Smart Contracts work

How Ethereum Smart Contracts work

David Frenkel
David Frenkel
October 12, 2017
4 mins
Audio version
0:00
0:00
https://pub-a2de9b13a9824158a989545a362ccd03.r2.dev/how-ethereum-smart-contracts-work.mp3
Table of contents
User ratingUser ratingUser ratingUser ratingUser rating
Have a project
in mind?
Key Take Away Summary

Blockchain is a technology of decentralized data storage that provides a high-security level and enables data manipulation occurred within the certain rules. This confidence is ensured by the fact that data array is stored at…

Blockchain is a technology of decentralized data storage that provides a high security level and enables data manipulation within defined rules. That confidence comes from the fact that the data is replicated across every network participant, so it is not enough to alter it in one place.

Each subsequent piece of data, a so-called block, contains a hash of the previous block, which provides two guarantees:

  • An intermediate block cannot be substituted in a finished chain
  • A block cannot be changed without changing its hash, so any change breaks the chain's integrity

Ethereum builds on this foundation by adding a programmable execution layer, which is what makes smart contracts possible.

What Are Ethereum Smart Contracts?

Smart contracts are programs holding terms agreed by the parties and written directly into code. Every network participant can see the same data, the contract executes automatically when its conditions are met, and no intermediary is needed to enforce it. An Ethereum smart contract behaves like an ordinary contract, except that it is enforced technically rather than legally, so there is no notary or administrator whose authority both sides have to accept.

On-chain, smart contracts are responsible for data manipulation. Each contract holds its own state and exposes functions for changing that state. Because contracts are replicated across all nodes, so is their state. Every time a user calls a function that changes data, that call is executed and verified by the entire network, which is what produces distributed consensus about what the contract now says.

A contract defines both what data it stores and the set of functions that operate on it. Those functions are reached through an interface generated from the source code at compile time. Changes to state happen through transactions.

Each transaction has the following structure:

  • Sender
  • Recipient
  • Amount of ETH being sent
  • Gas limit, the maximum computation the sender will pay for
  • Maximum fee and priority fee per unit of gas
  • Arbitrary data, optional

How Gas and Fees Work

Executing a transaction costs ether (ETH) and takes effect once a block containing it is added to the chain. Contract code runs in the Ethereum Virtual Machine (EVM), and gas is the unit measuring how much computation that takes.

Two changes since Ethereum's early years are worth knowing, because a great deal of older material describes the original model.

First, The Merge in September 2022 moved Ethereum from proof of work to proof of stake. Blocks are now proposed and attested by validators who stake ETH, not produced by miners competing on hardware. Any guide describing mining, hash rate or GPU rigs is describing a network that no longer exists.

Second, EIP-1559 changed how fees are calculated. Each block has a base fee that adjusts with demand and is burned rather than paid to anyone. On top of that the sender sets a priority fee, which goes to the validator as an incentive to include the transaction. So raising your priority fee still raises your chance of fast inclusion, but the base fee is not a payment to a network participant.

Developing Smart Contracts

Bitcoin's Script language can express limited contract logic, but it is deliberately not Turing-complete, which rules out most of what people want smart contracts to do. Ethereum provides Turing-complete languages for this purpose, and ETH covers the cost of the computation.

To interact with the network you need a wallet. MetaMask is the most widely used, available as a browser extension and mobile app. Note that Mist, the Ethereum Foundation's original wallet and browser, was discontinued in 2019 and should not be used.

Decentralized applications, or dApps, are applications built on smart contracts: contract logic plus a user interface. A wallet is what connects a user's browser to the contract behind the interface.

Choosing a Test Network

You develop against a testnet, where ETH has no real value, before deploying to mainnet where it does. Testnets are deprecated and replaced periodically, and several widely referenced ones are now dead: Ropsten, Rinkeby, Kovan and Goerli are all retired, and Holesky was deprecated in September 2025.

As of 2026 the two current public testnets are:

  • Sepolia for smart contract and dApp testing, which is what most developers want
  • Hoodi for validator, staking and protocol upgrade testing

You obtain test ETH from a faucet rather than by mining it, since mining no longer exists on any Ethereum network. Faucets are listed on the Ethereum networks documentation.

For writing the contracts themselves, Solidity remains the most widely used language: statically typed, object-oriented, with syntax reminiscent of JavaScript and C++, and well supported by documentation and tooling. Development environments such as Remix, Hardhat and Foundry handle compilation, testing and deployment.

A Simple Smart Contract

Below is a minimal token contract in current Solidity. Anyone can send coins to anyone else without registering, but only the contract creator can mint new supply. Note that this uses modern syntax: older tutorials show a constructor named after the contract and events emitted without the emit keyword, both of which were removed in Solidity 0.5.0 and will not compile today.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Coin {
   // "public" makes these variables readable from outside
   address public minter;
   mapping(address => uint) public balances;

   // Events let light clients react to changes efficiently
   event Sent(address from, address to, uint amount);

   // Runs once, when the contract is deployed
   constructor() {
       minter = msg.sender;
   }

   function mint(address receiver, uint amount) public {
       require(msg.sender == minter, "Only minter can mint");
       balances[receiver] += amount;
   }

   function send(address receiver, uint amount) public {
       require(balances[msg.sender] >= amount, "Insufficient balance");
       balances[msg.sender] -= amount;
       balances[receiver] += amount;
       emit Sent(msg.sender, receiver, amount);
   }
}

Smart contracts are used across a wide range of cases, including voting, crowdfunding, financial and data transactions, digital wallets and decentralized coordination.

FAQs About Ethereum Smart Contracts

How do Ethereum smart contracts work?

An Ethereum smart contract is code deployed to the blockchain that holds its own state and exposes functions to change it. When someone calls one of those functions in a transaction, every node on the network executes the same code against the same state and agrees on the result. That shared execution is what removes the need for a trusted intermediary to enforce the agreement.

What is gas on Ethereum?

Gas is the unit measuring computational work on Ethereum. Every operation has a gas cost, and a transaction specifies both a gas limit and the fees it will pay per unit. Since EIP-1559 each block has a base fee that is burned, plus a priority fee that goes to the validator who includes the transaction.

Does Ethereum still use mining?

No. Ethereum moved from proof of work to proof of stake with The Merge in September 2022. Blocks are proposed and attested by validators who stake ETH rather than produced by miners running hardware. Any guide that describes mining ether, hash rate or GPU rigs predates that change.

Which Ethereum testnet should I use?

Sepolia is the current testnet for smart contract and dApp development, and Hoodi is used for validator and protocol testing. Ropsten, Rinkeby, Kovan and Goerli are all deprecated, and Holesky was deprecated in September 2025, so any tutorial pointing at those needs updating. Test ETH comes from a faucet.

What language are Ethereum smart contracts written in?

Solidity is the dominant language, statically typed with syntax similar to JavaScript and C++. Vyper is an alternative favouring simplicity and auditability. Current Solidity is on the 0.8 series, and contracts written for 0.4 will not compile without changes, since constructor syntax and event emission both changed in 0.5.0.

Can a smart contract be changed after deployment?

Not directly. Deployed contract code is immutable, which is the source of its guarantees and also its main risk, since a bug cannot simply be patched. Teams that need upgradeability use proxy patterns, where a stable address delegates to a replaceable implementation contract. That reintroduces a degree of central control, which is a deliberate trade-off rather than a free fix.

CloudGeometry can help

Whether you need help integrating a new blockchain service into your existing business infrastructure, or connecting a SaaS, PaaS or IaaS blockchain into your clients' technology stack, CloudGeometry has the expertise and resources to help. We have worked for many years with complex production systems, helping clients such as GE Digital connect new PaaS and IaaS solutions. We provide advisory, development and support services to integrate cloud and on-premises systems into one stable solution, and have delivered blockchain projects across industrial, marketing, fintech and SaaS companies.

‍

Data Science Team Lead
David Frankel is a highly accomplished Data Scientist with a passion for leading and mentoring teams. As the Data Science Team Lead at CloudGeometry, he leverages his expertise to drive innovation, foster collaboration, and deliver impactful insights that drive business growth.
Audio version
0:00
0:00
https://audio.cloudgeometry.com/how-ethereum-smart-contracts-work.mp3
Share this article
Monthly newsletter
No spam. Just the latest releases and tips, interesting articles, and exclusive interviews in your inbox every month.
Continue conversation

CloudGeometry

AI assistant