Skip to content
Verified contractPartialMIT

Executor

Address0x8b5d51af4c4542f241c4e54cfd903ceed145f082
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.27

 

Same code

2 more contracts

 

Details

Compiler
solc 0.8.27+commit.40a35a09
Language
solidity
Optimization
Yes, 1,000,000 runs
EVM version
paris
Via IR
yes
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,081,371
Creation transaction
0xac4b94a8ed…526fad2830
Main copy (most transactions)
0xeba53db3…11877eac

contracts/Executor.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {IExecutor} from "./interfaces/IExecutor.sol";

import {Call} from "./types/Intent.sol";

/**
 * @title Executor
 * @notice Contract for secure batch execution of intent calls
 * @dev Implements IExecutor with comprehensive safety checks and authorization controls
 * - Only the portal contract can execute calls (onlyPortal modifier)
 * - Prevents malicious calls through EOA validation
 * - Supports batch execution for multiple calls in a single transaction
 */
contract Executor is IExecutor {
    /**
     * @notice Address of the portal contract authorized to call execute
     */
    address private immutable portal;

    /**
     * @notice Initializes the Executor contract
     * @dev Sets the deploying address (portal) as the only authorized caller
     */
    constructor() {
        portal = msg.sender;
    }

    /**
     * @notice Restricts function access to the portal contract only
     * @dev Reverts with NonPortalCaller error if caller is not the portal
     */
    modifier onlyPortal() {
        if (msg.sender != portal) {
            revert NonPortalCaller(msg.sender);
        }

        _;
    }

    /**
     * @notice Executes multiple intent calls with comprehensive safety checks
     * @dev Performs validation and execution for each call in the batch:
     * 1. Prevents calls to EOAs that include calldata (potential phishing protection)
     * 2. Executes each call and returns results or reverts on any failure
     * @param calls Array of call data containing target addresses, values, and calldata
     * @return Array of return data from the successfully executed calls
     */
    function execute(
        Call[] calldata calls
    ) external payable override onlyPortal returns (bytes[] memory) {
        uint256 callsLength = calls.length;
        bytes[] memory results = new bytes[](callsLength);

        for (uint256 i = 0; i < callsLength; i++) {
            results[i] = execute(calls[i]);
        }

        return results;
    }

    function execute(Call calldata call) internal returns (bytes memory) {
        if (_isCallToEoa(call)) {
            revert CallToEOA(call.target);
        }

        (bool success, bytes memory result) = call.target.call{
            value: call.value
        }(call.data);

        if (!success) {
            revert CallFailed(call, result);
        }

        return result;
    }

    /**
     * @notice Checks if a call is targeting an EOA with calldata
     * @dev Returns true if target has no code but calldata is provided
     * This prevents potential phishing attacks where calldata might be misinterpreted
     * @param call The call to validate
     * @return bool True if this is a potentially unsafe call to an EOA
     */
    function _isCallToEoa(Call calldata call) internal view returns (bool) {
        return call.target.code.length == 0 && call.data.length > 0;
    }

    /**
     * @notice Allows the contract to receive ETH
     * @dev Required for handling ETH transfer for intent execution
     */
    receive() external payable {}
}

contracts/interfaces/IExecutor.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {Call} from "../types/Intent.sol";

/**
 * @title IExecutor
 * @notice Interface for secure batch execution of intent calls
 * @dev Provides controlled execution with built-in safety checks and authorization
 * - Restricts execution to authorized portal contracts only
 * - Prevents calls to EOAs with calldata
 * - Supports batch execution for multiple calls in a single transaction
 */
interface IExecutor {
    /**
     * @notice Thrown when caller is not the portal to execute calls
     * @param caller The unauthorized address that attempted the call
     */
    error NonPortalCaller(address caller);

    /**
     * @notice Attempted call to an EOA
     * @param target EOA address to which call was attempted
     */
    error CallToEOA(address target);

    /**
     * @notice Call to a contract failed
     * @param call The call that failed
     * @param reason The reason for the failure
     */
    error CallFailed(Call call, bytes reason);

    /**
     * @notice Executes multiple intent calls with safety checks
     * @dev Validates each target address and executes calls if safe
     * - Prevents calls to EOAs that include calldata
     * - Reverts if any target call fails
     * @param calls Array of call data containing target, value, and calldata
     * @return Array of return data from the executed calls
     */
    function execute(
        Call[] calldata calls
    ) external payable returns (bytes[] memory);
}

contracts/types/Intent.sol

/* -*- c-basic-offset: 4 -*- */
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

/**
 * @notice Represents a single contract call with encoded function data
 * @dev Used to execute arbitrary function calls on the destination chain
 * @param target The contract address to call
 * @param data ABI-encoded function call data
 * @param value Amount of native tokens to send with the call
 */
struct Call {
    address target;
    bytes data;
    uint256 value;
}

/**
 * @notice Represents a token amount pair
 * @dev Used to specify token rewards and transfers
 * @param token Address of the ERC20 token contract
 * @param amount Amount of tokens in the token's smallest unit
 */
struct TokenAmount {
    address token;
    uint256 amount;
}

/**
 * @notice Defines the routing and execution instructions for cross-chain messages
 * @dev Contains all necessary information to route and execute a message on the destination chain
 * @param salt Unique identifier provided by the intent creator, used to prevent duplicates
 * @param deadline Timestamp by which the route must be executed
 * @param portal Address of the portal contract on the destination chain that receives messages
 * @param nativeAmount Amount of native tokens to send with the route execution
 * @param tokens Array of tokens required for execution of calls on destination chain
 * @param calls Array of contract calls to execute on the destination chain in sequence
 */
struct Route {
    bytes32 salt;
    uint64 deadline;
    address portal;
    uint256 nativeAmount;
    TokenAmount[] tokens;
    Call[] calls;
}

/**
 * @notice Defines the reward and validation parameters for cross-chain execution
 * @dev Specifies who can execute the intent and what rewards they receive
 * @param deadline Timestamp after which the intent can no longer be executed
 * @param creator Address that created the intent and has authority to modify/cancel
 * @param prover Address of the prover contract that must approve execution
 * @param nativeAmount Amount of native tokens offered as reward
 * @param tokens Array of ERC20 tokens and amounts offered as additional rewards
 */
struct Reward {
    uint64 deadline;
    address creator;
    address prover;
    uint256 nativeAmount;
    TokenAmount[] tokens;
}

/**
 * @notice Complete cross-chain intent combining routing and reward information
 * @dev Main structure used to process and execute cross-chain messages
 * @param destination Target chain ID where the intent should be executed
 * @param route Routing and execution instructions
 * @param reward Reward and validation parameters
 */
struct Intent {
    uint64 destination;
    Route route;
    Reward reward;
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": false,
    "bytecodeHash": "none"
  },
  "libraries": {},
  "optimizer": {
    "runs": 1000000,
    "enabled": true
  },
  "evmVersion": "paris",
  "remappings": [
    "@eth-optimism/contracts-bedrock/=node_modules/@eth-optimism/contracts-bedrock/",
    "@hyperlane-xyz/core/=node_modules/@hyperlane-xyz/core/",
    "@metalayer/contracts/=node_modules/@metalayer/contracts/",
    "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
    "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.