Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a utility contract and a JS script for upkeep interactions. #76

Merged

Conversation

SyedAsadKazmi
Copy link
Contributor

Changes

  • Added a solidity file named as UpkeepInteractions.sol, showcasing the interaction with AutomationRegistrar and KeeperRegistry contracts, for registration of Custom Logic Upkeep and performing other operations like pause upkeep, unpause upkeep, cancel upkeep, add funds to upkeep, withdraw funds from upkeep, and edit gas limit of upkeep.

  • Added a script (upkeepInteractions.js) containing the functions to interact with the registered Custom Logic Upkeep.

Motive

Initially, I've created that as a utility contract and shared as a gist with the devs on Chainlink Discord, that are facing problems while registering and interacting with upkeep via contract.

Here are some of screenshots for the same:

Screenshot 2024-07-26 at 3 05 48 PM
Screenshot 2024-07-26 at 3 07 21 PM
Screenshot 2024-07-26 at 3 07 57 PM
Screenshot 2024-07-26 at 3 09 07 PM
Screenshot 2024-07-26 at 3 09 36 PM

So, on Bharath's suggestion, I've decided to create this PR. The contract code could possibly be added into the Register Upkeeps Programmatically section of the documentation, as it's a kind of extension of the same contract.

Kindly please review the PR, and let me know if any changes or add-ons are required from my end.

Thanks.

@andrejrakic andrejrakic self-assigned this Jul 29, 2024
Copy link
Contributor

@andrejrakic andrejrakic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great stuff, thanks for your contribution! I have couple of comments:

  • Let's make json rpc url not hardcoded to Polygon Amoy Alchemy, rather just use JSON_RPC_URL env variable. That way developers can choose their own provider and blockchain network
  • Let's make PRIVATE_KEY an env variable as well (process.env.PRIVATE_KEY), instead of having it as a string
  • Let's avoid hardcoding addresses of KeeperRegistry and LinkToken contracts for Polygon Amoy, and instead allow developers to pass those programmatically
  • Let's avoid mixing JavaScript promises and async/await syntax if possible, for example:
async function pauseUpkeep(upkeepId) {
    const tx = await keeperRegistry.pauseUpkeep(upkeepId);
    const receipt = await tx.wait();
    console.log(`Upkeep is paused successfully. Tx hash: ${receipt.hash}`);
}

@SyedAsadKazmi
Copy link
Contributor Author

Thanks for the appreciation, @andrejrakic!

I've done the changes in the new commit, as you've mentioned. Kindly please review and let me know if any further changes are required from my end.

Thanks.

@andrejrakic andrejrakic merged commit deabde8 into smartcontractkit:main Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants