Counter

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "settings": {
    "evmVersion": "cancun",
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  },
  "sources": {
    "project/contracts/Counter.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

/**
 * @title Counter
 * @dev A simple counter contract that demonstrates basic Solidity functionality
 */
contract Counter {

    uint256 public count;

    event CountIncremented(
        uint256 _newCount
    );

    event CountDecremented(
        uint256 _newCount
    );

    event CountReset();

    /**
     * @dev Increment the counter by 1
     */
    function increment()
        public
    {
        count++;

        emit CountIncremented(
            count
        );
    }

    /**
     * @dev Decrement the counter by 1
     */
    function decrement()
        public
    {
        require(
            count > 0,
            "Counter cannot be negative!"
        );

        count--;

        emit CountDecremented(
            count
        );
    }

    /**
     * @dev Reset the counter to 0
     */
    function reset()
        public
    {
        count = 0;
        emit CountReset();
    }

    /**
     * @dev Get the current count value
     * @return The current count
     */
    function get()
        public
        view
        returns (uint256)
    {
        return count;
    }
}
"
    }
  }
}}

Tags:
Factory|addr:0xb12895f047dac019b1181f47340ee81a55bd5b75|verified:true|block:23578297|tx:0x02380a46180d9d2171bbd30c40ac0634a09408dc9965923b31979a5dc2ec778d|first_check:1760513066

Submitted on: 2025-10-15 09:24:27

Comments

Log in to comment.

No comments yet.