Your first smart contract with Solidity

Without installing anything, write a small timestamping contract in your browser, test it, and see how it is deployed on SUR.

3 min read Last reviewed 2026/11/26

What we will build

A simple "timestamp register": it records any text once, and later anyone can see when that text was recorded. The same idea, with files instead of text, is the basis of document timestamping services. All you need for this guide is a browser.

Solidity at a glance

Solidity is the most common language for EVM contracts and looks a bit like JavaScript. A few ideas you will see in the code below:

  • contract: like a class; keeps data and functions together.
  • mapping: a key-to-value table stored on chain.
  • event: a message recorded in the transaction log that outside programs can follow.
  • require: if the condition fails, the whole transaction reverts and nothing is recorded.
  • msg.sender and block.timestamp: the sender of the transaction and the block time.

The contract

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

contract Notary {
    mapping(bytes32 => uint256) public registeredAt;

    event Registered(bytes32 indexed hash, address indexed by, uint256 at);

    function register(string calldata text) external {
        bytes32 h = keccak256(bytes(text));
        require(registeredAt[h] == 0, "already registered");
        registeredAt[h] = block.timestamp;
        emit Registered(h, msg.sender, block.timestamp);
    }

    function check(string calldata text) external view returns (uint256) {
        return registeredAt[keccak256(bytes(text))];
    }
}

The contract does not store the text itself; it keeps only its fingerprint (hash) with the time it was recorded.

Step by step in Remix

  1. Open Remix in your browser, create a new file called Notary.sol and paste the code above.
  2. Go to the Solidity compiler tab. Pick compiler 0.8.24 or later and, under Advanced configurations, set the EVM version to cancun (the version SUR runs). Then press Compile.
  3. Go to the Deploy & run transactions tab. Set the environment to Remix VM (Cancun): a test blockchain inside your browser with accounts full of test coins. Press Deploy.
  4. Under the deployed contract, type a text into register (for example "hello SUR", with quotes) and run it. Now call check with the same text: it returns the time it was recorded. Call register with the same text again: the transaction reverts with already registered.

The text you send to register is visible to everyone in the transaction data, even though the contract keeps only the hash. For a real document, compute the file's hash off chain and send only the hash.

Deploying on SUR

The SUR main network has not launched yet. Until then, test the contract in Remix VM or on a local node.

After launch, deploying on SUR takes only three extra steps:

  1. Add the SUR network to MetaMask (the network page, one button).
  2. Have some SUREN for fees; deploying this contract and a few calls cost a few tens of SUREN (buy SUREN from licensed exchanges).
  3. In Remix, set the environment to Injected Provider - MetaMask and deploy again. Once recorded, find the contract in the SUR explorer and verify its source code there so anyone can read it.

Next steps

  • For a real project use Hardhat or Foundry: developer quickstart.
  • For tokens and common patterns use audited libraries such as OpenZeppelin, and get a security audit before deploying any contract that holds money.
  • The official Solidity documentation is the best place to go deeper.

Last reviewed: 2026/11/26

All guides