Skip to content

Commit a856ea3

Browse files
authored
[FIX] - Update hardhat guides to hardhat-polkadot 1.9.0 (#894)
* fix: hardhat version * fix: section for upgrades * fix: clean dep commands * Revert "fix: clean dep commands" This reverts commit 45d7d4d.
1 parent 5eca5c9 commit a856ea3

File tree

3 files changed

+59
-24
lines changed

3 files changed

+59
-24
lines changed

develop/smart-contracts/dev-environments/hardhat.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Before getting started, ensure you have:
5151
3. To interact with Polkadot, Hardhat requires the following plugin to compile contracts to PolkaVM bytecode and to spawn a local node compatible with PolkaVM:
5252

5353
```bash
54-
npm install --save-dev @parity/[email protected].8
54+
npm install --save-dev @parity/[email protected].9
5555
```
5656

5757
4. Create a Hardhat project:
@@ -66,11 +66,9 @@ Before getting started, ensure you have:
6666
- **`test`** - contains your test files that validate contract functionality
6767
- **`ignition`** - deployment modules for safely deploying your contracts to various networks
6868

69-
5. Add the following folders to the `.gitignore` file if they are not already there:
69+
5. Add the following folder to the `.gitignore` file if it is not already there:
7070

7171
```bash
72-
echo '/artifacts-pvm' >> .gitignore
73-
echo '/cache-pvm' >> .gitignore
7472
echo '/ignition/deployments/' >> .gitignore
7573
```
7674

@@ -163,6 +161,9 @@ Configure a local node setup by adding the node binary path along with the ETH-R
163161
164162
Replace `INSERT_PATH_TO_SUBSTRATE_NODE` and `INSERT_PATH_TO_ETH_RPC_ADAPTER` with the actual paths to your compiled binaries. The `dev: true` flag configures both the node and adapter for development mode. To obtain these binaries, check the [Installation](/develop/smart-contracts/local-development-node#install-the-substrate-node-and-eth-rpc-adapter){target=\_blank} section on the Local Development Node page.
165163
164+
!!! warning
165+
If you're using the default `hardhat.config.js` created by the `hardhat-polkadot` plugin, it includes a `forking` section pointing to the Polkadot Hub TestNet. When you run `npx hardhat node`, Hardhat will start a fork of that network. To use your local node instead, comment out the `forking` section; otherwise, `npx hardhat node` will continue to use the forked network even if a local node is defined in the configuration.
166+
166167
Once configured, start your chosen testing environment with:
167168

168169
```bash
@@ -283,6 +284,23 @@ Run your interaction script:
283284
npx hardhat run scripts/interact.js --network polkadotHubTestnet
284285
```
285286

287+
## Upgrading the Plugin
288+
289+
If you already have a Hardhat Polkadot project and want to upgrade to a newer version of the plugin, to avoid errors (for example, `Cannot find module 'run-container'`), you can clean your dependencies by running the following commands:
290+
291+
```bash
292+
rm -rf node_modules package-lock.json
293+
```
294+
295+
After that, you can upgrade the plugin to the latest version by running the following commands:
296+
297+
```bash
298+
npm install --save-dev @parity/hardhat-polkadot@latest
299+
npm install
300+
```
301+
302+
Consider using [Node.js](https://nodejs.org/){target=\_blank} 22.18+ and [npm](https://www.npmjs.com/){target=\_blank} version 10.9.0+ to avoid issues with the plugin.
303+
286304
## Where to Go Next
287305

288306
Hardhat provides a powerful environment for developing, testing, and deploying smart contracts on Polkadot Hub. Its plugin architecture allows seamless integration with PolkaVM through the `hardhat-resolc` and `hardhat-revive-node` plugins.

llms.txt

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8450,7 +8450,7 @@ Before getting started, ensure you have:
84508450
3. To interact with Polkadot, Hardhat requires the following plugin to compile contracts to PolkaVM bytecode and to spawn a local node compatible with PolkaVM:
84518451

84528452
```bash
8453-
npm install --save-dev @parity/[email protected].8
8453+
npm install --save-dev @parity/[email protected].9
84548454
```
84558455

84568456
4. Create a Hardhat project:
@@ -8465,11 +8465,9 @@ Before getting started, ensure you have:
84658465
- **`test`** - contains your test files that validate contract functionality
84668466
- **`ignition`** - deployment modules for safely deploying your contracts to various networks
84678467

8468-
5. Add the following folders to the `.gitignore` file if they are not already there:
8468+
5. Add the following folder to the `.gitignore` file if it is not already there:
84698469

84708470
```bash
8471-
echo '/artifacts-pvm' >> .gitignore
8472-
echo '/cache-pvm' >> .gitignore
84738471
echo '/ignition/deployments/' >> .gitignore
84748472
```
84758473

@@ -8604,6 +8602,9 @@ module.exports = {
86048602

86058603
Replace `INSERT_PATH_TO_SUBSTRATE_NODE` and `INSERT_PATH_TO_ETH_RPC_ADAPTER` with the actual paths to your compiled binaries. The `dev: true` flag configures both the node and adapter for development mode. To obtain these binaries, check the [Installation](/develop/smart-contracts/local-development-node#install-the-substrate-node-and-eth-rpc-adapter){target=\_blank} section on the Local Development Node page.
86068604

8605+
!!! warning
8606+
If you're using the default `hardhat.config.js` created by the `hardhat-polkadot` plugin, it includes a `forking` section pointing to the Polkadot Hub TestNet. When you run `npx hardhat node`, Hardhat will start a fork of that network. To use your local node instead, comment out the `forking` section; otherwise, `npx hardhat node` will continue to use the forked network even if a local node is defined in the configuration.
8607+
86078608
Once configured, start your chosen testing environment with:
86088609

86098610
```bash
@@ -8789,6 +8790,23 @@ Run your interaction script:
87898790
npx hardhat run scripts/interact.js --network polkadotHubTestnet
87908791
```
87918792

8793+
## Upgrading the Plugin
8794+
8795+
If you already have a Hardhat Polkadot project and want to upgrade to a newer version of the plugin, to avoid errors (for example, `Cannot find module 'run-container'`), you can clean your dependencies by running the following commands:
8796+
8797+
```bash
8798+
rm -rf node_modules package-lock.json
8799+
```
8800+
8801+
After that, you can upgrade the plugin to the latest version by running the following commands:
8802+
8803+
```bash
8804+
npm install --save-dev @parity/hardhat-polkadot@latest
8805+
npm install
8806+
```
8807+
8808+
Consider using [Node.js](https://nodejs.org/){target=\_blank} 22.18+ and [npm](https://www.npmjs.com/){target=\_blank} version 10.9.0+ to avoid issues with the plugin.
8809+
87928810
## Where to Go Next
87938811

87948812
Hardhat provides a powerful environment for developing, testing, and deploying smart contracts on Polkadot Hub. Its plugin architecture allows seamless integration with PolkaVM through the `hardhat-resolc` and `hardhat-revive-node` plugins.
@@ -41205,7 +41223,7 @@ Let's start by setting up Hardhat for your Storage contract project:
4120541223
3. Install `hardhat-polkadot` and all required plugins:
4120641224

4120741225
```bash
41208-
npm install --save-dev @parity/hardhat-polkadot [email protected]
41226+
npm install --save-dev @parity/hardhat-polkadot@0.1.9 [email protected]
4120941227
```
4121041228

4121141229
For dependencies compatibility, ensure to install the `@nomicfoundation/hardhat-toolbox` dependency with the `--force` flag:
@@ -41235,7 +41253,6 @@ const { vars } = require("hardhat/config");
4123541253
module.exports = {
4123641254
solidity: "0.8.28",
4123741255
resolc: {
41238-
version: "1.5.2",
4123941256
compilerSource: "npm",
4124041257
},
4124141258
networks: {
@@ -41654,7 +41671,7 @@ Congratulations! You've successfully set up a Hardhat development environment, w
4165441671
To get started with a working example right away, you can clone the repository and navigate to the project directory:
4165541672

4165641673
```bash
41657-
git clone https://github.com/polkadot-developers/polkavm-hardhat-examples.git -b v0.0.7
41674+
git clone https://github.com/polkadot-developers/polkavm-hardhat-examples.git -b v0.0.8
4165841675
cd polkavm-hardhat-examples/storage-hardhat
4165941676
```
4166041677
--- END CONTENT ---

tutorials/smart-contracts/launch-your-first-project/test-and-deploy-with-hardhat.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Let's start by setting up Hardhat for your Storage contract project:
4141
3. Install `hardhat-polkadot` and all required plugins:
4242

4343
```bash
44-
npm install --save-dev @parity/hardhat-polkadot [email protected]
44+
npm install --save-dev @parity/hardhat-polkadot@0.1.9 [email protected]
4545
```
4646

4747
For dependencies compatibility, ensure to install the `@nomicfoundation/hardhat-toolbox` dependency with the `--force` flag:
@@ -61,7 +61,7 @@ Let's start by setting up Hardhat for your Storage contract project:
6161
6. Configure Hardhat by updating the `hardhat.config.js` file:
6262

6363
```javascript title="hardhat.config.js"
64-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/hardhat.config.js'
64+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/hardhat.config.js'
6565
```
6666

6767
Ensure that `INSERT_PATH_TO_SUBSTRATE_NODE` and `INSERT_PATH_TO_ETH_RPC_ADAPTER` are replaced with the proper paths to the compiled binaries.
@@ -91,7 +91,7 @@ Let's start by setting up Hardhat for your Storage contract project:
9191
1. Create a new folder called `contracts` and create a `Storage.sol` file. Add the contract code from the previous tutorial:
9292
9393
```solidity title="Storage.sol"
94-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/contracts/Storage.sol'
94+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/contracts/Storage.sol'
9595
```
9696
9797
2. Compile the contract:
@@ -113,9 +113,9 @@ Testing is a critical part of smart contract development. Hardhat makes it easy
113113
1. Create a folder for testing called `test`. Inside that directory, create a file named `Storage.js` and add the following code:
114114
115115
```javascript title="Storage.js"
116-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/test/Storage.js:0:19'
116+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/test/Storage.js:0:19'
117117
// Add your logic here
118-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/test/Storage.js:48:49'
118+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/test/Storage.js:48:49'
119119
```
120120
121121
The `beforeEach` hook ensures stateless contract execution by redeploying a fresh instance of the Storage contract before each test case. This approach guarantees that each test starts with a clean and independent contract state by using `ethers.getSigners()` to obtain test accounts and `ethers.getContractFactory('Storage').deploy()` to create a new contract instance.
@@ -125,7 +125,7 @@ Testing is a critical part of smart contract development. Hardhat makes it easy
125125
a. **Initial state verification** - ensures that the contract starts with a default value of zero, which is a fundamental expectation for the `Storage.sol` contract
126126
127127
```javascript title="Storage.js"
128-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/test/Storage.js:20:22'
128+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/test/Storage.js:20:22'
129129
```
130130
131131
Explanation:
@@ -137,7 +137,7 @@ Testing is a critical part of smart contract development. Hardhat makes it easy
137137
b. **Value storage test** - validate the core functionality of storing and retrieving a value in the contract
138138
139139
```javascript title="Storage.js"
140-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/test/Storage.js:24:30'
140+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/test/Storage.js:24:30'
141141
```
142142
143143
Explanation:
@@ -149,7 +149,7 @@ Testing is a critical part of smart contract development. Hardhat makes it easy
149149
c. **Event emission verification** - confirm that the contract emits the correct event when storing a value, which is crucial for off-chain tracking
150150
151151
```javascript title="Storage.js"
152-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/test/Storage.js:32:38'
152+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/test/Storage.js:32:38'
153153
```
154154
155155
Explanation:
@@ -161,7 +161,7 @@ Testing is a critical part of smart contract development. Hardhat makes it easy
161161
d. **Sequential value storage test** - check the contract's ability to store multiple values sequentially and maintain the most recent value
162162
163163
```javascript title="Storage.js"
164-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/test/Storage.js:40:47'
164+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/test/Storage.js:40:47'
165165
```
166166
167167
Explanation:
@@ -174,7 +174,7 @@ Testing is a critical part of smart contract development. Hardhat makes it easy
174174
175175
???--- code "View complete script"
176176
```javascript title="Storage.js"
177-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/test/Storage.js'
177+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/test/Storage.js'
178178
```
179179
180180
2. Run the tests:
@@ -194,7 +194,7 @@ Testing is a critical part of smart contract development. Hardhat makes it easy
194194
1. Create a new folder called`ignition/modules`. Add a new file named `StorageModule.js` with the following logic:
195195
196196
```javascript title="StorageModule.js"
197-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/ignition/modules/StorageModule.js'
197+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/ignition/modules/StorageModule.js'
198198
```
199199
200200
2. Deploy to the local network:
@@ -234,7 +234,7 @@ To interact with your deployed contract:
234234
1. Create a new folder named `scripts` and add the `interact.js` with the following content:
235235

236236
```javascript title="interact.js"
237-
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.7/storage-hardhat/scripts/interact.js'
237+
--8<-- 'https://raw.githubusercontent.com/polkadot-developers/polkavm-hardhat-examples/refs/tags/v0.0.8/storage-hardhat/scripts/interact.js'
238238
```
239239

240240
Ensure that `INSERT_DEPLOYED_CONTRACT_ADDRESS` is replaced with the value obtained in the previous step.
@@ -256,6 +256,6 @@ Congratulations! You've successfully set up a Hardhat development environment, w
256256
To get started with a working example right away, you can clone the repository and navigate to the project directory:
257257
258258
```bash
259-
git clone https://github.com/polkadot-developers/polkavm-hardhat-examples.git -b v0.0.7
259+
git clone https://github.com/polkadot-developers/polkavm-hardhat-examples.git -b v0.0.8
260260
cd polkavm-hardhat-examples/storage-hardhat
261261
```

0 commit comments

Comments
 (0)