I'm playing around with Chainlink's "Register an Upkeep using your own deployed contract" example: https://docs.chain.link/docs/chainlink-keepers/register-upkeep/#register-an-upkeep-using-your-own-deployed-contract
However, once the UpkeepIDConsumerExample is deployed with the Link Token Contact, Registry and Registrar parameters for the respective chain, I am unable to use the UpkeepIDConsumerExample.registerAndPredictID function as it fails.
(Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? Internal JSON-RPC error. { "code": -32000, "message": "execution reverted" })
I've tried on Rinkeby, Mumbai and Polygon Mainnet, incase testnets weren't live yet. And I've used the parameters suggested by the docs for calling the function. And I have sufficient Link in my metamask.
Is it correct to use these: https://docs.chain.link/docs/link-token-contracts/ as the Link Token Interfrace parameter?
Thanks!
I was able to make this work (though I tried only on Goerli)using the code from the offical docs that you linked to.
For the benefit of others that read this post, I will break it down into detailed steps - perhaps more than you needed for an answer!
Prerequisites
10
as the interval
-- that's 10 seconds. This way you can see the upkeep happen fast. Note this Upkeep's addressUpkeepIDConsumerExample
from the example in the docs, which is the smart contract that programmatically registers your Upkeep Contract. This contract handles registering the Upkeep Contract you deployed in Step #2 with Chainlink's Keepers network, so that the Keepers Network can automate the running of functions in your Upkeep contract. Note this Contracts AddressMaking it work
From your wallet, which should now have LINK in it, send 5 LINK to the deployed UpkeepIDConsumerExample
address. This is funding it will need to send onwards to your Upkeep (Upkeeps need funding so they can pay the Keepers Network for the compute work they do in performing the automations).
Using Remix, connect to the right network and then connect to your deployed UpkeepIDConsumerExample
contract by using its address.
When Remix shows your contract and its interactions in the DEPLOYED CONTRACTS section of the UI, fill in the parameters for the registerAndPredictID()
function using this table in the docs.
While following the table referred to above, please note:
3000000
5000000000000000000
UpkeepIDConsumerExample
's address. In this example it's the calling contract itself.run registerAndPredictID()
with the params as per the previous step. It should run successfully.
Verify by going to the Keepers App and checking under "My Upkeeps" for a new Upkeep that you just programmatically created.
Cleanup
UpkeepIDConsumerExample
has any
LINK in it (it shouldn't because the 5 LINK you sent from your wallet to this contract, was transferred when you ran registerAndPredictID()
and sent an amount of 5 LINKHope this helps!