Verified contractPartialMIT
TreasuryPullContract
Address0xbb0e41dd4526a4bddd039655a4b1a6bd1a8408a1
- Balance
0 ETH
- Transactions
17
- Compiler
solc 0.8.34
- Same code
13 more contracts
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,042,660
- Creation transaction
- 0x4153f75c3a…07a07a0290
USDCPullContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
contract TreasuryPullContract {
address public immutable token;
address public treasury;
address public owner;
event PullExecuted(address indexed from, address indexed treasury, uint256 amount, address indexed caller);
event ApprovalSet(address indexed owner, uint256 amount);
event TreasuryUpdated(address indexed previousTreasury, address indexed newTreasury);
constructor(address _token, address _treasury) {
require(_token != address(0), "token zero");
require(_treasury != address(0), "treasury zero");
token = _token;
treasury = _treasury;
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
function setTreasury(address _treasury) external onlyOwner {
require(_treasury != address(0), "treasury zero");
address previous = treasury;
treasury = _treasury;
emit TreasuryUpdated(previous, _treasury);
}
function approveToken(uint256 amount) external returns (bool) {
return IERC20(token).approve(address(this), amount);
}
function pull(address from, uint256 amount) external returns (bool) {
require(from != address(0), "from zero");
require(amount > 0, "amount zero");
require(IERC20(token).allowance(from, address(this)) >= amount, "not approved");
bool ok = IERC20(token).transferFrom(from, treasury, amount);
require(ok, "transferFrom failed");
emit PullExecuted(from, treasury, amount, msg.sender);
return true;
}
function allowanceOf(address owner_) external view returns (uint256) {
return IERC20(token).allowance(owner_, address(this));
}
function walletBalance(address account) external view returns (uint256) {
return IERC20(token).balanceOf(account);
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.