Deciphr Academy
Track 1 · Module 4 · Lesson 6 of 6 · 7 min read

How do you read a simple Solidity smart contract?

Short answer

Solidity is a high-level language for writing smart contracts that run on the EVM.1 Its documentation opens with a tiny contract that stores one number, which anyone can set and anyone can read.2

Anyoneany accountSimpleStoragestoredDatastarts at 0set(x) saves xget() reads it backset changes the number. get only reads it.
Fig. 6. SimpleStorage holds one number. set changes it; get only reads it.

Solidity in brief

Solidity is a high-level language for writing smart contracts.1 It uses curly brackets, and it is built to run on the EVM.1 It borrows ideas from C++, Python and JavaScript.1

The contract

Below is the first example in Solidity's own documentation. It is called SimpleStorage.2

The contract
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.9.0;

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

Line by line

Line 1: the licence. The first line says the code is shared under the GPL version 3.0 licence.2 Licence labels that machines can read matter when publishing code is the normal thing to do.2

Line 2: the version. A pragma is an instruction to the compiler. This one says the code is for Solidity 0.4.16 or newer, but older than 0.9.0.2 That stops a future version of the compiler, which might make the code behave differently, from compiling it.2

Line 4: the contract. contract SimpleStorage starts the contract. In Solidity, a contract is code (its functions) and data (its state) at one address.2

Line 5: the stored number. uint storedData; creates a state variable called storedData.2 uint means an "unsigned integer" of 256 bits: a whole number that starts at zero and cannot go below it.2,3 Think of it as one box in a database.2 State variables are kept permanently on the blockchain.4 Until someone sets it, it holds 0, the default value for a uint.5

Lines 7 to 9: set. The set function takes a number, called x, and saves it in storedData.2 It is marked public, so it is part of the contract's interface and can be called from outside.6 People run a contract's functions by sending transactions, and transactions cost gas.7,8

Lines 11 to 13: get. The get function hands back the stored number.2 It is marked view, which is a promise not to change the contract's state.6 Functions like this are often called "getters".4

What it lets people do

This contract lets anyone store one number that anyone in the world can read.2 Anyone can call set again and overwrite the number. The old number is still kept in the blockchain's history.2

To stop strangers changing a value, a contract needs access rules.2 ethereum.org's vending machine example uses a require line, so that only the owner can refill the machine.7 A require check runs at the start of a function, and the function only goes ahead if the conditions are met.9

Our viewYou don't need to be a programmer to read the outline of a contract. Look for who can call each function, what each one changes, and whether anything stops a stranger.
Sources
  1. Solidity documentation (home page). Solidity documentation, The Solidity Authors.
  2. Introduction to Smart Contracts (the SimpleStorage example and the EVM overview). Solidity documentation, The Solidity Authors.
  3. Types: integers. Solidity documentation, The Solidity Authors.
  4. Anatomy of smart contracts. ethereum.org developer docs, page updated 12 June 2026.
  5. Expressions and control structures: scoping and declarations. Solidity documentation, The Solidity Authors.
  6. Contracts: function visibility and view functions. Solidity documentation, The Solidity Authors.
  7. Introduction to smart contracts. ethereum.org developer docs, page updated 25 February 2026.
  8. Gas and fees. ethereum.org developer docs, page updated 24 June 2026.
  9. Smart contract security. ethereum.org developer docs, page updated 7 October 2026.

General education built from the publicly available sources listed above. Not financial, legal, tax or investment advice. Naming a company, project or regulator is not an endorsement either way. Last checked 2026-10-22. Terms and disclaimer.