A simple smart contract that implements a basic counter functionality with the ability to increment, decrement, and reset its value.
The Counter Smart Contract is a minimal Solidity project demonstrating how to manage and update state variables on-chain.
It serves as a foundational example for developers exploring Flow EVM Testnet and learning how to deploy, interact with, and test Ethereum-compatible smart contracts.
- Built on: Flow EVM Testnet
- Contract Address:
0x580fbcAF0a8400A2C5C8aD1ea646F36A93D3A7fC
| Component | Description |
|---|---|
| Solidity | Smart contract programming language |
| Remix IDE / Hardhat | Development and deployment tools |
| Flow EVM Testnet | EVM-compatible blockchain network used for deployment |
| MetaMask | Wallet for managing testnet accounts and transactions |
| EtherScan (FlowScan) | Explorer for verifying deployed contracts |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Counter {
uint256 public count;
function getCount() public view returns (uint256) {
return count;
}
function increment() public {
count += 1;
}
function decrement() public {
require(count > 0, "Counter cannot go below zero");
count -= 1;
}
function reset() public {
count = 0;
}
}- Open Remix IDE.
- Create a file named
Counter.soland paste the code above. - Go to the Solidity Compiler tab and compile the contract (version
0.8.x). - In Deploy & Run Transactions, set the Environment to “Injected Provider - MetaMask”.
- Connect your MetaMask wallet to Flow EVM Testnet.
- Click Deploy and copy your deployed contract address (
0x580fbcAF0a8400A2C5C8aD1ea646F36A93D3A7fC).
count→ A state variable storing the counter value.increment()→ Increases the counter by one.decrement()→ Decreases the counter by one (checks ifcount > 0).reset()→ Resets the counter to zero.getCount()→ Returns the current count value.
- Add event emitters for
Incremented,Decremented, andReset. - Introduce access control (only owner can modify counter).
- Implement batch operations or multi-user counters.
- Build a simple frontend (React + Ethers.js) to interact with the contract visually.
- Store and visualize transaction history on-chain.
This project is licensed under the MIT License.