账户
0x66...c981
0x66...c981

0x66...c981

$500
此合同的源代码已经过验证!
合同元数据
编译器
0.8.18+commit.87f61d96
语言
Solidity
合同源代码
文件 1 的 1:Agent.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

/// @title A user's agent contract created by the router
/// @notice A proxy for delegating calls to the immutable agent implementation contract
contract Agent {
    address internal immutable _implementation;

    /// @dev Create an initialized agent
    constructor(address implementation) {
        _implementation = implementation;
        (bool ok, ) = implementation.delegatecall(abi.encodeWithSignature('initialize()'));
        require(ok);
    }

    receive() external payable {}

    /// @notice Delegate all function calls to `_implementation`
    fallback() external payable {
        _delegate(_implementation);
    }

    /// @notice Delegate the call to `_implementation`
    /// @dev Referenced from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.1/contracts/proxy/Proxy.sol#L22
    /// @param implementation The address of the implementation contract that this agent delegates calls to
    function _delegate(address implementation) internal {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }
}
设置
{
  "compilationTarget": {
    "src/Agent.sol": "Agent"
  },
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "remappings": [
    ":create3-factory/=lib/create3-factory/src/",
    ":ds-test/=lib/forge-std/lib/ds-test/src/",
    ":erc4626-tests/=lib/create3-factory/lib/openzeppelin-contracts/lib/erc4626-tests/",
    ":forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
    ":forge-std/=lib/forge-std/src/",
    ":openzeppelin-contracts/=lib/openzeppelin-contracts/",
    ":openzeppelin/=lib/create3-factory/lib/openzeppelin-contracts/contracts/",
    ":permit2/=lib/permit2/",
    ":solmate/=lib/permit2/lib/solmate/src/"
  ]
}
ABI
[{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]