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": []
}
}}
Submitted on: 2025-10-31 11:16:04
Comments
Log in to comment.
No comments yet.