Counter
A simple counter contract demonstrating basic state management, events, custom errors, and owner-only access control.
beginner
Open in Playground →
counter/counter.sol
// Source file not found Overview
The counter example is the simplest SolScript contract. It demonstrates:
- State variables:
uint256for the count andaddressfor the owner - Events: Emitted on increment, decrement, and reset
- Custom errors:
Underflow()andUnauthorized() - Modifiers:
onlyOwnerrestricts reset to the deployer - Constructor: Sets the initial owner
This is a great starting point for understanding how SolScript maps Solidity concepts to Solana programs.