ETH Price: $3,368.28 (-3.39%)

Contract

0xd313E04A4Bd954E33C6DaAbd7f1B277b8087A948
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

1 Internal Transaction found.

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block
From
To
186957892023-12-02 2:39:11390 days ago1701484751  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
IntentTarget01

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion
File 1 of 3 : IntentTarget01.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity =0.8.17;


/**
 *    ,,                           ,,                                
 *   *MM                           db                      `7MM      
 *    MM                                                     MM      
 *    MM,dMMb.      `7Mb,od8     `7MM      `7MMpMMMb.        MM  ,MP'
 *    MM    `Mb       MM' "'       MM        MM    MM        MM ;Y   
 *    MM     M8       MM           MM        MM    MM        MM;Mm   
 *    MM.   ,M9       MM           MM        MM    MM        MM `Mb. 
 *    P^YbmdP'      .JMML.       .JMML.    .JMML  JMML.    .JMML. YA.
 *
 *    IntentTarget01.sol :: 0xd313e04a4bd954e33c6daabd7f1b277b8087a948
 *    etherscan.io verified 2023-12-01
 */ 
import "./IntentBase.sol";
import "./Libraries/ProxyReentrancyGuard.sol";

error BadIntentIndex();
error UnsignedCallRequired();

/// @param segmentTarget Contract address where segment functions will be executed
/// @param intents Array of allowed intents
/// @param beforeCalls Array of segment calls to execute before intent execution
/// @param afterCalls Array of segment calls to execute after intent execution
struct Declaration {
  address segmentTarget;
  Intent[] intents;
  bytes[] beforeCalls;
  bytes[] afterCalls;
}

struct Intent {
  Segment[] segments;
}

struct Segment {
  bytes data;
  bool requiresUnsignedCall;
}

struct UnsignedData {
  uint8 intentIndex;
  bytes[] calls;
}

contract IntentTarget01 is IntentBase, ProxyReentrancyGuard {

  /// @dev Execute a signed declaration of intents
  /// @notice This should be executed by metaDelegateCall() or metaDelegateCall_EIP1271() with the following signed and unsigned params
  /// @param declaration Declaration of intents signed by owner [signed]
  /// @param unsignedData Unsigned calldata [unsigned]
  function execute(
    Declaration calldata declaration,
    UnsignedData calldata unsignedData
  ) external nonReentrant {
    if (unsignedData.intentIndex >= declaration.intents.length) {
      revert BadIntentIndex();
    }

    _delegateCallsWithRevert(declaration.segmentTarget, declaration.beforeCalls);

    uint8 nextUnsignedCall = 0;
    for (uint8 i = 0; i < declaration.intents[unsignedData.intentIndex].segments.length; i++) {
      Segment calldata segment = declaration.intents[unsignedData.intentIndex].segments[i];
      bytes memory segmentCallData;
      if (segment.requiresUnsignedCall) {
        if (nextUnsignedCall >= unsignedData.calls.length) {
          revert UnsignedCallRequired();
        }

        bytes memory signedData = segment.data;

        // change length of signedData to ignore the last bytes32
        assembly {
          mstore(add(signedData, 0x0), sub(mload(signedData), 0x20))
        }

        // concat signed and unsigned call bytes
        segmentCallData = bytes.concat(signedData, unsignedData.calls[nextUnsignedCall]);
        nextUnsignedCall++;
      } else {
        segmentCallData = segment.data;
      }
      _delegateCallWithRevert(Call({
        targetContract: declaration.segmentTarget,
        data: segmentCallData
      }));
    }

    _delegateCallsWithRevert(declaration.segmentTarget, declaration.afterCalls);
  }

  function _delegateCallsWithRevert (address targetContract, bytes[] calldata calls) internal {
    for (uint8 i = 0; i < calls.length; i++) {
      _delegateCallWithRevert(Call({
        targetContract: targetContract,
        data: calls[i]
      }));
    }
  }

  function _delegateCallWithRevert (Call memory call) internal {
    address targetContract = call.targetContract;
    bytes memory data = call.data;
    assembly {
      let result := delegatecall(gas(), targetContract, add(data, 0x20), mload(data), 0, 0)
      if eq(result, 0) {
        returndatacopy(0, 0, returndatasize())
        revert(0, returndatasize())
      }
    }
  }
}

File 2 of 3 : IntentBase.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity =0.8.17;

struct Call {
  address targetContract;
  bytes data;
}

abstract contract IntentBase { }

File 3 of 3 : ProxyReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
// Modified to use unstructured storage for proxy/implementation pattern

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ProxyReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ProxyReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    // uint256 representation of keccak("reentrancy_guard_status")
    uint256 private constant _STATUS_PTR = 111692000423667832297373040361148959237193225730820145803586364568851768547719;

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status() != _ENTERED, "ProxyReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _setStatus(_ENTERED);
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _setStatus(_NOT_ENTERED);
    }

    function _setStatus(uint256 status) private {
        assembly { sstore(_STATUS_PTR, status) }
    }

    function _status() internal view returns (uint256 status) {
        assembly { status := sload(_STATUS_PTR) }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "metadata": {
    "bytecodeHash": "none"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"BadIntentIndex","type":"error"},{"inputs":[],"name":"UnsignedCallRequired","type":"error"},{"inputs":[{"components":[{"internalType":"address","name":"segmentTarget","type":"address"},{"components":[{"components":[{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bool","name":"requiresUnsignedCall","type":"bool"}],"internalType":"struct Segment[]","name":"segments","type":"tuple[]"}],"internalType":"struct Intent[]","name":"intents","type":"tuple[]"},{"internalType":"bytes[]","name":"beforeCalls","type":"bytes[]"},{"internalType":"bytes[]","name":"afterCalls","type":"bytes[]"}],"internalType":"struct Declaration","name":"declaration","type":"tuple"},{"components":[{"internalType":"uint8","name":"intentIndex","type":"uint8"},{"internalType":"bytes[]","name":"calls","type":"bytes[]"}],"internalType":"struct UnsignedData","name":"unsignedData","type":"tuple"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50610736806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80634f899fb214610030575b600080fd5b61004361003e3660046104e5565b610045565b005b61004d610333565b61005a6020830183610558565b905061006960208301836105a9565b60ff161061008a57604051637881879360e01b815260040160405180910390fd5b6100ac61009a60208401846105d3565b6100a76040850185610558565b6103e5565b6000805b6100bd6020850185610558565b6100ca60208601866105a9565b60ff168181106100dc576100dc610609565b90506020028101906100ee919061061f565b6100f89080610558565b90508160ff16101561030857366101126020860186610558565b61011f60208701876105a9565b60ff1681811061013157610131610609565b9050602002810190610143919061061f565b61014d9080610558565b8360ff1681811061016057610160610609565b9050602002810190610172919061063f565b905060606101866040830160208401610655565b15610272576101986020860186610558565b90508460ff16106101bc5760405163c14ac78b60e01b815260040160405180910390fd5b60006101c88380610677565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250508251601f19018352509091508190506102166020880188610558565b8760ff1681811061022957610229610609565b905060200281019061023b9190610677565b60405160200161024d939291906106be565b60405160208183030381529060405291508480610269906106fc565b955050506102b4565b61027c8280610677565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509293505050505b604080518082019091526102f390806102d060208a018a6105d3565b73ffffffffffffffffffffffffffffffffffffffff168152602001839052610497565b50508080610300906106fc565b9150506100b0565b5061032661031960208501856105d3565b6100a76060860186610558565b5061032f6104bc565b5050565b600261035d7ff6ef6e958a5ebb449666809e8ffe373209b30b1bdf012fe2fea8635ab59e19875490565b036103ba5760405162461bcd60e51b8152602060048201526024808201527f50726f78795265656e7472616e637947756172643a207265656e7472616e742060448201526318d85b1b60e21b606482015260840160405180910390fd5b6103e360027ff6ef6e958a5ebb449666809e8ffe373209b30b1bdf012fe2fea8635ab59e198755565b565b60005b60ff81168211156104915761047f60405180604001604052808673ffffffffffffffffffffffffffffffffffffffff16815260200185858560ff1681811061043257610432610609565b90506020028101906104449190610677565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250610497565b80610489816106fc565b9150506103e8565b50505050565b80516020808301518051909160009182918401855af480610491573d6000803e3d6000fd5b6103e360017ff6ef6e958a5ebb449666809e8ffe373209b30b1bdf012fe2fea8635ab59e198755565b600080604083850312156104f857600080fd5b823567ffffffffffffffff8082111561051057600080fd5b908401906080828703121561052457600080fd5b9092506020840135908082111561053a57600080fd5b5083016040818603121561054d57600080fd5b809150509250929050565b6000808335601e1984360301811261056f57600080fd5b83018035915067ffffffffffffffff82111561058a57600080fd5b6020019150600581901b36038213156105a257600080fd5b9250929050565b6000602082840312156105bb57600080fd5b813560ff811681146105cc57600080fd5b9392505050565b6000602082840312156105e557600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146105cc57600080fd5b634e487b7160e01b600052603260045260246000fd5b60008235601e1983360301811261063557600080fd5b9190910192915050565b60008235603e1983360301811261063557600080fd5b60006020828403121561066757600080fd5b813580151581146105cc57600080fd5b6000808335601e1984360301811261068e57600080fd5b83018035915067ffffffffffffffff8211156106a957600080fd5b6020019150368190038213156105a257600080fd5b6000845160005b818110156106df57602081880181015185830152016106c5565b506000908301908152838582376000930192835250909392505050565b600060ff821660ff810361072057634e487b7160e01b600052601160045260246000fd5b6001019291505056fea164736f6c6343000811000a

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80634f899fb214610030575b600080fd5b61004361003e3660046104e5565b610045565b005b61004d610333565b61005a6020830183610558565b905061006960208301836105a9565b60ff161061008a57604051637881879360e01b815260040160405180910390fd5b6100ac61009a60208401846105d3565b6100a76040850185610558565b6103e5565b6000805b6100bd6020850185610558565b6100ca60208601866105a9565b60ff168181106100dc576100dc610609565b90506020028101906100ee919061061f565b6100f89080610558565b90508160ff16101561030857366101126020860186610558565b61011f60208701876105a9565b60ff1681811061013157610131610609565b9050602002810190610143919061061f565b61014d9080610558565b8360ff1681811061016057610160610609565b9050602002810190610172919061063f565b905060606101866040830160208401610655565b15610272576101986020860186610558565b90508460ff16106101bc5760405163c14ac78b60e01b815260040160405180910390fd5b60006101c88380610677565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250508251601f19018352509091508190506102166020880188610558565b8760ff1681811061022957610229610609565b905060200281019061023b9190610677565b60405160200161024d939291906106be565b60405160208183030381529060405291508480610269906106fc565b955050506102b4565b61027c8280610677565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509293505050505b604080518082019091526102f390806102d060208a018a6105d3565b73ffffffffffffffffffffffffffffffffffffffff168152602001839052610497565b50508080610300906106fc565b9150506100b0565b5061032661031960208501856105d3565b6100a76060860186610558565b5061032f6104bc565b5050565b600261035d7ff6ef6e958a5ebb449666809e8ffe373209b30b1bdf012fe2fea8635ab59e19875490565b036103ba5760405162461bcd60e51b8152602060048201526024808201527f50726f78795265656e7472616e637947756172643a207265656e7472616e742060448201526318d85b1b60e21b606482015260840160405180910390fd5b6103e360027ff6ef6e958a5ebb449666809e8ffe373209b30b1bdf012fe2fea8635ab59e198755565b565b60005b60ff81168211156104915761047f60405180604001604052808673ffffffffffffffffffffffffffffffffffffffff16815260200185858560ff1681811061043257610432610609565b90506020028101906104449190610677565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250610497565b80610489816106fc565b9150506103e8565b50505050565b80516020808301518051909160009182918401855af480610491573d6000803e3d6000fd5b6103e360017ff6ef6e958a5ebb449666809e8ffe373209b30b1bdf012fe2fea8635ab59e198755565b600080604083850312156104f857600080fd5b823567ffffffffffffffff8082111561051057600080fd5b908401906080828703121561052457600080fd5b9092506020840135908082111561053a57600080fd5b5083016040818603121561054d57600080fd5b809150509250929050565b6000808335601e1984360301811261056f57600080fd5b83018035915067ffffffffffffffff82111561058a57600080fd5b6020019150600581901b36038213156105a257600080fd5b9250929050565b6000602082840312156105bb57600080fd5b813560ff811681146105cc57600080fd5b9392505050565b6000602082840312156105e557600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146105cc57600080fd5b634e487b7160e01b600052603260045260246000fd5b60008235601e1983360301811261063557600080fd5b9190910192915050565b60008235603e1983360301811261063557600080fd5b60006020828403121561066757600080fd5b813580151581146105cc57600080fd5b6000808335601e1984360301811261068e57600080fd5b83018035915067ffffffffffffffff8211156106a957600080fd5b6020019150368190038213156105a257600080fd5b6000845160005b818110156106df57602081880181015185830152016106c5565b506000908301908152838582376000930192835250909392505050565b600060ff821660ff810361072057634e487b7160e01b600052601160045260246000fd5b6001019291505056fea164736f6c6343000811000a

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.