Search
This guide explains the use case for the EthBalanceMonitor
contract. This Keeper 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 keepers.chain.link to register Upkeep and run the contract. To take full advantage of the Keepers automation infrastructure, read all of the documentation to understand the features of Chainlink Keepers.
To find other example contracts, see the Example Keepers Contracts page.
Topics
EthBalanceMonitor
PropertiesEthBalanceMonitor
is ownable, pausable, and Keepers-compatible:
KeeperCompatibleInterface
is necessary to create Keepers-compatible contracts. To learn more about the KeeperCompatibleInterface
and its uses and functions, refer to Making Keepers-compatible Contracts.You can open the contract in Remix:
Note on Owner Settings
Aside from certain features listed below, only owners can withdraw funds and pause or unpause the contract. If the contract is paused or unpaused, it will affect checkUpkeep
, performUpkeep
, and topUp
functions.
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:
Function Name | Description |
---|---|
setWatchList * | Addresses to watch minimum balance and how much to top it up. |
setKeeperRegistryAddress * | Updates the KeeperRegistry address. |
setMinWaitPeriodSeconds * | Updates the global minimum period between top ups. |
topUp | Used by performUpkeep . This function will only trigger top up if conditions are met. |
Below are the feed functions in EthBalanceMonitor
:
Read Function Name | Description |
---|---|
getUnderfundedAddresses | View function used in checkUpkeep to find underfunded balances. |
getKeeperRegistryAddress | Views the KeeperRegistry address. |
getMinWaitPeriodSeconds | Views the global minimum period between top ups. |
getWatchList | Views addresses to watch minimum balance and how much to top it up. |
getAccountInfo | Provides information about the specific target address, including the last time it was topped up. This function is external only. |
setWatchList
FunctionName | Description | Suggested Setting |
---|---|---|
addresses | The list of addresses to watch | (not applicable) |
minBalancesWei | The minimum balances for each address | 5000000000000000000 (5 ETH) |
topUpAmountsWei | 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.
setKeeperRegistryAddress
FunctionName | Description |
---|---|
keeperRegistryAddress | Address that requires updating in KeeperRegistry |
Only the keeperRegistryAddress
can performUpkeep
, which is a global setting. KeeperRegistry
addresses can be found on the Keepers app. However, only the owner can set a new KeeperRegistry
after deployment.
setMinWaitPeriodSeconds
FunctionName | Description | Suggested Setting |
---|---|---|
period | 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.
topUp
FunctionName | Description |
---|---|
needsFunding | 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 Keepers-compatible 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.