NEW

Chainlink Data Streams have officially launched on mainnet. Sign up for early access.

Back

Getting Started with Chainlink Automation

Chainlink Automation will reliably execute smart contract functions using a variety of triggers. Explore the examples below to see how Chainlink Automation works for each type of trigger. Before you begin, you will need an active cryptocurrency wallet such as Metamask.

  • Time-based trigger: Use a time-based trigger to execute your function according to a time schedule.
  • Custom logic trigger: Use a custom logic trigger to provide custom solidity logic that Automation Nodes evaluate (off-chain) to determine when to execute your function on-chain.
  • Log trigger: Use log data as both trigger and input.

Time-based trigger

Increment a counter every 5 minutes using our example contract.

  1. Navigate to the Chainlink Automation app and connect to Arbitrum Goerli in the top dropdown menu.

  2. If your wallet is not yet connected, do so now. You may also need to fetch Arbitrum Goerli testnet link here.

  3. Now select Register new Upkeep and select Time-based trigger.

  4. Under Target contract address, enter 0x698a3a4B0a98dda279795521Bd6f63cdBE605125. This is a simple counter contract that will just increment with each call. Source code is here.

  5. In the Contract call section, enter addInteger under Target function. In the Function inputs section, enter a number to increment by under intToAdd. Then click Next.

  6. Now specify the time schedule, for example every 5 minutes. Paste the cron expression */5 * * * * under Cron expression or select one of the example timers. Then click Next.

  7. To learn more about CRON expressions, click here.

  8. Enter an Upkeep name, your public key address under Admin Address, 500000 under Gas limit, and 0.1 under Starting balance (LINK).

  9. Click Register Upkeep.

  10. After the transaction has completed, you can view the performs for your upkeep in the upkeep details.

You have successfully automated your first time-based upkeep. To learn more about creating time-based upkeeps, read here.

Custom logic trigger

Increment a counter using custom logic stored on-chain.

  1. Navigate to the Chainlink Automation app and connect to Arbitrum Goerli in the top dropdown menu.

  2. If your wallet is not yet connected, do so now. You may also need to fetch Arbitrum Goerli testnet link here.

  3. Now select Register new Upkeep and select Custom logic trigger.

  4. Under Target contract address, enter 0xC3d3656868594db09abD410821c9F9ab9812B4d1. This contract uses logic stored on-chain and on-chain state to determine when to perform, which increments a counter. It is an example of an Automation-compatible contract and can be read here. Click Next.

  5. Enter an Upkeep name, your public key address under Admin Address, 500000 under Gas limit, and 0.1 under Starting balance (LINK).

  6. Finally, enter your public key address under Check data (Hexadecimal). This is an example of how we use checkData, which is optional static data that you can pass into your upkeep, to ensure your counter increments.

  7. Click Register Upkeep.

  8. After the transaction is complete, you can view the performs for your upkeep in the upkeep details. Your upkeep should perform once every minute and stop after 4 performs, as per the code.

You have successfully automated your first custom logic upkeep. To learn more about creating custom logic upkeeps, read here.

Log trigger

Increment an on-chain counter using a log as trigger.

  1. Navigate to the Chainlink Automation app and connect to Arbitrum Goerli in the top dropdown menu.

  2. If your wallet is not yet connected, do so now. You may also need to fetch Arbitrum Goerli testnet link here.

  3. Now select Register new Upkeep and select log logic trigger.

  4. Under Contract to automate, enter 0xcf39b55F3E583DdEc8D418dB4708A71aA8453a83. This is a simple iLogAutomation-compatible contract example that will increment a counter when a log is detected. The code is here. Click Next.

  5. Under Contract emitting logs, enter 0xeB4ABE57c2ba0A467273f9b7fDed130AD863e923. This is the contract Automation will listen to for emitted logs. The code is here. Click Next.

  6. Under Emitted log select Bump from the dropdown menu. This is the log signature Automation will look for.

  7. Log index topic filters are optional filters to narrow the logs you want to trigger your upkeep. For our example enter your public key address under addr and leave the num field empty. Later when you call the bump function to emit the log, your msg.Sender address will be emitted in the log, triggering your upkeep. Click Next.

  8. Enter an Upkeep name, your public key address under Admin Address, 500000 under Gas limit, and 0.1 under Starting balance (LINK).

  9. Click Register Upkeep and wait for it to finish.

  10. To trigger your upkeep call bump on the trigger contract by navigating to the Arbitrum Goerli scanner, connecting your wallet and executing the bump function. You can observe your upkeep's perform in the Automation dashboard.

You have sucessfully automated your first log trigger upkeep. To learn more about creating log trigger upkeeps, read here.

Supported networks and costs

For a list of blockchains that are supported by Chainlink Automation, see the Supported Networks page. To learn more about the cost of using Chainlink Automation, see the Automation Economics page.

Contact us

For help with your specific use case, contact us to connect with one of our Solutions Architects. You can also ask questions about Chainlink Automation on Stack Overflow or the #automation channel in our Discord server. Utility contracts can also help you get started quickly.

What's next

Stay updated on the latest Chainlink news