23 lines
470 B
Solidity
23 lines
470 B
Solidity
// SPDX-License-Identifier: UNLICENSED
|
|
pragma solidity ^0.8.20;
|
|
|
|
contract Counter {
|
|
uint256 public count;
|
|
|
|
// Funcion to get the current count
|
|
function get() public view returns (uint256) {
|
|
return count;
|
|
}
|
|
|
|
// Function to increment count by 1
|
|
function inc() public {
|
|
count += 1;
|
|
}
|
|
|
|
// Function to decrement count by 1
|
|
function dec() public {
|
|
// thid function will fail if count = 0
|
|
count -= 1;
|
|
}
|
|
}
|