Skip to content

Commit

Permalink
Cleanup writing and formatting on guides (#614)
Browse files Browse the repository at this point in the history
* Cleanup Hardhat Guide

* Cleanup remix tutorial writing

* Update docs/evm/build/guides/deploy-contract/using-hardhat.md

Co-authored-by: Greg Santos <[email protected]>

---------

Co-authored-by: Chase Fleming <[email protected]>
Co-authored-by: Greg Santos <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2024
1 parent 11a88d3 commit 7ddbe67
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 56 deletions.
43 changes: 19 additions & 24 deletions docs/evm/build/guides/deploy-contract/using-hardhat.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ sidebar_position: 1

# Using Hardhat

Hardhat is a comprehensive Ethereum development tool that simplifies the process of deploying, testing, and debugging smart contracts. It's designed to offer developers a seamless experience when working with Solidity contracts.
Hardhat is an Ethereum development tool designed to facilitate the deployment, testing, and debugging of smart contracts. It provides a streamlined experience for developers working with Solidity contracts.


## Prerequisites

### Software

Node v18+, can be downloaded [Here](https://nodejs.org/en/download)
Node v18 or higher, available for [download here](https://nodejs.org/en/download).

Getting Started with Hardhat. [More Information](https://hardhat.org/tutorial/creating-a-new-hardhat-project). These directions demonstrate using npm commands to create a project and add its dependencies.
For those new to Hardhat, we recommend exploring the [official documentation](https://hardhat.org/tutorial/creating-a-new-hardhat-project) to get acquainted. The following instructions utilize `npm` to initialize a project and install dependencies:

```shell
mkdir hardhat-example
Expand All @@ -29,20 +29,18 @@ npm install --save-dev hardhat
npx hardhat init
```


### Fund Your Wallet

Navigate to the Flow [Previewnet Faucet](https://previewnet-faucet.onflow.org/fund-account). Paste in your wallet address to get receive $FLOW. This will allow your wallet address to deploy smart contracts.


To deploy smart contracts, ensure your wallet has **$FLOW**. Obtain funds by navigating to the Flow [Previewnet Faucet](https://previewnet-faucet.onflow.org/fund-account) and entering your wallet address.

## Deploying a Smart Contract using Hardhat
## Deploying a Smart Contract with Hardhat

This section is dedicated to guiding you through deploying smart contracts on the Flow EVM network using Hardhat.
This section guides you through the process of deploying smart contracts on the Flow network using Hardhat.

### Configuration

Make sure to add Previewnet network to `hardhat.config.ts`
First, incorporate the Previewnet network into your `hardhat.config.ts`:

```javascript

require('dotenv').config()
Expand All @@ -64,11 +62,13 @@ const config: HardhatUserConfig = {

export default config;
```

To keep this example straightforward, we've included the account's private key directly in `hardhat.config.ts`. However, it is crucial to avoid committing private keys to your Git repository for security reasons. Instead, opt for using environment variables for safer handling of sensitive information.

### Deploying HelloWorld Smart Contract

### HelloWorld Smart Contract

```Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
Expand All @@ -95,13 +95,11 @@ contract HelloWorld {
return greeting;
}
}
```

Deploying:
1. Create a file named HelloWorld.sol under contracts directory.
2. Add above HelloWorld.sol contract code to new file.
1. Create a file named `HelloWorld.so`l` under `contracts` directory.
2. Add above `HelloWorld.sol` contract code to new file.
3. Create a `deploy.ts` file in `scripts` directory.
4. Paste in the following TypeScript code.

Expand Down Expand Up @@ -161,9 +159,9 @@ main().catch((error) => {
});
```
Steps:
1. Create new file getGreeting.ts in `scripts` directory.
1. Create a `getGreeting.ts` file in the `scripts` directory.
2. Paste contents of script above. Make sure to update the contract address with the one from deployment in earlier step.
3. Call script to get HelloWorld greeting, `npx hardhat run scripts/getGreeting.ts --network previewNet`
3. Call script to get the greeting, `npx hardhat run scripts/getGreeting.ts --network previewNet`
4. The output should be as follows:
```shell
❯ npx hardhat run scripts/getGreeting.ts --network previewNet
Expand Down Expand Up @@ -211,11 +209,11 @@ main().catch((error) => {

```

Next we'll add a script to update the greeting and log it. Here are the steps to follow:
1. Create new script `updateGreeting.ts` file in the `scripts` directory
Next, we'll add a script to update the greeting and log it. Here are the steps to follow:
1. Create an `updateGreeting.ts` script in the `scripts` directory.
2. Paste in the TypeScript above, Make sure to update the contract address with the one from deployment in earlier step.
3. Call the new script, `NEW_GREETING='Howdy!' npx hardhat run ./scripts/updateGreeting.ts --network previewNet`
4. Output should be
4. The output should be
```shell
❯ NEW_GREETING='Howdy!' npx hardhat run ./scripts/updateGreeting.ts --network previewNet
The greeting is: Hello, World!
Expand All @@ -224,16 +222,13 @@ Greeting updated successfully!
The greeting is: Howdy!
```

### Flow EVM Block explorer

#### Coming Soon

### Flow EVM Block explorer

:::info

### Coming Soon

- **Comprehensive Guides:** Step-by-step tutorials on deploying various types of smart contracts, including NFTs (ERC-721), using Hardhat on the FlowEVM network.
- **Comprehensive Guides:** Step-by-step tutorials on deploying various types of smart contracts, including NFTs (ERC-721), using Hardhat on the Flow network.
- **Requirements:** Detailed prerequisites for using Hardhat with FlowEVM, including Node.js setup, wallet preparation, and obtaining testnet FLOW for gas fees.
- **Verification and Interaction:** Steps to verify your smart contracts on FlowEVM and interact with them using tools like Flowdiver.

Expand Down
60 changes: 28 additions & 32 deletions docs/evm/build/guides/deploy-contract/using-remix.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,22 @@ sidebar_position: 1

# Using Remix

Remix is an open-source, web-based development environment tailored for EVM smart contract development. It provides developers with a comprehensive suite of tools to write, deploy, and test smart contracts in Solidity. More Information [Remix](https://remix.ethereum.org/)
Remix is an open-source, web-based development environment tailored for EVM smart contract development. It offers developers a comprehensive suite of tools for writing, deploying, and testing smart contracts in Solidity. For more information, visit [Remix](https://remix.ethereum.org/).

## Add Flow EVM Network to metamask
## Add the Flow Network to MetaMask

![Add Flow EVM Network](./Remix-adding-metamask-network.gif)
![Add Flow Network](./Remix-adding-metamask-network.gif)

Navigate to [Using EVM](../../../using.mdx) page to find the convenient button to add Flow EVM network information to your metamask.
Navigate to the [Using EVM](../../../using.mdx) page to find the button to add the Flow network information to your metamask.

## Fund your Flow EVM account
## Fund Your Flow Account

Navigate to the [Flow Previewnet Faucet](https://previewnet-faucet.onflow.org/fund-account) to obtain FLOW tokens necessary for deploying a smart contract.

Navigate to the Flow [Previewnet Faucet](https://previewnet-faucet.onflow.org/fund-account) to get Flow in order to deploy a smart contract


## Deploying a Smart Contract using Remix
## Deploying a Smart Contract Using Remix

![Deploy Smart Contract](./Remix-deploy-contract-flowevm.gif)


### HelloWorld Smart Contract
```solidity
// SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -58,19 +55,19 @@ contract HelloWorld {
```

### Steps to deploy HelloWorld smart contract.
Using Remix:
1. Create a file named HelloWorld.sol
2. Select Solidity Compiler and compile HelloWorld.sol
3. Select Deploy & Run Transactions
4. Make sure to select `Injected Provider - Metamask` in Environment dropdown
5. Deploy the HelloWorld smart contract
### Steps to Deploy the HelloWorld Smart Contract

1. Create a file named `HelloWorld.sol`.
2. Select Solidity Compiler and compile `HelloWorld.sol`.
3. Select Deploy & Run Transactions.
4. Make sure to select `Injected Provider - Metamask` in Environment dropdown.
5. Deploy the `HelloWorld` smart contract.

## Calling deployed Smart Contract using Remix
## Calling the Deployed Smart Contract

![Call Smart Contract](./Remix-call-getGreeting.gif)

### Using Ethersjs to call HelloWorld smart contract
### Using Ethers.js to Call the HelloWorld Smart Contract

```javascript
// Import ethers from the ethers.js library
Expand Down Expand Up @@ -104,26 +101,25 @@ getGreeting();

```
1. Create a new file under `scripts`
2. Paste in above JavaScript code
3. Click on green play button
1. Create a new file under `scripts`.
2. Paste in above JavaScript code.
3. Click on green play button.
4. Verify the greeting is "Hello World!"
Use the steps below to change the greeting and retrieve the greeting again.
Follow the steps below to change the greeting and retrieve the new greeting.
## Updating deployed Smart Contract
## Updating the Deployed Smart Contract
![Update Smart Contract](./Remix-update-greeting.gif)
Steps to update the HelloWorld smart contract greeting
1. Select the HelloWorld.sol file
2. Select the `Deploy and Run Transaction` page
3. Make sure to select `Injected Provider - Metamask` in Environment dropdown
4. Type a new greeting in the text input next to `changeGreeting` orange button
5. Click on the `changeGreeting` orange button
6. Sign the Metamask transaction
1. Select the `HelloWorld.sol` file.
2. Select the `Deploy and Run Transaction` page.
3. Make sure to select `Injected Provider - Metamask` in Environment dropdown.
4. Type a new greeting in the text input next to orange `changeGreeting` button.
5. Click on the orange `changeGreeting` button.
6. Sign the Metamask transaction.
7. Verify the greeting has changed by running the JavaScript above.
## Flow EVM Block explorer
## Flow Previewnet Block Explorer
### Coming Soon

0 comments on commit 7ddbe67

Please sign in to comment.