This guide explains the use case for the
EthBalanceMonitor contract. This Automation contract monitors and funds Ethereum addresses that developers might need to top up frequently based on a configurable threshold. As a result, nodes are funded automatically.
After deploying the contract, developers can go to automation.chain.link to register Upkeep and run the contract. To take full advantage of the Chainlink Automation infrastructure, read all of the documentation to understand the features of Chainlink Automation.
To find other example contracts, see the Example Automation Contracts page.
EthBalanceMonitor is ownable, pauseable, and compatible with the
- Ownable: The contract has an owner address, and provides basic authorization control functions. This simplifies the implementation of user permissions and allows for transfer of ownership.
- Pauseable: This feature allows the contract to implement a pause and unpause mechanism that the contract owner can trigger.
- Compatible: The
AutomationCompatibleInterfaceis necessary to create contracts that are compatible with the Chainlink Automation Network. To learn more about the
AutomationCompatibleInterfaceand its uses and functions, read the Making Compatible Contracts guide.
You can open the contract in Remix:
Functions with an asterisk (
*) denote features that only the owner can change. Click on each function to learn more about its parameters and design patterns:
|Addresses to watch minimum balance and how much to top it up.|
|Updates the |
|Updates the global minimum period between top ups.|
|Used by |
Below are the feed functions in
|Read Function Name||Description|
|View function used in |
|Views the |
|Views the global minimum period between top ups.|
|Views addresses to watch minimum balance and how much to top it up.|
|Provides information about the specific target address, including the last time it was topped up. This function is external only.|
|The list of addresses to watch||(not applicable)|
|The minimum balances for each address||5000000000000000000 (5 ETH)|
|The amount to top up each address||5000000000000000000 (5 ETH)|
Only the owner can
setWatchList. Each of the parameters should be set with distinct requirements for each address.
|Address that requires updating in |
performUpkeep, which is a global setting.
KeeperRegistry addresses can be found on the Chainlink Automation app. However, only the owner can set a new
KeeperRegistry after deployment.
|Minimum wait period (in seconds) for addresses between funding||3600 (1 hour)|
period denotes the length of time between top ups for a specific address. This is a global setting that prevents draining of funds from the contract if the private key for an address is compromised or if a gas spike occurs. However, only the owner can set a different minimum wait period after deployment.
|List of addresses to fund (addresses must be pre-approved)|
Any address can trigger the
topUp function. This is an intentional design pattern that shows how easy it is to make an existing contract compatible with Chainlink Automation while maintaining an open interface. All validations are performed before the funding is triggered. If the conditions are not met, any attempt to top up will revert.