diff --git a/hardhat.config.ts b/hardhat.config.ts index 621a97da285..b5f2141bddd 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -20,6 +20,7 @@ const config: HardhatUserConfig = { { version: "0.8.6" }, { version: "0.8.16" }, { version: "0.8.19" }, + { version: "0.8.20" }, ], }, } diff --git a/public/samples/Automation/tutorials/EthBalanceMonitor.sol b/public/samples/Automation/tutorials/EthBalanceMonitor.sol index 79a463acce8..16a07d8ca1d 100644 --- a/public/samples/Automation/tutorials/EthBalanceMonitor.sol +++ b/public/samples/Automation/tutorials/EthBalanceMonitor.sol @@ -2,9 +2,9 @@ pragma solidity ^0.8.7; -import {ConfirmedOwner} from "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol"; -import {AutomationCompatibleInterface} from "@chainlink/contracts/src/v0.8/automation/interfaces/AutomationCompatibleInterface.sol"; -import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol"; +import "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol"; +import "@chainlink/contracts/src/v0.8/automation/interfaces/AutomationCompatibleInterface.sol"; +import "@openzeppelin/contracts/security/Pausable.sol"; /** * @title The EthBalanceMonitor contract @@ -29,14 +29,14 @@ contract EthBalanceMonitor is event FundsWithdrawn(uint256 amountWithdrawn, address payee); event TopUpSucceeded(address indexed recipient); event TopUpFailed(address indexed recipient); - event KeeperRegistryAddressUpdated(address oldAddress, address newAddress); + event ForwarderAddressUpdated(address oldAddress, address newAddress); event MinWaitPeriodUpdated( uint256 oldMinWaitPeriod, uint256 newMinWaitPeriod ); error InvalidWatchList(); - error OnlyKeeperRegistry(); + error OnlyForwarder(); error DuplicateAddress(address duplicate); struct Target { @@ -46,20 +46,15 @@ contract EthBalanceMonitor is uint56 lastTopUpTimestamp; // enough space for 2 trillion years } - address private s_keeperRegistryAddress; + address private s_forwarderAddress; uint256 private s_minWaitPeriodSeconds; address[] private s_watchList; mapping(address => Target) internal s_targets; /** - * @param keeperRegistryAddress The address of the Chainlink Automation registry contract * @param minWaitPeriodSeconds The minimum wait period for addresses between funding */ - constructor( - address keeperRegistryAddress, - uint256 minWaitPeriodSeconds - ) ConfirmedOwner(msg.sender) { - setKeeperRegistryAddress(keeperRegistryAddress); + constructor(uint256 minWaitPeriodSeconds) ConfirmedOwner(msg.sender) { setMinWaitPeriodSeconds(minWaitPeriodSeconds); } @@ -193,7 +188,7 @@ contract EthBalanceMonitor is */ function performUpkeep( bytes calldata performData - ) external override onlyKeeperRegistry whenNotPaused { + ) external override onlyForwarder whenNotPaused { address[] memory needsFunding = abi.decode(performData, (address[])); topUp(needsFunding); } @@ -220,17 +215,14 @@ contract EthBalanceMonitor is } /** - * @notice Sets the Chainlink Automation registry address + * @notice Sets the upkeep's unique forwarder address + * for upkeeps in Automation versions 2.0 and later + * https://docs.chain.link/chainlink-automation/guides/forwarder */ - function setKeeperRegistryAddress( - address keeperRegistryAddress - ) public onlyOwner { - require(keeperRegistryAddress != address(0)); - emit KeeperRegistryAddressUpdated( - s_keeperRegistryAddress, - keeperRegistryAddress - ); - s_keeperRegistryAddress = keeperRegistryAddress; + function setForwarderAddress(address forwarderAddress) public onlyOwner { + require(forwarderAddress != address(0)); + emit ForwarderAddressUpdated(s_forwarderAddress, forwarderAddress); + s_forwarderAddress = forwarderAddress; } /** @@ -242,14 +234,14 @@ contract EthBalanceMonitor is } /** - * @notice Gets the Chainlink Automation registry address + * @notice Gets the forwarder address of the Chainlink Automation upkeep */ - function getKeeperRegistryAddress() + function getForwarderAddress() external view - returns (address keeperRegistryAddress) + returns (address forwarderAddress) { - return s_keeperRegistryAddress; + return s_forwarderAddress; } /** @@ -304,9 +296,9 @@ contract EthBalanceMonitor is _unpause(); } - modifier onlyKeeperRegistry() { - if (msg.sender != s_keeperRegistryAddress) { - revert OnlyKeeperRegistry(); + modifier onlyForwarder() { + if (msg.sender != s_forwarderAddress) { + revert OnlyForwarder(); } _; } diff --git a/public/samples/Automation/tutorials/VRFSubscriptionBalanceMonitor.sol b/public/samples/Automation/tutorials/VRFSubscriptionBalanceMonitor.sol index cccffbaac69..557595d630b 100644 --- a/public/samples/Automation/tutorials/VRFSubscriptionBalanceMonitor.sol +++ b/public/samples/Automation/tutorials/VRFSubscriptionBalanceMonitor.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.6; +pragma solidity 0.8.20; +import "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol"; import "@chainlink/contracts/src/v0.8/automation/interfaces/KeeperCompatibleInterface.sol"; -import {ConfirmedOwner} from "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol"; -import {VRFCoordinatorV2Interface} from "@chainlink/contracts/src/v0.8/vrf/interfaces/VRFCoordinatorV2Interface.sol"; -import {LinkTokenInterface} from "@chainlink/contracts/src/v0.8/shared/interfaces/LinkTokenInterface.sol"; -import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol"; +import "@chainlink/contracts/src/v0.8/vrf/interfaces/VRFCoordinatorV2Interface.sol"; +import "@chainlink/contracts/src/v0.8/shared/interfaces/LinkTokenInterface.sol"; +import "@openzeppelin/contracts/security/Pausable.sol"; /** * @title The VRFSubscriptionBalanceMonitor contract. @@ -26,7 +26,7 @@ contract VRFSubscriptionBalanceMonitor is event FundsWithdrawn(uint256 amountWithdrawn, address payee); event TopUpSucceeded(uint64 indexed subscriptionId); event TopUpFailed(uint64 indexed subscriptionId); - event KeeperRegistryAddressUpdated(address oldAddress, address newAddress); + event ForwarderAddressUpdated(address oldAddress, address newAddress); event VRFCoordinatorV2AddressUpdated( address oldAddress, address newAddress @@ -40,6 +40,7 @@ contract VRFSubscriptionBalanceMonitor is error InvalidWatchList(); error OnlyKeeperRegistry(); + error OnlyForwarder(); error DuplicateSubcriptionId(uint64 duplicate); struct Target { @@ -49,7 +50,7 @@ contract VRFSubscriptionBalanceMonitor is uint56 lastTopUpTimestamp; } - address public s_keeperRegistryAddress; // the address of the keeper registry + address public s_forwarderAddress; // the address of the upkeep's forwarder uint256 public s_minWaitPeriodSeconds; // minimum time to wait between top-ups uint64[] public s_watchList; // the watchlist on which subscriptions are stored mapping(uint64 => Target) internal s_targets; @@ -57,18 +58,18 @@ contract VRFSubscriptionBalanceMonitor is /** * @param linkTokenAddress the Link token address * @param coordinatorAddress the address of the vrf coordinator contract - * @param keeperRegistryAddress the address of the keeper registry contract + * @param forwarderAddress the address of the upkeep's forwarder * @param minWaitPeriodSeconds the minimum wait period for addresses between funding */ constructor( address linkTokenAddress, address coordinatorAddress, - address keeperRegistryAddress, + address forwarderAddress, uint256 minWaitPeriodSeconds ) ConfirmedOwner(msg.sender) { setLinkTokenAddress(linkTokenAddress); setVRFCoordinatorV2Address(coordinatorAddress); - setKeeperRegistryAddress(keeperRegistryAddress); + setForwarderAddress(forwarderAddress); setMinWaitPeriodSeconds(minWaitPeriodSeconds); } @@ -218,7 +219,7 @@ contract VRFSubscriptionBalanceMonitor is */ function performUpkeep( bytes calldata performData - ) external override onlyKeeperRegistry whenNotPaused { + ) external override onlyForwarder whenNotPaused { uint64[] memory needsFunding = abi.decode(performData, (uint64[])); topUp(needsFunding); } @@ -261,17 +262,14 @@ contract VRFSubscriptionBalanceMonitor is } /** - * @notice Sets the keeper registry address. + * @notice Sets the upkeep's unique forwarder address + * for upkeeps in Automation versions 2.0 and later + * https://docs.chain.link/chainlink-automation/guides/forwarder */ - function setKeeperRegistryAddress( - address keeperRegistryAddress - ) public onlyOwner { - require(keeperRegistryAddress != address(0)); - emit KeeperRegistryAddressUpdated( - s_keeperRegistryAddress, - keeperRegistryAddress - ); - s_keeperRegistryAddress = keeperRegistryAddress; + function setForwarderAddress(address forwarderAddress) public onlyOwner { + require(forwarderAddress != address(0)); + emit ForwarderAddressUpdated(s_forwarderAddress, forwarderAddress); + s_forwarderAddress = forwarderAddress; } /** @@ -327,9 +325,9 @@ contract VRFSubscriptionBalanceMonitor is _unpause(); } - modifier onlyKeeperRegistry() { - if (msg.sender != s_keeperRegistryAddress) { - revert OnlyKeeperRegistry(); + modifier onlyForwarder() { + if (msg.sender != s_forwarderAddress) { + revert OnlyForwarder(); } _; } diff --git a/src/content/quickstarts/eth-balance-monitor.mdx b/src/content/quickstarts/eth-balance-monitor.mdx index 94d9525a8ca..562fba2cce8 100644 --- a/src/content/quickstarts/eth-balance-monitor.mdx +++ b/src/content/quickstarts/eth-balance-monitor.mdx @@ -15,7 +15,7 @@ Some smart contract applications require you to maintain a certain Ethereum bala This Automation contract monitors and funds Ethereum addresses that developers might need to top up frequently based on a configurable threshold. You will deploy this example monitor contract and use the [automation.chain.link](https://automation.chain.link/) interface to register an upkeep and run the contract. To learn the basics about Chainlink Automation, read the [Chainlink Automation Overview](/chainlink-automation). -For this example, use the Polygon Mumbai testnet to simplify access to testnet funds. You will top up an address with a specific amount of testnet MATIC. Later, you can use another EVM-compatible network of your choice. +For this example, use the Ethereum Sepolia testnet to simplify access to testnet funds. You will top up an address with a specific amount of testnet ETH. Later, you can use another EVM-compatible network of your choice. ## Before you begin @@ -24,8 +24,8 @@ Before you start this tutorial, complete the following items: - If you are new to smart contract development, learn how to [Deploy Your First Smart Contract](/quickstarts/deploy-your-first-contract). - Set up a cryptocurrency wallet such as [MetaMask](https://metamask.io/). - Fund your wallet with the following testnet tokens: - - Get testnet MATIC from [faucet.polygon.technology](https://faucet.polygon.technology) to pay for your onchain transactions. - - Get at least 2 ERC-677 testnet LINK from [faucets.chain.link/mumbai](https://faucets.chain.link/mumbai). + - Get testnet ETH from [faucet.polygon.technology](https://faucet.polygon.technology) to pay for your onchain transactions. + - Get ERC-677 testnet LINK from [faucets.chain.link/fuji](https://faucets.chain.link/fuji). ## Steps to implement @@ -40,20 +40,21 @@ Before you start this tutorial, complete the following items: 1. On the **Deploy & Run Transactions** tab in Remix, set your Environment to Injected Provider and allow Remix to connect to MetaMask. -1. The constructor requires a `keeperRegistryAddress` value and a `minWaitPeriodSeconds` value. Specify these in the **Deploy** fields in Remix. You can find these registry addresses on the Automation [Supported Networks](/chainlink-automation/overview/supported-networks) page. For this example using Polygon Mumbai, enter the following values: +1. The constructor requires a `minWaitPeriodSeconds` value. Specify this in the **Deploy** fields in Remix. For this example using Ethereum Sepolia, enter the following value: - - **keeperRegistryAddress**: `0xE16Df59B887e3Caa439E0b29B42bA2e7976FD8b2` - **minWaitPeriodSeconds**: `60` 1. Click **Transact** to deploy the contract with the defined constructor settings and accept the transaction in MetaMask. After the contract is deployed, it will appear in your **Deployed Contracts** list with several functions available to configure. -1. Use metamask to Send 0.001 MATIC to your contract address. The funds are used to top-up other contracts with MATIC. See the [Fund Your Contracts](/resources/fund-your-contract?parent=automation) page to learn how to find your contract address and send funds to those contracts. For this example, 0.001 MATIC is sufficient for demonstration purposes. In a production environment, you might store a larger amount of funds in the contract so Chainlink Automation can automatically distribute them to several different addresses as they are needed over time. + Note: You will come back and set your forwarder address later. This forwarder address becomes available after you create your upkeep. + +1. Use MetaMask to Send 0.001 ETH to your contract address. The funds are used to top-up other contracts with ETH. See the [Fund Your Contracts](/resources/fund-your-contract?parent=automation) page to learn how to find your contract address and send funds to those contracts. For this example, 0.001 ETH is sufficient for demonstration purposes. In a production environment, you might store a larger amount of funds in the contract so Chainlink Automation can automatically distribute them to several different addresses as they are needed over time. -Before your contract will fund an address, you must set the `watchList` address array with `minBalancesWei` and `topUpAmmountsWei` variables. For this example on Polygon Mumbai, you are using testnet MATIC instead of wei (ETH). For demonstration purposes, you configure your own wallet as the top-up address. This makes it easy to see the MATIC being sent as part of the automated top-up function. After you complete this tutorial, you can configure any wallet or contract address that you want to keep funded. +Before your contract will fund an address, you must set the `watchList` address array with `minBalancesWei` and `topUpAmountsWei` variables. For demonstration purposes, you configure your own wallet as the top-up address. This makes it easy to see the ETH being sent as part of the automated top-up function. After you complete this tutorial, you can configure any wallet or contract address that you want to keep funded. 1. In the list of functions for your deployed contract, run the `setWatchList` function. This function requires an `addresses` array, a `minBalancesWei` array that maps to the addresses, and a `topUpAmountsWei` array that also maps to the addresses. In Remix, arrays require brackets and quotes around both addresses and integer values. For this example, set the following values: @@ -61,7 +62,7 @@ Before your contract will fund an address, you must set the `watchList` address - **minBalancesWei**: `["100000000000000000000"]` - **topUpAmountsWei**: `["000100000000000000"]` - These values tell the top up contract to top up the specified address with 0.0001 MATIC if the address balance is less than 100 MATIC. These settings are intended to demonstrate the example using testnet faucet funds. For a production application, you might set more reasonable values that top up a smart contract with 10 MATIC if the balance is less than 1 MATIC. + These values tell the top up contract to top up the specified address with 0.0001 ETH if the address balance is less than 100 ETH. These settings are intended to demonstrate the example using testnet faucet funds. For a production application, you might set more reasonable values that top up a smart contract with 10 ETH if the balance is less than 1 ETH. 1. After you configure the function values, click **transact** to run the function. MetaMask asks you to confirm the transaction. @@ -89,21 +90,25 @@ Now that the contract is deployed, funded, and configured, register the upkeep a 1. Click **Register Upkeep** to complete the registration process. -Now that you've registered the upkeep, Chainlink Automation handles the rest of the process. +1. Go to the **Upkeep details** page and copy your **Forwarder address**. + +1. Navigate back to Remix and find the `setForwarderAddress` function. Paste your forwarder address and click click **transact** to run the function. MetaMask asks you to confirm the transaction. + +Now that you've registered the upkeep and configured your contract with your new upkeep's forwarder address, Chainlink Automation handles the rest of the process. -The upkeep runs the `checkUpkeep` function in your contract, which checks the balances of all addresses in the `watchList` against their defined limits. If any of the addresses are below their specified minimum balances, the upkeep runs the `topUp` function for that specific address, which distributes the MATIC in your contract to that address. Unless your wallet happens to have more than 100 testnet MATIC, you will receive MATIC in your wallet every 60 seconds as defined by `minWaitPeriodSeconds` in your contract. Check to make sure the example is running correctly: +The upkeep runs the `checkUpkeep` function in your contract, which checks the balances of all addresses in the `watchList` against their defined limits. If any of the addresses are below their specified minimum balances, the upkeep runs the `topUp` function for that specific address, which distributes the ETH in your contract to that address. Unless your wallet happens to have more than 100 testnet ETH, you will receive ETH in your wallet every 60 seconds as defined by `minWaitPeriodSeconds` in your contract. Check to make sure the example is running correctly: 1. Go to [automation.chain.link](https://automation.chain.link/), view your new upkeep, and confirm that it is performing upkeeps in the **History** list. -1. View your contract address and your wallet address at [mumbai.polygonscan.com](https://mumbai.polygonscan.com/) to see the transactions happening between your contract and your wallet address. +1. View your contract address and your wallet address at the [Sepolia block explorer](https://sepolia.etherscan.io/) to see the transactions happening between your contract and your wallet address. -The example continues to run until your upkeep runs out of LINK, your contract runs out of MATIC, or until you manually pause or cancel the upkeep. +The example continues to run until your upkeep runs out of LINK, your contract runs out of ETH, or until you manually pause or cancel the upkeep. -After you are done with this example, you can run the `withdraw` function on your contract to withdraw any remaining testnet MATIC so you can use it later. Also, you can cancel your upkeep in the Automation UI and withdraw any remaining unspent LINK. +After you are done with this example, you can run the `withdraw` function on your contract to withdraw any remaining testnet ETH so you can use it later. Also, you can cancel your upkeep in the Automation UI and withdraw any remaining unspent LINK. @@ -127,7 +132,7 @@ Functions with an asterisk (`*`) denote features that only the owner can change. | Function Name | Description | | ---------------------------- | -------------------------------------------------------------------------------------- | | `setWatchList`\* | Addresses to watch minimum balance and how much to top it up. | -| `setKeeperRegistryAddress`\* | Updates the `KeeperRegistry` address. | +| `setForwarderAddress`\* | Updates your upkeep's forwarder address, which is available after you create your upkeep. | | `setMinWaitPeriodSeconds`\* | Updates the global minimum period between top ups. | | `topUp` | Used by `performUpkeep`. This function will only trigger top up if conditions are met. | @@ -136,7 +141,7 @@ 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. | +| `getForwarderAddress` | Views the upkeep's forwarder 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_. | @@ -153,15 +158,15 @@ Below are the feed functions in `EthBalanceMonitor`: Only the owner can `setWatchList`. Each of the parameters should be set with distinct requirements for each address. -### `setKeeperRegistryAddress` Function +### `setForwarderAddress` Function #### Parameters | Name | Description | | ----------------------- | -------------------------------------------------- | -| `keeperRegistryAddress` | Address that requires updating in `KeeperRegistry` | +| `forwarderAddress` | Unique forwarder address used to secure your upkeep | -Only the `keeperRegistryAddress` can `performUpkeep`, which is a _global setting_. `KeeperRegistry` addresses can be found on the [Chainlink Automation app](https://automation.chain.link/). However, only the owner can set a new `KeeperRegistry` after deployment. +Only the `forwarderAddress` can `performUpkeep`. Your upkeep's forwarder address can be found on the [Chainlink Automation app](https://automation.chain.link/) after you create the upkeep. Only the owner can set a new `forwarderAddress` after deployment. ### `setMinWaitPeriodSeconds` Function diff --git a/src/content/quickstarts/functions-demo-app.mdx b/src/content/quickstarts/functions-demo-app.mdx index 882e6d77d82..2a7ab56aabe 100644 --- a/src/content/quickstarts/functions-demo-app.mdx +++ b/src/content/quickstarts/functions-demo-app.mdx @@ -9,6 +9,11 @@ requires: "Wallet with gas token & ERC-677 LINK" import { Aside } from "@components" + + ## Overview The [Chainlink Functions Demo App](https://github.com/smartcontractkit/chainlink-functions-demo-app) is designed to run on the Mumbai testnet (Polygon). It uses [Chainlink Functions](/chainlink-functions). The functionality allows users to donate MATIC to their favorite GitHub creators. Authors of those repositories can then claim their donations. Donations are made in an amount of MATIC per amount of Stars the repository has. diff --git a/src/content/quickstarts/giveaway.mdx b/src/content/quickstarts/giveaway.mdx index 2999c1851df..67ae6cd362c 100644 --- a/src/content/quickstarts/giveaway.mdx +++ b/src/content/quickstarts/giveaway.mdx @@ -46,8 +46,7 @@ Before you start this tutorial, complete the following items: - Set up a cryptocurrency wallet such as [MetaMask](https://metamask.io/). - Fund your wallet with the following testnet tokens: - - Get testnet MATIC from [faucet.polygon.technology](https://faucet.polygon.technology) to pay for your onchain transactions. - - Request ERC-677 testnet LINK from [faucets.chain.link/mumbai](https://faucets.chain.link/mumbai). You will need [at least 5.1 LINK](#required-balance-amounts) to set up each giveaway with this app. + - Request ERC-677 testnet LINK and Sepolia ETH from [faucets.chain.link/sepolia](https://faucets.chain.link/sepolia). You will need [at least 5.1 LINK](#required-balance-amounts) to set up each giveaway with this app. ## Steps to implement @@ -67,11 +66,10 @@ git clone https://github.com/smartcontractkit/quickstart-giveaway.git The recommended networks for this app are: -- Polygon mainnet and Mumbai testnet +- Ethereum mainnet and Sepolia testnet -For demo purposes, use Polygon Mumbai for this tutorial. Create a block explorer API key to verify contracts on your preferred network: +For demo purposes, use Sepolia for this tutorial. Create a block explorer API key to verify contracts on your preferred network: -- [Polygonscan](https://docs.polygonscan.com/getting-started/viewing-api-usage-statistics) - [Etherscan](https://docs.etherscan.io/getting-started/viewing-api-usage-statistics) @@ -82,11 +80,11 @@ For demo purposes, use Polygon Mumbai for this tutorial. Create a block explorer - The RPC URL for your deployment network, using an [RPC node provider](https://ethereum.org/en/developers/docs/nodes-and-clients/nodes-as-a-service/) such as [Infura](https://www.infura.io/) or [Alchemy](https://www.alchemy.com/). - The private key for your deployer account. If your deployer account is in MetaMask, [export your private key from MetaMask](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key). - - The block explorer API key from Etherscan or Polygonscan that you [created earlier](#create-a-block-explorer-api-key). + - The block explorer API key from Etherscan that you [created earlier](#create-a-block-explorer-api-key). | Parameter | Description | Example | | ----------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------ | - | `NETWORK_RPC_URL` | The RPC URL for the network you want to deploy to. | `https://polygon-mumbai.g.alchemy.com/v2/your-api-key` | + | `NETWORK_RPC_URL` | The RPC URL for the network you want to deploy to. | `https://eth-sepolia.g.alchemy.com/v2/your-api-key` | | `PRIVATE_KEY` | The private key of the account you want to deploy from.
Add `0x` before your key. | `0xabc123abc123abc123abc123abc123...` | | `EXPLORER_KEY` | The block explorer API key needed for contract verification. | `ABC123ABC123ABC123ABC123ABC123ABC1` | @@ -198,11 +196,11 @@ $ make deploy Save the deployed contract address from your terminal output. This is the giveaway contract manager address that you will need when you [run the UI](#run-and-view-the-ui). Scroll up in the terminal output and look for your contract address, which appears shortly after the `Success` message: ```shell -##### mumbai -✅ [Success]Hash: 0x6feb039ea7533c2ad1b385d73370a38ccb330f76360dfa1444b26c8ba57c6e0a -Contract Address: 0x97fD95333b827dae8c58BC74394Cc8E7d83fDEbA -Block: 40656570 -Paid: 0.01104793954 ETH (5469277 gas * 2.02 gwei) +##### sepolia +✅ [Success]Hash: 0x050ec798d7205c41bafa91029fcdd30104b99c17003a59ac033099dbe47d3658 +Contract Address: 0xA168A5eAd28d5E4C1C9cEaF6492a0F9D715ea8D8 +Block: 5727377 +Paid: 0.005473916599834344 ETH (5470873 gas * 1.000556328 gwei) ``` @@ -236,15 +234,15 @@ Set environment variables to run the UI and then view it locally. | Item | Value | | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `UI_GIVEAWAY_MANAGER_CONTRACT_ADDRESS` | The address of the Giveaway Contract Manager contract that you [deployed earlier](#deploy-contract) | - | `UI_LINK_TOKEN_CONTRACT_ADDRESS` | For Polygon Mumbai:
See all [LINK token contract addresses](/resources/link-token-contracts) | - | `UI_KEEPER_REGISTRY_CONTRACT_ADDRESS` | For Polygon Mumbai:
This app currently supports Automation v1.2. See all [Automation registry contract addresses](/chainlink-automation/overview/supported-networks/) | + | `UI_LINK_TOKEN_CONTRACT_ADDRESS` | For Ethereum Sepolia:
See all [LINK token contract addresses](/resources/link-token-contracts) | + | `UI_KEEPER_REGISTRY_CONTRACT_ADDRESS` | For Ethereum Sepolia:
This app currently supports Automation v1.2. See all [Automation registry contract addresses](/chainlink-automation/overview/supported-networks/) | 1. Navigate to the `/client/packages/ui` directory, and run these commands to set up your UI environment variables. Do not use quotes to assign values: ```bash # /client/packages/ui export UI_GIVEAWAY_MANAGER_CONTRACT_ADDRESS= - export UI_LINK_TOKEN_CONTRACT_ADDRESS= - export UI_KEEPER_REGISTRY_CONTRACT_ADDRESS= + export UI_LINK_TOKEN_CONTRACT_ADDRESS=0x779877A7B0D9E8603169DdbD7836e478b4624789 + export UI_KEEPER_REGISTRY_CONTRACT_ADDRESS=0xE16Df59B887e3Caa439E0b29B42bA2e7976FD8b2 ``` 1. After setting the environment variables, run the UI locally: ```bash diff --git a/src/content/quickstarts/pass-cost-to-end-user.mdx b/src/content/quickstarts/pass-cost-to-end-user.mdx index 8bb79111c76..a480b4dc6d9 100644 --- a/src/content/quickstarts/pass-cost-to-end-user.mdx +++ b/src/content/quickstarts/pass-cost-to-end-user.mdx @@ -7,7 +7,7 @@ time: "30 minutes" requires: "Wallet with gas token & ERC-677 LINK" --- -import { Accordion, Aside, ClickToZoom } from "@components" +import { Accordion, Aside, ClickToZoom, CopyText } from "@components" import { TabsContent } from "@components/Tabs" ## Objective @@ -158,7 +158,7 @@ This gives you an existing [Foundry](https://github.com/foundry-rs/foundry) proj | Parameter | Description | Example | | -------------- | ----------------------------------------------------------- | ------------------------------------------- | | `RPC_URL` | The RPC URL for the network you want to deploy to. | `https://sepolia.infura.io/v3/your-api-key` | - | `PRIVATE_KEY` | The private key of the account you want to deploy from. | `0xabc123abc123abc123abc123abc123...` | + | `PRIVATE_KEY` | The private key of the account you want to deploy from.
Add `0x` before your key. | `0xabc123abc123abc123abc123abc123...` | | `EXPLORER_KEY` | The API key for Etherscan needed for contract verification. | `ABC123ABC123ABC123ABC123ABC123ABC1` | @@ -175,7 +175,7 @@ This command will install the project dependencies, which include [chainlink](ht - + ### Deploy the contract @@ -193,7 +193,7 @@ make deploy Test the contract as the end-user. -1. Open the [LINK Token Contract](https://docs.chain.link/resources/link-token-contracts) write functions for your network in an explorer. For example, on Polygon Mumbai you can open the [0x0ed18e80aacede8cb52a6043976c255eff6fedbf](https://mumbai.polygonscan.com/address/0x0ed18e80aacede8cb52a6043976c255eff6fedbf#writeContract) contract. +1. Open the [LINK Token Contract](https://docs.chain.link/resources/link-token-contracts) write functions for your network in an explorer. For example, on Ethereum Sepolia you can open the [0x779877A7B0D9E8603169DdbD7836e478b4624789](https://sepolia.etherscan.io/token/0x779877A7B0D9E8603169DdbD7836e478b4624789#writeContract) contract. 1. Connect your wallet to the scanning app so you can run write functions. @@ -203,7 +203,7 @@ Test the contract as the end-user. style="max-width: 50%;" /> -1. Approve the deployed contract to spend LINK. Run the `approve` function with your deployed contract address and `5000000000000000000` Juels (5 LINK) as variables. Click **Write** to run the function. Metamask asks you to approve the transaction. +1. Approve the deployed contract to spend LINK. Run the `approve` function with your deployed contract address and Juels (5 LINK) as variables. Click **Write** to run the function. MetaMask asks you to approve the transaction. @@ -121,7 +119,6 @@ For Sepolia, these values are all consolidated here: | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | LINK token address |
| | VRF Coordinator |
| -| Automation registry address |
| 1. Open the `VRFSubscriptionBalanceMonitor.sol` contract in Remix. @@ -137,7 +134,6 @@ For Sepolia, these values are all consolidated here: | ----------------------- | ------------------------------------------------------------------ | | `LINKTOKENADDRESS` | | | `COORDINATORADDRESS` | | - | `KEEPERREGISTRYADDRESS` | | | `MINWAITPERIODSECONDS` | | 1. Click **Deploy**. MetaMask opens and prompts you to confirm the contract deployment transaction. @@ -163,22 +159,35 @@ Registering an upkeep on Chainlink Automation creates a smart contract that will 1. Click **Register new Upkeep**. -1. Select the _Custom logic_ trigger. +1. Select the _Custom logic_ trigger option. -1. Input the address of your deployed subscription balance monitor contract. +1. Copy your contract address from Remix and paste it into the **Target contract address** field. -1. Get the ABI from Remix. +1. Specify a name for your upkeep and set a **Starting balance** of 5 LINK for this demo. Leave the other settings at their default values. -1. Enter the values for the constructor. +1. Go to the **Upkeep details** page and copy your **Forwarder address**. - | Item | Value | - | ----------------------- | ------------------------------------------------------------------ | - | `LINKTOKENADDRESS` | | - | `COORDINATORADDRESS` | | - | `KEEPERREGISTRYADDRESS` | | - | `MINWAITPERIODSECONDS` | | +1. Navigate back to Remix and find the `setForwarderAddress` function. Paste your forwarder address and click click **transact** to run the function. MetaMask asks you to confirm the transaction. + +Now that you've registered the upkeep and configured your contract with your new upkeep's forwarder address, Chainlink Automation handles the rest of the process. + + + + + +Before your contract will fund a subscription, you must set the `watchList` address array with `minBalancesJuels` and `topUpAmountsJuels` variables. For demonstration purposes, you configure your own wallet as the top-up address. This makes it easy to see the ETH being sent as part of the automated top-up function. After you complete this tutorial, you can configure any wallet or contract address that you want to keep funded. + +1. In the list of functions for your deployed contract, run the `setWatchList` function. This function requires an `subscriptionIds` array, a `minBalancesJuels` array that maps to the subscriptions, and a `topUpAmountsJuels` array that also maps to the subscriptions. In Remix, arrays require brackets and quotes around integer values. For this example, set the following values: + + - **subscriptionIds**: `["SUB_ID_1", "SUB_ID_2"]` + - **minBalancesJuels**: `["2000000000000000000", "2000000000000000000"]` + - **topUpAmountsJuels**: `["10000000000000000", "10000000000000000"]` + + These values tell the top up contract to top up the specified address with 0.01 LINK if the address balance is less than 2 LINK. These settings are intended to demonstrate the example using testnet faucet funds. For a production application, you might set more reasonable values that top up a smart contract with 10 LINK if the balance is less than 1 LINK. + +1. After you configure the function values, click **transact** to run the function. MetaMask asks you to confirm the transaction. -1. Fund the upkeep with enough LINK to monitor your VRF subscriptions. +1. In the functions list, click the `getWatchList` function to confirm your settings are correct.