@cfxdevkit/compiler / COUNTER_SOURCE
Variable: COUNTER_SOURCE
constCOUNTER_SOURCE: ”// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\n/**\n * @title Counter\n * @notice A simple counter contract — great first contract to understand\n * state variables, modifiers, events, and ownership.\n */\ncontract Counter {\n uint256 public count;\n address public owner;\n uint256 public step;\n\n event CountChanged(uint256 indexed previous, uint256 indexed current, address indexed by);\n event StepChanged(uint256 newStep);\n\n modifier onlyOwner() {\n require(msg.sender == owner, “Counter: not the owner”);\n _;\n }\n\n constructor() {\n owner = msg.sender;\n step = 1;\n }\n\n /// @notice Increment the counter by `step`.\n function increment() external {\n uint256 prev = count;\n count += step;\n emit CountChanged(prev, count, msg.sender);\n }\n\n /// @notice Decrement the counter by `step` (reverts on underflow).\n function decrement() external {\n require(count >= step, “Counter: underflow”);\n uint256 prev = count;\n count -= step;\n emit CountChanged(prev, count, msg.sender);\n }\n\n /// @notice Reset the counter to zero (owner only).\n function reset() external onlyOwner {\n uint256 prev = count;\n count = 0;\n emit CountChanged(prev, 0, msg.sender);\n }\n\n /// @notice Change the increment/decrement step (owner only).\n function setStep(uint256 newStep) external onlyOwner {\n require(newStep > 0, “Counter: step must be > 0”);\n step = newStep;\n emit StepChanged(newStep);\n }\n}”
Defined in: templates/counter.ts:12