diff --git a/README.md b/README.md index e883978..31aab16 100644 --- a/README.md +++ b/README.md @@ -513,18 +513,18 @@ contract Exchange is ERC20 { npm install dotenv ``` -- Now create a `.env` file in the `hardhat-tutorial` folder and add the following lines, use the instructions in the comments to get your Alchemy API Key URL and Rinkeby Private Key. Make sure that the account from which you get your Rinkeby private key is funded with Rinkeby Ether. +- Now create a `.env` file in the `hardhat-tutorial` folder and add the following lines, use the instructions in the comments to get your Alchemy API Key URL and Goerli Private Key. Make sure that the account from which you get your Goerli private key is funded with Goerli Ether. ```bash // Go to https://www.alchemyapi.io, sign up, create - // a new App in its dashboard and select the network as Rinkeby, and replace "add-the-alchemy-key-url-here" with its key url + // a new App in its dashboard and select the network as Goerli, and replace "add-the-alchemy-key-url-here" with its key url ALCHEMY_API_KEY_URL="add-the-alchemy-key-url-here" - // Replace this private key with your RINKEBY account private key + // Replace this private key with your GOERLI account private key // To export your private key from Metamask, open Metamask and // go to Account Details > Export Private Key // Be aware of NEVER putting real Ether into testing accounts - RINKEBY_PRIVATE_KEY="add-the-rinkeby-private-key-here" + GOERLI_PRIVATE_KEY="add-the-goerli-private-key-here" ``` - Lets also create a constants folder to keep track of any constants we have. Under the `hardhat-tutorial` folder create a new folder named `constants` and under the `constants` folder create a new file `index.js` @@ -537,7 +537,7 @@ contract Exchange is ERC20 { module.exports = { CRYPTO_DEV_TOKEN_CONTRACT_ADDRESS }; ``` -- Lets deploy the contract to `rinkeby` network. Create a new file, or replace the existing default one, named `deploy.js` under the `scripts` folder +- Lets deploy the contract to `goerli` network. Create a new file, or replace the existing default one, named `deploy.js` under the `scripts` folder - Now we would write some code to deploy the contract in `deploy.js` file. @@ -573,7 +573,7 @@ contract Exchange is ERC20 { }); ``` -- Now open the `hardhat.config.js` file, we would add the `rinkeby` network here so that we can deploy our contract to rinkeby. Replace all the lines in the `hardhat.config.js` file with the given below lines +- Now open the `hardhat.config.js` file, we would add the `goerli` network here so that we can deploy our contract to goerli. Replace all the lines in the `hardhat.config.js` file with the given below lines ```js require("@nomicfoundation/hardhat-toolbox"); @@ -581,14 +581,14 @@ contract Exchange is ERC20 { const ALCHEMY_API_KEY_URL = process.env.ALCHEMY_API_KEY_URL; - const RINKEBY_PRIVATE_KEY = process.env.RINKEBY_PRIVATE_KEY; + const GOERLI_PRIVATE_KEY = process.env.GOERLI_PRIVATE_KEY; module.exports = { solidity: "0.8.4", networks: { - rinkeby: { + goerli: { url: ALCHEMY_API_KEY_URL, - accounts: [RINKEBY_PRIVATE_KEY], + accounts: [GOERLI_PRIVATE_KEY], }, }, }; @@ -602,7 +602,7 @@ contract Exchange is ERC20 { - To deploy, open up a terminal pointing at`hardhat-tutorial` directory and execute this command ```bash - npx hardhat run scripts/deploy.js --network rinkeby + npx hardhat run scripts/deploy.js --network goerli ``` - Save the Exchange Contract Address that was printed on your terminal in your notepad, you would need it further down in the tutorial. @@ -1430,11 +1430,11 @@ export default function Home() { const provider = await web3ModalRef.current.connect(); const web3Provider = new providers.Web3Provider(provider); - // If user is not connected to the Rinkeby network, let them know and throw an error + // If user is not connected to the Goerli network, let them know and throw an error const { chainId } = await web3Provider.getNetwork(); - if (chainId !== 4) { - window.alert("Change the network to Rinkeby"); - throw new Error("Change network to Rinkeby"); + if (chainId !== 5) { + window.alert("Change the network to Goerli"); + throw new Error("Change network to Goerli"); } if (needSigner) { @@ -1453,7 +1453,7 @@ export default function Home() { // Assign the Web3Modal class to the reference object by setting it's `current` value // The `current` value is persisted throughout as long as this page is open web3ModalRef.current = new Web3Modal({ - network: "rinkeby", + network: "goerli", providerOptions: {}, disableInjectedProvider: false, }); diff --git a/hardhat-tutorial/hardhat.config.js b/hardhat-tutorial/hardhat.config.js index 36b53e5..6f8d6f4 100644 --- a/hardhat-tutorial/hardhat.config.js +++ b/hardhat-tutorial/hardhat.config.js @@ -3,14 +3,14 @@ require("dotenv").config({ path: ".env" }); const ALCHEMY_API_KEY_URL = process.env.ALCHEMY_API_KEY_URL; -const RINKEBY_PRIVATE_KEY = process.env.RINKEBY_PRIVATE_KEY; +const GOERLI_PRIVATE_KEY = process.env.GOERLI_PRIVATE_KEY; module.exports = { solidity: "0.8.4", networks: { - rinkeby: { + goerli: { url: ALCHEMY_API_KEY_URL, - accounts: [RINKEBY_PRIVATE_KEY], + accounts: [GOERLI_PRIVATE_KEY], }, }, }; diff --git a/my-app/pages/index.js b/my-app/pages/index.js index 05b3736..0732fb0 100644 --- a/my-app/pages/index.js +++ b/my-app/pages/index.js @@ -292,11 +292,11 @@ export default function Home() { const provider = await web3ModalRef.current.connect(); const web3Provider = new providers.Web3Provider(provider); - // If user is not connected to the Rinkeby network, let them know and throw an error + // If user is not connected to the Goerli network, let them know and throw an error const { chainId } = await web3Provider.getNetwork(); - if (chainId !== 4) { - window.alert("Change the network to Rinkeby"); - throw new Error("Change network to Rinkeby"); + if (chainId !== 5) { + window.alert("Change the network to Goerli"); + throw new Error("Change network to Goerli"); } if (needSigner) { @@ -315,7 +315,7 @@ export default function Home() { // Assign the Web3Modal class to the reference object by setting it's `current` value // The `current` value is persisted throughout as long as this page is open web3ModalRef.current = new Web3Modal({ - network: "rinkeby", + network: "goerli", providerOptions: {}, disableInjectedProvider: false, });