Smart Contract Automation Explained


Smart contract automation enables developers to trigger smart contract functions in an automated way.

The utility of smart contracts continues to evolve over time. The initial wave of smart contracts were used to issue and assign rights to blockchain-based tokens. Later, developers began leveraging oracle networks to create hybrid smart contracts, which use external data and off-chain computation within on-chain applications to enable new markets such as DeFi, dynamic NFTs, and GameFi. Now, an additional piece of infrastructure is coming to the fore—smart contract automation.

This article will explore smart contract automation and the possibilities it unlocks. We start by defining smart contract automation and examine key security and cost considerations around automating smart contract execution, before highlighting the benefits of the smart contract automation tool Chainlink Automation and showcasing various use cases unlocked by Web3 automation.

If you are a developer and want to dive immediately into the code and technical components, skip to the beginner’s guide tutorial below or visit the Chainlink Automation documentation.

What Is Smart Contract Automation?

Smart contract automation allows developers to trigger smart contract functions in an automated way. These can include harvesting yield, minting NFTs, starting and stopping game rounds, triggering the liquidation of undercollateralized loans, and much more. To better understand the wide-ranging benefits of smart contract automation, let’s establish a working understanding of smart contract automation in terms of the problem it helps developers overcome.

Problem: Smart Contracts Cannot Auto-Execute

Smart contracts are deterministic programs that run on blockchains. They contain code that states, “if x event happens, then trigger y action.” However, smart contracts are not self-executing, meaning their code will not run and make state changes on a blockchain until triggered by an on-chain transaction. The external transaction serves as a “poke” to wake the smart contract up and initiate its logic, similar to how clicking a mouse can start a computer program. 

For example, a blockchain-based lending protocol cannot liquidate an under-collateralized loan until an on-chain transaction is made that calls its liquidation function. Once called, the protocol’s liquidation smart contract will verify if the loan is under-collateralized by referencing on-chain price feeds. If under-collateralized, the user’s collateral is liquidated to pay down their debt—otherwise, the transaction reverts.

In some use cases, end-users call on-chain functions directly through their own smart contract interactions. For example, when a user wants to take out a loan in a decentralized money market, their transaction to borrow tokens against their collateral directly triggers the loan issuance function to execute. This function will determine the user’s maximum loan size and then transfer borrowed tokens to their address. However, there are many instances in which smart contracts must perform on-chain functions to maintain the health and utility of the protocol—with no direct user interactions to trigger them.

Solution: Chainlink Automation as a Transaction Execution Service

“Keepers” are externally owned accounts (EOAs) that are incentivized to trigger the execution of smart contracts based on predefined conditions. Conditions are defined in jobs and submitted by a development team, DAO, or protocol users to a decentralized network, along with rewards subject to performance. Conditions for smart contract automation are generally based on time (e.g. trigger x function every day at 5:00 pm EST) or events (e.g. trigger y function only when the asset’s price crosses a certain threshold).

Decentralized automation nodes check conditions and make transactions once those predefined conditions have been satisfied. This process often involves the nodes using off-chain computation to execute the same smart contract function that it may eventually call on-chain. Once the function returns true, then the node calls that function on-chain by issuing an on-chain transaction. When the function is called, the conditions can be verified on-chain by the protocol’s smart contract before it undergoes a state change, helping ensure that the node is correct. The end result is smart contracts that only run on blockchains when needed and according to clearly defined conditions.

While the purpose of automation is relatively straightforward, it’s important to look at some of the critical technical considerations in order to understand the advantages of tools such as Chainlink Automation.

Security and Cost Considerations With Automating Smart Contract Execution

Below are some of the key security risks and cost considerations to take into account when using smart contract automation tools within your dApp.

Manual DevOps and Centralized Servers

One type of smart contract automation implementation involves running a Solidity cron job on a centralized server or having a development team manually monitor conditions and make on-chain transactions. In such a setup, the automation node becomes a centralized point of failure that introduces risk around the untimely execution of smart contract functions (e.g. downtime or delays). Smart contracts that don’t execute when required can lead to asymmetrical exploits and missed opportunities, such as trade slippage, protocol insolvency, and the loss of user funds. 

Manual developer operations (DevOps) also place demands on projects’ limited time and resources, which could otherwise go to core product development and ecosystem expansion. Manual DevOps are also likely to become more burdensome over time as projects seek to simplify user experience and add advanced utility to their dApps through smart contract automation. In the end, smart contracts need to be decentralized end to end, including the off-chain automation infrastructure responsible for triggering their execution.

Costly and Unpredictable Bounties

Another way to design smart contract automation systems is by offering bounties, with a financial reward allotted to the first node to call an on-chain function when certain conditions are met. While this method improves upon the centralized automation model, it introduces challenges around cost-efficiency, centralization, and unpredictability. For example, the incentive system used in one of the first decentralized automation solutions, the Ethereum Alarm Clock, meant that it was possible that transactions would not be executed at all.

The primary issue with bounties is that nodes end up engaging in direct competition for the winner-takes-all reward, driving priority gas auction (PGA) bidding wars. Competing nodes will keep raising the gas price they’re willing to pay in order to incentivize miners to process their transactions first. Because the smart contract function can only be called once after its conditions are met, only the first node succeeds and gets paid for its work. Every other node is unsuccessful and incurs a loss when its transaction fails as compensation for gas consumption is not issued. Since most automation job costs involve a base cost plus a gas fee, PGAs lead to increased costs for end-users, who have to cover the higher gas fees. 

Smart contract automation implementations designed around public bounties also fuel several other unintended consequences. For one, PGAs can increase network congestion on blockchains, driving even higher gas prices for nodes and everyone else on the network. Additionally, competition can result in the number of nodes naturally reducing over time to a select few well-capitalized actors who submit aggressive gas prices. Centralized automation networks decrease reliability by reducing the number of nodes monitoring and submitting transactions. 

Another risk with public bounties is that the smart contract has no direct commitment from the node to provide timely service. This introduces a level of uncertainty, especially during periods of extreme market volatility and network congestion when automation is needed most. For example, lending protocols that don’t liquidate toxic positions can become insolvent if the small set of competitive nodes don’t act on time because gas prices are too high, their gas funds run out, or they become preoccupied with other activities.

The takeaway from these designs is that automation networks need to perform smart contract automation in a cost-effective, tamper-proof, and highly available manner.

Chainlink Automation: Decentralized, Low-Cost, and Reliable Smart Contract Automation

Instead of relying on centralized setups or taking a risk on competitive public bounties, projects can outsource their smart contract execution to Chainlink Automation—a decentralized smart contract automation tool with a proven track record of hyper-reliability and incentive alignment. Chainlink Automation is already running live on Avalanche, BNB Chain, Ethereum, and Polygon, with support for many more chains to be added in the future.

Some of the benefits of the Chainlink Automation service include:

  • Incentivized Jobs—Chainlink Automation offers a simple framework where users can clearly outline jobs and rewards that a decentralized network of Chainlink nodes commits to, removing competition and creating predictable financial incentives.
  • High Uptime—Chainlink Automation is run by the same professional DevOps teams and enterprises that have a verifiable history of reliability during extreme network congestion and market volatility. Chainlink Automation nodes already help secure $80+ billion dollars in smart contract value across other Chainlink services (e.g. Price Feeds).
  • Low Cost—Chainlink Automation has several gas-optimizing features that lower the costs of dApp automation, including a rotating node selection process to prevent PGA wars and stabilize costs for users. 
  • Decentralized Execution—Chainlink leverages a decentralized and transparent pool of nodes for strong guarantees around secure and timely smart contract execution, saving teams time and mitigating manual intervention or centralized server risks.
  • Increased Utility—Chainlink Automation can perform advanced off-chain computation and generate calldata that’s verifiable by smart contracts, allowing developers to build advanced functionality that was not possible before and without any additional trust assumptions.
  • Seamless Integration—Chainlink Automation can be integrated in a matter of hours to trigger smart contracts, with developers provided with simple documentation and step-by-step setup guides.

Smart Contract Automation Use Cases

Below are just a few of the many smart contract use cases enabled by Chainlink Automation, including liquidity management, DEX limit orders, dynamic NFTs, and more. There are a plethora of other use cases still yet to be created that are waiting on innovative and creative developers to pioneer.

Automated Yield Harvesting and Debt Repayment

Alchemix is a self-repaying lending protocol that integrated Chainlink Automation to harvest yield generated by users’ collateral on a daily basis. The yield is then used to repay portions of the debt created by loans without any manual input or developer overhead required.

Decentralized Rebasing of Elastic Supply Tokens

COTI is using Chainlink Automation to rebase the supply of a volatility token pegged to the Crypto Volatility Index (CVI) each day at midnight UTC time. This establishes stronger assurances that the tokens remain pegged to the underlying CVI index in a fully decentralized manner. 

Optimal Rebalancing of Liquidity Provisions

Visor Finance is a management protocol for Uniswap v3 liquidity providers (LPs) that aims to optimize yield returns. Visor Finance uses Chainlink Automation to reinvest earned fees and new capital deposits into active liquidity positions and single asset limit orders when certain predefined thresholds are crossed. The end result is LPs being able to maintain high asset utilization via efficiently and timely deployed capital. 

Minting of Limited-Edition NFTs When Specific Events Happen

The Curse NFT is a dynamic NFT art project that displays positive or negative 3D renderings of model Krystal Schott based on the price movement of ETH. The Curse NFT is using Chainlink Automation to trigger the NFT to display its final “blessed” form should the price of ETH ever reach $20K USD.

Time-Based Smart Contract Automation

NFT-based strategy game Planet IX is using Chainlink Automation on Polygon for time-based smart contract automation of its weekly drawings. This helps provide users with stronger guarantees that the draw will start and stop on time and without disruption. Now, developers can create an Avalanche, BNB Chain, Fantom, or Ethereum time-based smart contract using Chainlink Automation. Visit the docs to see how to trigger a transaction with smart contract automation.

Starting, Stopping, or Settling Games or Rounds

Chainlink Automation can be used to periodically trigger smart contract start and settlement functions to help execute games or rounds at predefined intervals. Without a smart contract automation tool, developers would need to manually trigger the smart contract functions responsible for starting and stopping the rounds.

Triggering DEX Limit Orders

Decentralized exchanges need smart contract automation tools to enable users to set limit orders on the platform and unlock a more seamless user experience. Chainlink Automation can monitor on-chain conditions to automatically trigger limit orders when a certain price is reached.

Automated On-Chain Payments

The Chainlink Automation Network can monitor predefined conditions and trigger on-chain payments when those conditions are met, helping to facilitate an automated on-chain payments workflow.

Triggering Automated Rewards Distribution

Chainlink Automation nodes can trigger the release of locked or vested assets on a regular basis according to predefined schedules, helping projects utilize a transparent token vesting mechanism.

Timely Liquidations on Decentralized Money Markets

Chainlink Automation can monitor the health of user loans on decentralized money markets by consistently checking if the collateralization ratio of open loans has dropped below the predefined liquidation threshold. If a user’s borrow transaction is found to be undercollateralized, Chainlink Automation can call the money market’s liquidation function, helping ensure that the protocol remains solvent.

Automated Dynamic NFT Updates

Dynamic NFTs evolve in response to external data relayed by oracles. The Chainlink Automation Network can trigger dynamic NFT updates when certain conditions change and help unlock increasingly sophisticated art projects, fan experiences, gaming assets, and more.

Automated DAO Governance Processes

Decentralized governance processes often require manual execution, introducing centralization risks into the management of the organization. Chainlink Automation can help decentralize governance processes by automatically triggering treasury updates and contributor payments, relaying off-chain governance votes on-chain, and more.

Chainlink Automation enables a wide array of use cases including harvesting and auto-compounding yield, starting and stopping prediction rounds, setting limit orders, and more
Chainlink Automation enables a wide array of use cases including harvesting and auto-compounding yield, starting and stopping prediction rounds, setting limit orders, and more.

How to Start Creating an Automated dApp With Chainlink Automation

Follow this technical guide to learn how to automate smart contracts with Chainlink Automation. You’ll learn how to deploy an Automation-compatible contract, how to register an Upkeep, and more.

If you want to start building hybrid smart contract applications today and need some type of external data or computation, refer to the documentation to learn how to trigger smart contract functions, ask a technical question in Discord, or set up a call with an expert.

Learn more about blockchain technology

Get the latest Chainlink content straight to your inbox.