skip to Main Content

I wrote a very simple smart contract for counting numbers similar to the SUM excel using solidity 8.0 and deployed it on the ethereum main chain as a test run. Below is the solidity code.

 

 pragma solidity ^0.8.0;

contract CountingNumbers {

// Declare a public variable to hold the count
uint public count;

// Constructor to initialize the count to 0
constructor() {
count = 0;
}

// Function to increment the count by 1
function incrementCount() public {
count++;
}

// Function to decrement the count by 1
function decrementCount() public {
count--;
}

// Function to reset the count to 0
function resetCount() public {
count = 0;
}

// Function to return the current count
function getCount() public view returns (uint) {
return count;
}
}

 

Back To Top