Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/TaxDistributor.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\r
pragma solidity ^0.8.13;\r
\r
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";\r
\r
contract TaxDistribution is ReentrancyGuard {\r
// Hardcoded wallet addresses for claiming\r
address public constant WALLET_A = 0xb5Bd14bD1653988eF4781938584aa42df73c8A2B; // 10%\r
address public constant WALLET_B = 0x5d3E5Db8977AE681Ea52AAC538d1bE53b077EE67; // 90%\r
\r
// Distribution percentages (in basis points for precision)\r
uint256 public constant WALLET_A_PERCENTAGE = 1000; // 10% = 1000 basis points\r
uint256 public constant WALLET_B_PERCENTAGE = 9000; // 90% = 9000 basis points\r
uint256 public constant BASIS_POINTS = 10000; // 100% = 10000 basis points\r
\r
// Tracking variables\r
uint256 public totalAccumulated;\r
uint256 public totalClaimedA;\r
uint256 public totalClaimedB;\r
\r
// Claimable amounts for each wallet\r
mapping(address => uint256) public claimableAmount;\r
\r
// Events\r
event ETHReceived(uint256 amount, uint256 totalAccumulated);\r
event ETHClaimed(address indexed wallet, uint256 amount, uint256 totalClaimed);\r
event DistributionUpdated(uint256 amountA, uint256 amountB, uint256 totalAccumulated);\r
\r
constructor() {\r
// Contract is ready to receive ETH\r
}\r
\r
// Receive ETH and distribute to claimable amounts\r
receive() external payable {\r
_distributeETH(msg.value);\r
}\r
\r
// Fallback function to handle ETH sent with data\r
fallback() external payable {\r
_distributeETH(msg.value);\r
}\r
\r
// Internal function to distribute received ETH\r
function _distributeETH(uint256 amount) internal {\r
require(amount > 0, "No ETH to distribute");\r
\r
totalAccumulated += amount;\r
\r
// Calculate distribution amounts\r
uint256 amountA = (amount * WALLET_A_PERCENTAGE) / BASIS_POINTS;\r
uint256 amountB = (amount * WALLET_B_PERCENTAGE) / BASIS_POINTS;\r
\r
// Add to claimable amounts\r
claimableAmount[WALLET_A] += amountA;\r
claimableAmount[WALLET_B] += amountB;\r
\r
emit ETHReceived(amount, totalAccumulated);\r
emit DistributionUpdated(claimableAmount[WALLET_A], claimableAmount[WALLET_B], totalAccumulated);\r
}\r
\r
// Function for WALLET_A to claim their 10%\r
function claimA() external nonReentrant {\r
require(msg.sender == WALLET_A, "Only WALLET_A can claim");\r
\r
uint256 amount = claimableAmount[WALLET_A];\r
require(amount > 0, "No ETH to claim");\r
\r
claimableAmount[WALLET_A] = 0;\r
totalClaimedA += amount;\r
\r
(bool success, ) = WALLET_A.call{value: amount}("");\r
require(success, "ETH transfer failed");\r
\r
emit ETHClaimed(WALLET_A, amount, totalClaimedA);\r
}\r
\r
// Function for WALLET_B to claim their 90%\r
function claimB() external nonReentrant {\r
require(msg.sender == WALLET_B, "Only WALLET_B can claim");\r
\r
uint256 amount = claimableAmount[WALLET_B];\r
require(amount > 0, "No ETH to claim");\r
\r
claimableAmount[WALLET_B] = 0;\r
totalClaimedB += amount;\r
\r
(bool success, ) = WALLET_B.call{value: amount}("");\r
require(success, "ETH transfer failed");\r
\r
emit ETHClaimed(WALLET_B, amount, totalClaimedB);\r
}\r
\r
// View functions for getting distribution info\r
function getClaimableAmountA() external view returns (uint256) {\r
return claimableAmount[WALLET_A];\r
}\r
\r
function getClaimableAmountB() external view returns (uint256) {\r
return claimableAmount[WALLET_B];\r
}\r
\r
function getTotalClaimable() external view returns (uint256) {\r
return claimableAmount[WALLET_A] + claimableAmount[WALLET_B];\r
}\r
\r
function getDistributionInfo() external view returns (\r
uint256 totalAcc,\r
uint256 claimableA,\r
uint256 claimableB,\r
uint256 claimedA,\r
uint256 claimedB,\r
uint256 contractBalance\r
) {\r
return (\r
totalAccumulated,\r
claimableAmount[WALLET_A],\r
claimableAmount[WALLET_B],\r
totalClaimedA,\r
totalClaimedB,\r
address(this).balance\r
);\r
}\r
\r
// Emergency function to check contract balance\r
function getContractBalance() external view returns (uint256) {\r
return address(this).balance;\r
}\r
}"
},
"@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-09-26 09:57:52
Comments
Log in to comment.
No comments yet.