Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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.

Expand Down Expand Up @@ -573,22 +573,22 @@ 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");
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],
},
},
};
Expand All @@ -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.

Expand Down Expand Up @@ -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) {
Expand All @@ -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,
});
Expand Down
6 changes: 3 additions & 3 deletions hardhat-tutorial/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
},
};
10 changes: 5 additions & 5 deletions my-app/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
});
Expand Down