Verified contractExactMIT
Executor
Address0xe6dd12cf1db2c7afb34865d753780fe714622a6a
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.34
- Same code
Only this contract
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,448,750
- Creation transaction
- 0x7fb9a6ac60…ca7ddc67d0
depoy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
}
contract Executor {
address constant OWNER = 0x47fa538ae6C1aEc385b17e903463bafE132C9A8b;
address constant EXECUTOR = 0x47fa538ae6C1aEc385b17e903463bafE132C9A8b;
event Flushed(address to, uint256 amount);
event TokensFlushed(address token, address to, uint256 amount);
modifier onlyAuthorized() {
require(
msg.sender == OWNER || msg.sender == EXECUTOR,
"Executor: not authorized"
);
_;
}
function owner() external pure returns (address) {
return OWNER;
}
function executor() external pure returns (address) {
return EXECUTOR;
}
function execute(
bytes[] calldata calls,
uint256 reward,
bool flushRemaining,
uint256 targetTimestamp,
uint256 targetBlock,
address[] calldata tokensToFlush // ⬅️ Array of token addresses
) external payable onlyAuthorized {
require(block.timestamp >= targetTimestamp, "targetTimestamp not reached");
require(block.number >= targetBlock, "targetBlockNumber not reached");
uint256 successCount = 0;
for (uint256 i = 0; i < calls.length; i++) {
(address to, uint256 value, bytes memory data, bool revertOnFail) = abi.decode(
calls[i],
(address, uint256, bytes, bool)
);
(bool success, bytes memory result) = to.call{value: value}(data);
if (success) {
successCount++;
} else if (revertOnFail) {
revert(string(result));
}
}
require(successCount > 0, "Executor: all calls failed");
if (reward > 0) {
require(address(this).balance >= reward, "Insufficient balance for reward");
(bool sent, ) = block.coinbase.call{value: reward}("");
require(sent, "Failed to send reward");
}
if (flushRemaining && address(this).balance > 0) {
(bool sent, ) = OWNER.call{value: address(this).balance}("");
require(sent, "Flush failed");
}
// ⬇️ Flush all specified ERC20 tokens
for (uint256 j = 0; j < tokensToFlush.length; j++) {
address token = tokensToFlush[j];
if (token != address(0)) {
uint256 tokenBalance = IERC20(token).balanceOf(address(this));
if (tokenBalance > 0) {
bool tokenSent = IERC20(token).transfer(OWNER, tokenBalance);
require(tokenSent, "Token transfer failed");
emit TokensFlushed(token, OWNER, tokenBalance);
}
}
}
}
receive() external payable {
if (msg.sender != address(this)) {
_flush();
}
}
function _flush() internal {
uint256 bal = address(this).balance;
if (bal > 0) {
(bool sent, ) = OWNER.call{value: bal}("");
require(sent, "Flush: ETH transfer failed");
emit Flushed(OWNER, bal);
}
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.