A simple Solidity smart contract that lets users increment or decrement an on-chain counter. Great for learning state variables and basic blockchain interaction.
This is a simple smart contract written in Solidity that acts as an on-chain counter. It allows anyone to increment or decrement a counter value stored on the blockchain.
✅ Store a counter as a state variable
➕ Increment the counter
➖ Decrement the counter
🌐 Read the counter value on-chain (public state variable)
Contract Name: `C# Counter Smart Contract
This is a simple smart contract written in Solidity that acts as an on-chain counter. It allows anyone to increment or decrement a counter value stored on the blockchain.
✅ Store a counter as a state variable
➕ Increment the counter
➖ Decrement the counter
🌐 Read the counter value on-chain (public state variable)
Contract Name: Counter
Network: (Replace with the network you deployed to, e.g., Ethereum, Sepolia, etc.)
Deployed Address: 0x922501607d4ec10961b5C864C6f510259Fed31fe
counter() → intReturns the current value of the counter. Automatically generated getter function for the public variable.
increment()Increments the counter value by 1.
decrement()Decrements the counter value by 1.
You can interact with the contract using:
Remix IDE – Connect MetaMask, load the contract, and call the functions.
Etherscan – If verified, interact directly using the "Write Contract" and "Read Contract" tabs.
Frontend/Web3 – Use Web3.js or Ethers.js to call increment() or decrement() from a frontend.
Open Remix IDE
Load the contract code
Compile with Solidity ^0.8.0
Deploy or interact with the existing deployed contract
Call increment() or decrement() functions
This project is licensed under the MIT License. ounter`
Network: (Replace with the network you deployed to, e.g., Ethereum, Sepolia, etc.)
Deployed Address: 0x922501607d4ec10961b5C864C6f510259Fed31fe
counter() → intReturns the current value of the counter. Automatically generated getter function for the public variable.
increment()Increments the counter value by 1.
decrement()Decrements the counter value by 1.
You can interact with the contract using:
Remix IDE – Connect MetaMask, load the contract, and call the functions.
Etherscan – If verified, interact directly using the "Write Contract" and "Read Contract" tabs.
Frontend/Web3 – Use Web3.js or Ethers.js to call increment() or decrement() from a frontend.
Open Remix IDE
Load the contract code
Compile with Solidity ^0.8.0
Deploy or interact with the existing deployed contract
Call increment() or decrement() functions
This project is licensed under the MIT License.
40
NA