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
pragma solidity ^0.8.24pins the compiler family.string public mottois state; public writes the getter.external puremarks a function that touches nothing.
Keywords and builtins used here
contractexternalfunctionpublicreturnreturnsstringuint256
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.
Step 1 of 4 in Contracts, step 1 of 28 in Language basics.