Skip to content
Lattice

ChainlinkAutomationAdapterLib

Git Source

Title: ChainlinkAutomationAdapterLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Chainlink (https://github.com/smartcontractkit/chainlink-evm)

Library implementing the consumer side of Chainlink Automation (keepers) with a canonical time-interval upkeep. checkUpkeep reports true once interval seconds have elapsed; performUpkeep (gated to the configured Automation forwarder) advances the counter and resets the timer. The upkeep condition is re-validated inside performUpkeep — performData is never trusted blindly.

Functions

chainlinkAutomationAdapterStorage

Returns the ERC-7201 storage struct for ChainlinkAutomationAdapter.

function chainlinkAutomationAdapterStorage() internal pure returns (ChainlinkAutomationAdapterStorage storage $);

Returns

NameTypeDescription
$ChainlinkAutomationAdapterStorage

__ChainlinkAutomationAdapter_init

Registers the IChainlinkAutomationAdapter ERC-165 interface.

Must be called between preInitializer / postInitializer.

function __ChainlinkAutomationAdapter_init() internal;

registerInterface

Writes true to the ERC-165 map slot for IChainlinkAutomationAdapter.

function registerInterface() internal;

getForwarder

Returns the configured Automation forwarder.

function getForwarder() internal view returns (address);

Returns

NameTypeDescription
<none>address

getInterval

Returns the configured upkeep interval (seconds).

function getInterval() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256

getLastTimeStamp

Returns the timestamp of the last performed upkeep.

function getLastTimeStamp() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256

getCounter

Returns the number of upkeeps performed.

function getCounter() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256

checkUpkeep

Reports whether the upkeep should run.

Returns true once interval seconds have elapsed since the last upkeep and a forwarder has been configured. performData echoes checkData.

function checkUpkeep(bytes calldata checkData) internal view returns (bool upkeepNeeded, bytes memory performData);

Parameters

NameTypeDescription
checkDatabytesArbitrary data configured on the upkeep.

Returns

NameTypeDescription
upkeepNeededboolTrue if performUpkeep should be called.
performDatabytesThe data to pass to performUpkeep.

setConfig

Sets or replaces the Automation configuration and resets the upkeep timer.

Caller must hold DEFAULT_ADMIN_ROLE. Reverts ChainlinkAutomationInvalidConfig on a zero forwarder or zero interval.

function setConfig(address forwarder, uint256 interval) internal;

Parameters

NameTypeDescription
forwarderaddressThe Automation forwarder allowed to call performUpkeep.
intervaluint256The minimum seconds between upkeeps.

performUpkeep

Performs the upkeep. Gated to the configured forwarder.

Reverts ChainlinkAutomationNotConfigured if no forwarder is set, ChainlinkAutomationOnlyForwarder if the caller is not the forwarder, and ChainlinkAutomationConditionNotMet if the interval has not elapsed. Advances the counter, resets the timer, and emits UpkeepPerformed.

function performUpkeep(bytes calldata performData) internal;

Parameters

NameTypeDescription
performDatabytesThe data returned by checkUpkeep (unused by the reference upkeep).