#
AutoLoop Integration - Quick Start
#
Inherit from AutoLoopCompatible.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@luckymachines/autoloop/contracts/AutoLoopCompatible.sol";
contract NumberGoUp is AutoLoopCompatible {
// ... contract code
}
#
Add required methods
function shouldProgressLoop()
external
view
returns (bool loopIsReady, bytes memory progressWithData)
{
loopIsReady = (block.timestamp - lastTimeStamp) > interval;
// pass a loop ID to avoid running the same update twice
progressWithData = bytes(abi.encode(_loopID));
}
function progressLoop(bytes calldata progressWithData) external {
// decode the data sent from shouldProgressLoop()
uint256 loopID = abi.decode(progressWithData, (uint256));
// re-check logic
if ((block.timestamp - lastTimeStamp) > interval && loopID == _loopID) {
updateNumber();
++_loopID;
}
}
#
Register AutoLoop compatible contract
Open the AutoLoop Dashboard:
#
Connect your wallet
#
Select Register Contract
#
Choose Settings and Funding Amount
#
Register Contract
#
Manage Registered Contracts