Code · 1 file

Sample Solidity File

Solidity, the language of Ethereum smart contracts. Our contract is for testing tools only and is not deployed anywhere. Every language sample implements the same small program so you can compare them side by side.

Solidity · 1.2 KB

Sample Solidity file

An idiomatic Solidity example — the same customer program (or, for hardware languages, a small counter design) we offer in every language.

CC0 · free for any use · Verified by an independent tool · Report a problem

CustomerRegistry.sol — first linesSolidity
// SPDX-License-Identifier: CC0-1.0
// Sample Solidity contract — samplefiles.com (for testing tools only; never deployed)
pragma solidity ^0.8.24;

contract CustomerRegistry {
    struct Customer {
        uint256 id;
        string name;
        uint256 balanceCents;
    }

    uint256 public constant VIP_THRESHOLD_CENTS = 1_000_000;
    address public immutable owner;
    Customer[] private customers;

    event CustomerAdded(uint256 indexed id, string name, uint256 balanceCents);

    error NotOwner();

    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner();
        _;
    }

    constructor() {

File details

Size
1.2 KB (1,265 bytes)
MIME type
text/plain
SHA-256
1a9dcc27852ca2b9d965835932c6861cb2dfb833575e6a0c7fd5940a971c0606
MD5
2fb16dc527de3dd54e1dbc1aa19edc4e

Download from the command line

curl -L -o CustomerRegistry.sol https://files.samplefiles.com/code/sol/CustomerRegistry.sol

Or check the download in your browser with the checksum calculator.