typestar

The contract shape in Solidity

A contract is state plus functions, deployed at an address.

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

// A contract is state plus functions, deployed at an address.
contract OrchardSign {
    string public motto = "planted in common";
    uint256 public founded = 2026;

    function greet() external pure returns (string memory) {
        return "welcome to the orchard";
    }
}

How it works

  1. pragma solidity ^0.8.24 pins the compiler family.
  2. string public motto is state; public writes the getter.
  3. external pure marks a function that touches nothing.

Keywords and builtins used here

The run, in numbers

Lines
12
Characters to type
312
Tokens
38
Three-star pace
65 tpm

At the three-star pace of 65 tokens a minute, this run takes about 35 seconds.

Type this snippet

Step 1 of 4 in Contracts, step 1 of 28 in Language basics.

Next →