Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0x8A42d311D282Bfcaa5133b2DE0a8bCDBECea3073
Balance 0 ETH
Nonce 1
Code Size 1592 bytes
Indexed Transactions 0 (1 on-chain, 0.7% indexed)
External Etherscan · Sourcify

Contract Bytecode

1592 bytes
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c8063bca8c7b51161005b578063bca8c7b5146100d6578063be6502e9146101cb578063e8edc816146101d3578063f9c7a0d1146101db5761007d565b806348e196d114610082578063782a533f1461008c5780638c064e19146100b0575b600080fd5b61008a6101f5565b005b6100946102ad565b604080516001600160a01b039092168252519081900360200190f35b61008a600480360360208110156100c657600080fd5b50356001600160a01b03166102bc565b610156600480360360408110156100ec57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561011757600080fd5b82018360208201111561012957600080fd5b8035906020019184600183028401116401000000008311171561014b57600080fd5b5090925090506103f4565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610190578181015183820152602001610178565b50505050905090810190601f1680156101bd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61008a6104d8565b610094610545565b6101e3610554565b60408051918252519081900360200190f35b6002546102335760405162461bcd60e51b815260040180806020018281038252602681526020018061058b6026913960400191505060405180910390fd5b6002544210156102745760405162461bcd60e51b815260040180806020018281038252602a815260200180610561602a913960400191505060405180910390fd5b600180546000805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b038416178255600291909155169055565b6001546001600160a01b031681565b6000546001600160a01b0316331461031b576040805162461bcd60e51b815260206004820181905260248201527f416c6c6f77616e63655461726765743a206e6f7420746865207370656e646572604482015290519081900360640190fd5b61032d816001600160a01b031661055a565b6103685760405162461bcd60e51b815260040180806020018281038252602b8152602001806105b1602b913960400191505060405180910390fd5b6001546001600160a01b03161580156103815750600254155b6103bc5760405162461bcd60e51b81526004018080602001828103825260278152602001806105dc6027913960400191505060405180910390fd5b6201518042016002556001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000546060906001600160a01b03163314610456576040805162461bcd60e51b815260206004820181905260248201527f416c6c6f77616e63655461726765743a206e6f7420746865207370656e646572604482015290519081900360640190fd5b6000846001600160a01b03168484604051808383808284376040519201945060009350909150508083038183865af19150503d80600081146104b4576040519150601f19603f3d011682016040523d82523d6000602084013e6104b9565b606091505b5092509050806104d0576040513d806000833e8082fd5b509392505050565b6000546001600160a01b03163314610537576040805162461bcd60e51b815260206004820181905260248201527f416c6c6f77616e63655461726765743a206e6f7420746865207370656e646572604482015290519081900360640190fd5b6000546001600160a01b0316ff5b6000546001600160a01b031681565b60025481565b3b15159056fe416c6c6f77616e63655461726765743a2074696d65206c6f636b206e6f74206578706972656420796574416c6c6f77616e63655461726765743a206e6f2070656e64696e67205365745370656e646572416c6c6f77616e63655461726765743a206e6577207370656e646572206e6f74206120636f6e7472616374416c6c6f77616e63655461726765743a205365745370656e64657220696e2070726f6772657373a26469706673582212201611b45ed194e38f6715c69ea91e3117814ef98600d350e22144bc44a7fd0ef964736f6c634300060c0033

Verified Source Code Full Match

Compiler: v0.6.12+commit.27d51765 EVM: istanbul Optimization: Yes (1000 runs)
AllowanceTarget.sol 84 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.5;

import "@openzeppelin/contracts/utils/Address.sol";
import "./interface/IAllowanceTarget.sol";

/**
 * @dev AllowanceTarget contract
 */
contract AllowanceTarget is IAllowanceTarget {
    using Address for address;

    uint256 constant private TIME_LOCK_DURATION = 1 days;

    address public spender;
    address public newSpender;
    uint256 public timelockExpirationTime;

    modifier onlySpender() {
        require(spender == msg.sender, "AllowanceTarget: not the spender");
        _;
    }


    constructor(address _spender) public {
        require(_spender != address(0), "AllowanceTarget: _spender should not be 0");

        // Set spender
        spender = _spender;
    }


    function setSpenderWithTimelock(address _newSpender) override external onlySpender {
        require(_newSpender.isContract(), "AllowanceTarget: new spender not a contract");
        require(newSpender == address(0) && timelockExpirationTime == 0, "AllowanceTarget: SetSpender in progress");

        timelockExpirationTime = now + TIME_LOCK_DURATION;
        newSpender = _newSpender;
    }

    function completeSetSpender() override external {
        require(timelockExpirationTime != 0, "AllowanceTarget: no pending SetSpender");
        require(now >= timelockExpirationTime, "AllowanceTarget: time lock not expired yet");

        // Set new spender
        spender = newSpender;
        // Reset
        timelockExpirationTime = 0;
        newSpender = address(0);
    }


    function teardown() override external onlySpender {
        selfdestruct(payable(spender));
    }


    /// @dev Execute an arbitrary call. Only an authority can call this.
    /// @param target The call target.
    /// @param callData The call data.
    /// @return resultData The data returned by the call.
    function executeCall(
        address payable target,
        bytes calldata callData
    )
        override
        external
        onlySpender
        returns (bytes memory resultData)
    {
        bool success;
        (success, resultData) = target.call(callData);
        if (!success) {
            // Get the error message returned
            assembly {
                let ptr := mload(0x40)
                let size := returndatasize()
                returndatacopy(ptr, 0, size)
                revert(ptr, size)
            }
        }
    }
}
IAllowanceTarget.sol 8 lines
pragma solidity ^0.6.0;

interface IAllowanceTarget {
    function setSpenderWithTimelock(address _newSpender) external;
    function completeSetSpender() external;
    function executeCall(address payable _target, bytes calldata _callData) external returns (bytes memory resultData);
    function teardown() external;
}
Address.sol 141 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies in extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

Read Contract

newSpender 0x782a533f → address
spender 0xe8edc816 → address
timelockExpirationTime 0xf9c7a0d1 → uint256

Write Contract 4 functions

These functions modify contract state and require a wallet transaction to execute.

completeSetSpender 0x48e196d1
No parameters
executeCall 0xbca8c7b5
address target
bytes callData
returns: bytes
setSpenderWithTimelock 0x8c064e19
address _newSpender
teardown 0xbe6502e9
No parameters

Recent Transactions

This address has 1 on-chain transactions, but only 0.7% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →