To deploy contracts on the Goerli Testnet, you’ll need Goerli ETH (GoerliETH). While it doesn’t hold any real value, it’s essential for paying gas fees on the testnet.
Metamask: Ensure your Metamask is switched to the Goerli Test Network.
Go to Goerli faucet to request some GoerliETH. Just paste your Goerli Testnet Ethereum address, and you should receive the test ETH shortly.
In Remix, navigate to the Deploy & Run Transactions
tab.
For the Environment
option, select Injected Provider
. This option allows Remix to connect to any network your Metamask is currently set to, which should be Goerli Testnet.
Ensure your contract, OracleIntegratedContract
, is selected in the Contract
dropdown.
For the Account
dropdown, you should see your Goerli Testnet Ethereum address.
Before you deploy, you’ll need the address of a Chainlink price feed on the Goerli network. For the sake of this example, we’ll use the ETH/USD Price Feed. You can usually find these addresses in the Chainlink documentation or by exploring the Chainlink contracts on a site like Etherscan. Check here: Testnet Oracles | Chainlink Documentation
Copy the Goerli Testnet address of the Chainlink price feed you want to use. In this case: 0xCC79157eb46F5624204f47AB42b3906cAA40eaB7
Back in Remix, in the Deploy & Run Transactions
tab, ensure your contract, OracleIntegratedContract
, is selected in the Contract
dropdown.
Paste the copied address into the field below the Deploy
button (this is where you provide constructor arguments).
Once the price feed address is filled in, click the Deploy
button.
Metamask will prompt you to confirm the transaction. Check the gas price and the gas limit to make sure everything looks in order, then confirm the transaction.
After the transaction gets mined, you’ll see a log in Remix with details of the deployment. You can click on the contract address to view the contract on the Goerli Etherscan.
Now that the contract is deployed, it’s time to test its functions.
In the Deployed Contracts
section in Remix, you should see your OracleIntegratedContract
.
Expand the deployed contract details to see the available functions.
Before making any calls, you have to detain some LINK on your Goerli Testnet address, you can ask for some here: https://faucets.chain.link/goerli
Once received, to check the balance, you can add LINK to your Metamask on Goerli. Find Here: https://docs.chain.link/resources/link-token-contracts
Or you can do it manually by adding the contract address like below:
Call the getLatestEthPrice
function by clicking on it. It should return the latest ETH price in raw format.
Now, call the getFormattedEthPrice
function. This function returns the price in a more readable format.
Lastly, call the safeGetLatestEthPrice
function to ensure data fetch safety checks are in place.
Congratulations! You’ve successfully deployed and tested an oracle-integrated contract on the Goerli Testnet. This real-world experience is invaluable, as it brings you a step closer to deploying on the main Ethereum network. In our next lesson, we’ll delve into best practices and common pitfalls to watch out for.
To deploy contracts on the Goerli Testnet, you’ll need Goerli ETH (GoerliETH). While it doesn’t hold any real value, it’s essential for paying gas fees on the testnet.
Metamask: Ensure your Metamask is switched to the Goerli Test Network.
Go to Goerli faucet to request some GoerliETH. Just paste your Goerli Testnet Ethereum address, and you should receive the test ETH shortly.
In Remix, navigate to the Deploy & Run Transactions
tab.
For the Environment
option, select Injected Provider
. This option allows Remix to connect to any network your Metamask is currently set to, which should be Goerli Testnet.
Ensure your contract, OracleIntegratedContract
, is selected in the Contract
dropdown.
For the Account
dropdown, you should see your Goerli Testnet Ethereum address.
Before you deploy, you’ll need the address of a Chainlink price feed on the Goerli network. For the sake of this example, we’ll use the ETH/USD Price Feed. You can usually find these addresses in the Chainlink documentation or by exploring the Chainlink contracts on a site like Etherscan. Check here: Testnet Oracles | Chainlink Documentation
Copy the Goerli Testnet address of the Chainlink price feed you want to use. In this case: 0xCC79157eb46F5624204f47AB42b3906cAA40eaB7
Back in Remix, in the Deploy & Run Transactions
tab, ensure your contract, OracleIntegratedContract
, is selected in the Contract
dropdown.
Paste the copied address into the field below the Deploy
button (this is where you provide constructor arguments).
Once the price feed address is filled in, click the Deploy
button.
Metamask will prompt you to confirm the transaction. Check the gas price and the gas limit to make sure everything looks in order, then confirm the transaction.
After the transaction gets mined, you’ll see a log in Remix with details of the deployment. You can click on the contract address to view the contract on the Goerli Etherscan.
Now that the contract is deployed, it’s time to test its functions.
In the Deployed Contracts
section in Remix, you should see your OracleIntegratedContract
.
Expand the deployed contract details to see the available functions.
Before making any calls, you have to detain some LINK on your Goerli Testnet address, you can ask for some here: https://faucets.chain.link/goerli
Once received, to check the balance, you can add LINK to your Metamask on Goerli. Find Here: https://docs.chain.link/resources/link-token-contracts
Or you can do it manually by adding the contract address like below:
Call the getLatestEthPrice
function by clicking on it. It should return the latest ETH price in raw format.
Now, call the getFormattedEthPrice
function. This function returns the price in a more readable format.
Lastly, call the safeGetLatestEthPrice
function to ensure data fetch safety checks are in place.
Congratulations! You’ve successfully deployed and tested an oracle-integrated contract on the Goerli Testnet. This real-world experience is invaluable, as it brings you a step closer to deploying on the main Ethereum network. In our next lesson, we’ll delve into best practices and common pitfalls to watch out for.