Search
This guide explains how to register a Custom logic Upkeep that uses a Keepers-compatible contract. You can either register it from the Keepers App, or from within a contract that you have deployed.
Topics
Connect your wallet using the button in the top right corner and choose a network. For a list of supported networks, see the Supported Blockchain Networks section. The Chainlink Keepers App also lists the currently supported networks.
Click the Register New Upkeep button
Select the custom logic trigger
Provide the address of your Keepers-compatible contract You do not need to verify the contract on-chain, but it must be Keepers-compatible.
Complete the required details:
performGasLimit
value configured on the registry. Before the network executes your transaction on chain, it simulates the transaction. If the gas required to execute your transaction exceeds the gas limit that you specified, your transaction will not be confirmed. Developers also have the ability to update performGasLimit
for an upkeep. Consider running your function on a testnet to see how much gas it uses before you select a gas limit. This can be changed afterwards.checkUpkeep
function is simulated. Either leave this field blank or specify a hexadecimal value starting with 0x
. To learn how to make flexible upkeeps using checkData
, see the Flexible Upkeeps guide.Funding Upkeep
You should fund your contract with more LINK that you anticipate you will need. The network will not check or perform your Upkeep if your balance is too low based on current exchange rates. View the Keepers economics page to learn more about the cost of using Keepers.
ERC677 Link
Fund your Upkeep with more LINK than you anticipate you will need. The network will not check or perform your upkeep if your balance is too low based on current exchange rates. View the Keepers Economics page to learn more about the cost of using Keepers.
Testing and best practices
Follow the best practices when creating a Keepers-compatible contract and test your Upkeep on a testnet before deploying it to a mainnet.
Click Register upkeep
and confirm the transaction in MetaMask.
Your Upkeeps will be displayed in your list of Active Upkeeps. You must monitor the balance of your Upkeep. If the balance drops below the minimum balance, the Keepers Network will not perform the Upkeep. See Manage Your Upkeeps to learn how to manage your Upkeeps.
You can dynamically create and manage Upkeeps from within your own dApp. To do this you will need to keep track of the Upkeep ID as your contract will use this to subsequently interact with the Keepers registry. The following example displays a smart contract that can create an Upkeep and determine the Upkeep ID. Note your contract should be Keepers-compatible you will need ERC-677 LINK to fund the Upkeep. You can also program your Upkeep to check its own balance and fund itself by interacting with the registry.
Find the following addresses for your network:
Optionally, you can fetch the LINK address and registrar address from the intended registry at run-time.
Make sure your contract has enough ERC-677 LINK to fund the Upkeep at creation. The minimum amount is 5 LINK.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;
// UpkeepIDConsumerExample.sol imports functions from both ./KeeperRegistryInterface.sol and
// ./interfaces/LinkTokenInterface.sol
import {KeeperRegistryInterface, State, Config} from "@chainlink/contracts/src/v0.8/interfaces/KeeperRegistryInterface.sol";
import {LinkTokenInterface} from "@chainlink/contracts/src/v0.8/interfaces/LinkTokenInterface.sol";
/**
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
* THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE.
* DO NOT USE THIS CODE IN PRODUCTION.
*/
interface KeeperRegistrarInterface {
function register(
string memory name,
bytes calldata encryptedEmail,
address upkeepContract,
uint32 gasLimit,
address adminAddress,
bytes calldata checkData,
uint96 amount,
uint8 source,
address sender
) external;
}
contract UpkeepIDConsumerExample {
LinkTokenInterface public immutable i_link;
address public immutable registrar;
KeeperRegistryInterface public immutable i_registry;
bytes4 registerSig = KeeperRegistrarInterface.register.selector;
constructor(
LinkTokenInterface _link,
address _registrar,
KeeperRegistryInterface _registry
) {
i_link = _link;
registrar = _registrar;
i_registry = _registry;
}
function registerAndPredictID(
string memory name,
bytes calldata encryptedEmail,
address upkeepContract,
uint32 gasLimit,
address adminAddress,
bytes calldata checkData,
uint96 amount,
uint8 source
) public {
(State memory state, Config memory _c, address[] memory _k) = i_registry.getState();
uint256 oldNonce = state.nonce;
bytes memory payload = abi.encode(
name,
encryptedEmail,
upkeepContract,
gasLimit,
adminAddress,
checkData,
amount,
source,
address(this)
);
i_link.transferAndCall(registrar, amount, bytes.concat(registerSig, payload));
(state, _c, _k) = i_registry.getState();
uint256 newNonce = state.nonce;
if (newNonce == oldNonce + 1) {
uint256 upkeepID = uint256(
keccak256(abi.encodePacked(blockhash(block.number - 1), address(i_registry), uint32(oldNonce)))
);
// DEV - Use the upkeepID however you see fit
} else {
revert("auto-approve disabled");
}
}
}
registerAndPredictID
ParametersName | Description |
---|---|
name | Name of Upkeep |
encryptedEmail | Not in use in programmatic registration. Please specify with 0x |
upkeepContract | Address of Keepers-compatible contract that will be automated |
gasLimit | The maximum amount of gas that will be used to execute your function on-chain |
adminAddress | Address for Upkeep administrator. Upkeep administrator can fund contract. |
checkData | ABI-encoded fixed and specified at Upkeep registration and used in every checkUpkeep. Can be empty (0x) |
amount | The amount of LINK (in Wei) to fund your Upkeep. The minimum amount is 5 LINK. To fund 5 LINK please set this to 5000000000000000000 |
source | Not in use in programmatic registration. Please specify with 0 . |
Refer to the Supported Networks page to find the correct registry and registrar addresses for your contract.