PayTk

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "payTk.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.0;\r
\r
contract PayTk {\r
    // id => paid\r
    mapping(uint256 => bool) public paid;\r
\r
    // Owner address\r
    address public owner;\r
\r
    // Threshold: 0.001 ETH in wei\r
    uint256 private constant THRESHOLD_WEI = 1e15; // 0.001 * 1e18\r
\r
    // Events\r
    event Withdrawn(address indexed to, uint256 amount);\r
\r
    // Set deployer as owner\r
    constructor() {\r
        owner = msg.sender;\r
    }\r
\r
    // Modifier: only owner\r
    modifier onlyOwner() {\r
        require(msg.sender == owner, "Only owner");\r
        _;\r
    }\r
\r
    // When contract receives plain ETH transfers\r
    receive() external payable {\r
        _processPayment(msg.value);\r
    }\r
\r
    fallback() external payable {\r
        _processPayment(msg.value);\r
    }\r
\r
    // Internal: parse id from amount and mark paid if applicable\r
    function _processPayment(uint256 amountWei) internal {\r
        if (amountWei <= THRESHOLD_WEI) {\r
            return;\r
        }\r
\r
        uint256 remainder = amountWei - THRESHOLD_WEI;\r
        uint256 id = remainder;\r
\r
        // Strip trailing zeros (base 10) to get compact id\r
        while (id % 10 == 0 && id != 0) {\r
            id /= 10;\r
        }\r
\r
        if (id == 0) {\r
            return;\r
        }\r
\r
        paid[id] = true;\r
    }\r
\r
    // Query function: returns 1 if paid, else 0\r
    function checkPaid(uint256 id) external view returns (uint8) {\r
        return paid[id] ? 1 : 0;\r
    }\r
\r
    // Owner-only: withdraw all ETH to owner\r
    function withdrawAll() external onlyOwner {\r
        uint256 balance = address(this).balance;\r
        require(balance > 0, "No balance");\r
\r
        // Transfer all balance to owner\r
        (bool success, ) = owner.call{value: balance}("");\r
        require(success, "Transfer failed");\r
\r
        emit Withdrawn(owner, balance);\r
    }\r
}\r
"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  }
}}

Tags:
Factory|addr:0x82af62ad31d8ff078aa585dd5b4d0076f2233ab4|verified:true|block:23693756|tx:0xa48c1896dfde91305e1543a7d19b8af85e3e92e56fdd97df5c7b6e2a75905117|first_check:1761905963

Submitted on: 2025-10-31 11:19:23

Comments

Log in to comment.

No comments yet.