Skip to content

Commit

Permalink
Simplify Contracts Tutorial by Removing Use of Hardhat Plugin (#7084)
Browse files Browse the repository at this point in the history
  • Loading branch information
danforbes committed Jun 10, 2024
1 parent 7af8090 commit b01d5f9
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions docs/docs/guides/smart_contracts/smart_contracts_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ In this step, we will set up Web3.js and Hardhat.
First, install the required packages with npm:

```bash
npm i web3 hardhat @nomicfoundation/hardhat-web3-v4
npm i web3 hardhat
```

Next, initialize the Hardhat project:
Expand All @@ -173,19 +173,7 @@ Next, initialize the Hardhat project:
npx hardhat init
```

Initializing the Hardhat project will require responding to several prompts - select the default option for each prompt.

After you initialize the Hardhat project, a number of new files and directories will be created, including a Hardhat configuration file called `hardhat.config.js`. Edit `hardhat.config.js` to include the [Web3.js plugin for Hardhat](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-web3-v4).

```js
require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-web3-v4"); // <=== add this import

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.24",
};
```
Initializing the Hardhat project will require responding to several prompts - select the default option for each prompt. After you initialize the Hardhat project, a number of new files and directories will be created.

To start the Hardhat development network, execute the following command:

Expand Down Expand Up @@ -221,7 +209,7 @@ The Hardhat development network needs to remain running in the terminal that was
Next, create a new file called `index.js` in your project directory and add the following code to it:

```js
const { Web3 } = require("hardhat");
const { Web3 } = require("web3");

const web3 = new Web3("http://127.0.0.1:8545/");

Expand Down Expand Up @@ -261,7 +249,7 @@ In this step, we will use Web3.js to deploy the smart contract to the developmen
Create a file named `deploy.js` and fill it with the following code:

```js
const { Web3 } = require("hardhat");
const { Web3 } = require("web3");
const path = require("path");
const fs = require("fs");

Expand Down Expand Up @@ -330,7 +318,7 @@ In this step, we will use Web3.js to interact with the smart contract on the dev
Create a file named `interact.js` and fill it with the following code:

```js
const { Web3 } = require("hardhat");
const { Web3 } = require("web3");
const path = require("path");
const fs = require("fs");

Expand Down

1 comment on commit b01d5f9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: b01d5f9 Previous: 7af8090 Ratio
processingTx 8958 ops/sec (±4.22%) 9348 ops/sec (±3.97%) 1.04
processingContractDeploy 39403 ops/sec (±7.83%) 40452 ops/sec (±6.63%) 1.03
processingContractMethodSend 18211 ops/sec (±7.41%) 19668 ops/sec (±6.95%) 1.08
processingContractMethodCall 38322 ops/sec (±5.87%) 37823 ops/sec (±6.19%) 0.99
abiEncode 44746 ops/sec (±7.58%) 44665 ops/sec (±7.08%) 1.00
abiDecode 29026 ops/sec (±9.01%) 30295 ops/sec (±7.99%) 1.04
sign 1601 ops/sec (±0.64%) 1584 ops/sec (±0.73%) 0.99
verify 365 ops/sec (±0.66%) 371 ops/sec (±2.86%) 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.