POL Price: $0.381772 (+0.48%)
Gas: 37.5 GWei
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
0x60a06040340342382022-10-07 6:42:13730 days ago1665124933IN
 Create: TimeConditions
0 POL0.0089633130.00000001

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
TimeConditions

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license
File 1 of 1 : TimeConditions.sol
pragma solidity 0.8.6;


/**
* @notice   This contract serves as a condition contract, to be used with Autonomy's
*           Automation Station and bundled with other calls to add conditions to
*           calls to contracts in a modular way without the need for duplicating
*           this logic elsewhere. It allows the called to specify that a request
*           is executed between 2 times (with `betweenTimes`, presumably for a
*           non-recurring request), aswell as to be called periodically every
*           X seconds (with `everyTimePeriod`, presumably for recurring requests).
* @author   @pldespaigne (Pierre-Louis Despaigne), @quantafire (James Key)
*/
contract TimeConditions {

    event Started(address indexed user, uint callId);
    

    // Mapping a user to last execution date of its ongoing requests
    // - because a user can have multiple requests, we introduce an arbitrary requestID (also refered as `callId`)
    // - users can know their previous `callId`s by looking at emitted `Started` events
    mapping(address => mapping(uint => uint)) public userToIdToLastExecTime;
    // The forwarder address through which calls are forwarded that guarantee the 1st argument, `user`, is accurate
    address public immutable routerUserVeriForwarder;


    constructor(address routerUserVeriForwarder_) {
        routerUserVeriForwarder = routerUserVeriForwarder_;
    }

    /**
    * @notice Ensure that the tx is being executed between 2 times (inclusive)
    *
    * @param afterTime  The 1st unix time from which the execution will succeed (inclusive).
    * @param beforeTime The last unix time from which the execution will succeed (inclusive).
    */
    function betweenTimes(uint afterTime, uint beforeTime) external view {
        require(block.timestamp >= afterTime, "TimeConditions: too early");
        require(block.timestamp <= beforeTime, "TimeConditions: too late");
    }

    /**
    * @notice       Ensure the tx is executed periodically, beginning from `startTime`, and
    *               occurring every `periodLength` after that.
    * @dev          The execution will never occur exactly at `startTime`, nor exactly at the
    *               beginning of the next period, but the average execution time should be
    *               around the same time with the proper period and should not drift because
    *               `block.timestamp` is never used to refer to the last execution time.
    * @param user   The address of the user who made the request. This is guaranteed to be
    *               accurate by `msg.sender` being `routerUserVeriForwarder` and is needed
    *               to ensure that different users can't affect the requests of other users.
    * @param callId An arbitrary request ID, used to differentiate between different requests
    *               from the same `user`.
    * @param startTime      The unix time that the automation should start for the first time.
    * @param periodLength   The number of seconds that should have passed inbetween calls.
    */
    function everyTimePeriod(
        address user,
        uint callId,
        uint startTime,
        uint periodLength
    ) external {
        require(msg.sender == routerUserVeriForwarder, "TimeConditions: not userForw");

        uint lastExecTime = userToIdToLastExecTime[user][callId];

        // immediately execute the first time
        if (lastExecTime == 0) {
            require(block.timestamp >= startTime, "TimeConditions: not passed start");
            userToIdToLastExecTime[user][callId] = startTime;
            emit Started(user, callId);

        } else {
            uint nextExecTime = lastExecTime + periodLength;
            require(block.timestamp >= nextExecTime, "TimeConditions: too early period");
            userToIdToLastExecTime[user][callId] = nextExecTime;
        }
    }
}

Settings
{
  "evmVersion": "istanbul",
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "libraries": {
    "TimeConditions.sol": {}
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"routerUserVeriForwarder_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"callId","type":"uint256"}],"name":"Started","type":"event"},{"inputs":[{"internalType":"uint256","name":"afterTime","type":"uint256"},{"internalType":"uint256","name":"beforeTime","type":"uint256"}],"name":"betweenTimes","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"callId","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"periodLength","type":"uint256"}],"name":"everyTimePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"routerUserVeriForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userToIdToLastExecTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a060405234801561001057600080fd5b5060405161050138038061050183398101604081905261002f91610044565b60601b6001600160601b031916608052610074565b60006020828403121561005657600080fd5b81516001600160a01b038116811461006d57600080fd5b9392505050565b60805160601c61046a61009760003960008181607e015260fe015261046a6000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80632d8eaa7c14610051578063367d781414610066578063a97d542b14610079578063cc0893f1146100bd575b600080fd5b61006461005f3660046103b3565b6100f3565b005b6100646100743660046103ec565b6102c9565b6100a07f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6100e56100cb366004610389565b600060208181529281526040808220909352908152205481565b6040519081526020016100b4565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146101705760405162461bcd60e51b815260206004820152601c60248201527f54696d65436f6e646974696f6e733a206e6f742075736572466f72770000000060448201526064015b60405180910390fd5b6001600160a01b0384166000908152602081815260408083208684529091529020548061024157824210156101e75760405162461bcd60e51b815260206004820181905260248201527f54696d65436f6e646974696f6e733a206e6f74207061737365642073746172746044820152606401610167565b6001600160a01b03851660008181526020818152604080832088845282529182902086905590518681527fec650fcc375710553756d538ba0b333d528957ad95af9ec6d1a23481441dfd22910160405180910390a26102c2565b600061024d838361040e565b90508042101561029f5760405162461bcd60e51b815260206004820181905260248201527f54696d65436f6e646974696f6e733a20746f6f206561726c7920706572696f646044820152606401610167565b6001600160a01b0386166000908152602081815260408083208884529091529020555b5050505050565b814210156103195760405162461bcd60e51b815260206004820152601960248201527f54696d65436f6e646974696f6e733a20746f6f206561726c79000000000000006044820152606401610167565b804211156103695760405162461bcd60e51b815260206004820152601860248201527f54696d65436f6e646974696f6e733a20746f6f206c61746500000000000000006044820152606401610167565b5050565b80356001600160a01b038116811461038457600080fd5b919050565b6000806040838503121561039c57600080fd5b6103a58361036d565b946020939093013593505050565b600080600080608085870312156103c957600080fd5b6103d28561036d565b966020860135965060408601359560600135945092505050565b600080604083850312156103ff57600080fd5b50508035926020909101359150565b6000821982111561042f57634e487b7160e01b600052601160045260246000fd5b50019056fea2646970667358221220bc3ac876cfd7d36b1736c533d081c516e70b1c53f75f9644735ff7222b3c824464736f6c63430008060033000000000000000000000000fd16a9c765fae6d4fd28ffd9888f7a2709af0fad

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80632d8eaa7c14610051578063367d781414610066578063a97d542b14610079578063cc0893f1146100bd575b600080fd5b61006461005f3660046103b3565b6100f3565b005b6100646100743660046103ec565b6102c9565b6100a07f000000000000000000000000fd16a9c765fae6d4fd28ffd9888f7a2709af0fad81565b6040516001600160a01b0390911681526020015b60405180910390f35b6100e56100cb366004610389565b600060208181529281526040808220909352908152205481565b6040519081526020016100b4565b336001600160a01b037f000000000000000000000000fd16a9c765fae6d4fd28ffd9888f7a2709af0fad16146101705760405162461bcd60e51b815260206004820152601c60248201527f54696d65436f6e646974696f6e733a206e6f742075736572466f72770000000060448201526064015b60405180910390fd5b6001600160a01b0384166000908152602081815260408083208684529091529020548061024157824210156101e75760405162461bcd60e51b815260206004820181905260248201527f54696d65436f6e646974696f6e733a206e6f74207061737365642073746172746044820152606401610167565b6001600160a01b03851660008181526020818152604080832088845282529182902086905590518681527fec650fcc375710553756d538ba0b333d528957ad95af9ec6d1a23481441dfd22910160405180910390a26102c2565b600061024d838361040e565b90508042101561029f5760405162461bcd60e51b815260206004820181905260248201527f54696d65436f6e646974696f6e733a20746f6f206561726c7920706572696f646044820152606401610167565b6001600160a01b0386166000908152602081815260408083208884529091529020555b5050505050565b814210156103195760405162461bcd60e51b815260206004820152601960248201527f54696d65436f6e646974696f6e733a20746f6f206561726c79000000000000006044820152606401610167565b804211156103695760405162461bcd60e51b815260206004820152601860248201527f54696d65436f6e646974696f6e733a20746f6f206c61746500000000000000006044820152606401610167565b5050565b80356001600160a01b038116811461038457600080fd5b919050565b6000806040838503121561039c57600080fd5b6103a58361036d565b946020939093013593505050565b600080600080608085870312156103c957600080fd5b6103d28561036d565b966020860135965060408601359560600135945092505050565b600080604083850312156103ff57600080fd5b50508035926020909101359150565b6000821982111561042f57634e487b7160e01b600052601160045260246000fd5b50019056fea2646970667358221220bc3ac876cfd7d36b1736c533d081c516e70b1c53f75f9644735ff7222b3c824464736f6c63430008060033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000fd16a9c765fae6d4fd28ffd9888f7a2709af0fad

-----Decoded View---------------
Arg [0] : routerUserVeriForwarder_ (address): 0xfD16a9C765fAE6d4Fd28fFd9888f7a2709AF0fad

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000fd16a9c765fae6d4fd28ffd9888f7a2709af0fad


Block Transaction 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
[ 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.