Verified contractPartialMIT
Executor7702
Address0xde9fdb02b95e7345649b0d4ce596c4a306f781bd
- Balance
0 ETH
- Transactions
2
- Compiler
solc 0.8.34
- Same code
1 more contract
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,373,262
- Creation transaction
- 0xbe07de7701…6e54eb5f8a
contracts/executor.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IERC20Balance {
function balanceOf(address account) external view returns (uint256);
}
/// @notice Storage-free EIP-7702 executor implementation.
/// @dev When delegated with EIP-7702, this code executes in the EOA's context.
/// Do not rely on constructor-written storage. Immutables are safe because
/// their values are embedded in this implementation's runtime bytecode.
contract Executor7702 {
struct Call {
address target;
uint256 value;
bytes data;
}
error Unauthorized(address caller);
error OnlySelf(address caller);
error ZeroSponsor();
error UnsupportedCall();
error CallFailed(uint256 index, address target, bytes reason);
error TokenBalanceTooLow(address token, uint256 actual, uint256 minimum);
event FailedCall(uint256 indexed index, address indexed target, bytes reason);
// Up to three independent funders can be authorized without touching EOA storage.
address public immutable sponsor0;
address public immutable sponsor1;
address public immutable sponsor2;
constructor(address _sponsor0, address _sponsor1, address _sponsor2) {
if (_sponsor0 == address(0)) revert ZeroSponsor();
sponsor0 = _sponsor0;
sponsor1 = _sponsor1;
sponsor2 = _sponsor2;
}
modifier onlySponsor() {
if (
msg.sender != sponsor0 &&
msg.sender != sponsor1 &&
msg.sender != sponsor2
) revert Unauthorized(msg.sender);
_;
}
modifier onlySelf() {
if (msg.sender != address(this)) revert OnlySelf(msg.sender);
_;
}
/// @notice Execute calls from the delegated EOA atomically when revertOnFail=true.
function m(Call[] calldata calls, bool revertOnFail)
external
payable
onlySponsor
{
uint256 length = calls.length;
for (uint256 i; i < length; ) {
Call calldata c = calls[i];
(bool ok, bytes memory ret) = c.target.call{value: c.value}(c.data);
if (!ok) {
if (revertOnFail) revert CallFailed(i, c.target, ret);
emit FailedCall(i, c.target, ret);
}
unchecked { ++i; }
}
}
/// @notice Guard intended to be inserted into m() as a self-call immediately
/// after the claim/withdraw call and before transfer/swap/sweep.
function assertTokenBalanceAtLeast(address token, uint256 minimum)
external
view
onlySelf
{
uint256 actual = IERC20Balance(token).balanceOf(address(this));
if (actual < minimum) {
revert TokenBalanceTooLow(token, actual, minimum);
}
}
receive() external payable {}
fallback() external payable {
revert UnsupportedCall();
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.