You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -10427,10 +10427,10 @@ Before getting started, ensure you have:
10427
10427
npm init -y
10428
10428
```
10429
10429
10430
-
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:
10430
+
3. To interact with Polkadot, Hardhat requires the following plugin to compile contracts and to spawn a local node for testing:
@@ -10439,7 +10439,7 @@ Before getting started, ensure you have:
10439
10439
npx hardhat-polkadot init
10440
10440
```
10441
10441
10442
-
Select **Create a JavaScript project** when prompted and follow the instructions. After that, your project will be created with three main folders:
10442
+
Follow the project creation wizard. Your project will be created with three main folders:
10443
10443
10444
10444
- **`contracts`**: Where your Solidity smart contracts live.
10445
10445
- **`test`**: Contains your test files that validate contract functionality.
@@ -10462,143 +10462,83 @@ Before getting started, ensure you have:
10462
10462
10463
10463
## Compile Your Contract
10464
10464
10465
-
The plugin will compile your Solidity contracts for Solidity versions `0.8.0` and higher to be PolkaVM compatible. When compiling your contract, there are two ways to configure your compilation process:
10465
+
The plugin will compile your Solidity contracts for Solidity versions `0.8.0` and higher. To compile your project, follow these instructions:
10466
10466
10467
-
- **npm compiler**: Uses library [@parity/resolc](https://www.npmjs.com/package/@parity/resolc){target=\_blank} for simplicity and ease of use.
10468
-
- **Binary compiler**: Uses your local `resolc` binary directly for more control and configuration options.
10467
+
1. Make sure your Hardhat configuration file looks like the following. Note that it may differ slightly based on the language choice made during the `init` step of setting up Hardhat:
10469
10468
10470
-
To compile your project, follow these instructions:
10471
-
10472
-
1. Modify your Hardhat configuration file to specify which compilation process you will be using and activate the `polkavm` flag in the Hardhat network:
For the binary configuration, replace `INSERT_PATH_TO_RESOLC_COMPILER` with the proper path to the binary. To obtain the binary, check the [releases](https://github.com/paritytech/revive/releases){target=\_blank} section of the `resolc` compiler, and download the latest version.
10522
-
10523
-
The default settings used can be found in the [`constants.ts`](https://github.com/paritytech/hardhat-polkadot/blob/v0.1.5/packages/hardhat-polkadot-resolc/src/constants.ts#L8-L23){target=\_blank} file of the `hardhat-polkadot` source code. You can change them according to your project needs. Generally, the recommended settings for optimized outputs are the following:
You can check the [`ResolcConfig`](https://github.com/paritytech/hardhat-polkadot/blob/v0.1.5/packages/hardhat-polkadot-resolc/src/types.ts#L26){target=\_blank} for more information about compilation settings.
10505
+
To obtain the `dev-node` and `eth-rpc` binaries required in `nodeConfig` and `adapterConfig` respectively, check this [release](https://github.com/paritytech/hardhat-polkadot/releases/tag/nodes-19071579107){target=\_blank} and download the binaries as per your development platform and update the paths in your Hardhat config.
10506
+
10507
+
!!! note
10508
+
You might have to give executable permissions to the binaries:
10509
+
```bash
10510
+
chmod +x /path/to/your/binary
10511
+
```
10512
+
In macOS environments, binaries are sometimes quarantined. To remove this, run:
3. After successful compilation, you'll see the artifacts generated in the `artifacts-pvm` directory:
10523
+
3. After successful compilation, you'll see the artifacts generated in the `artifacts` directory:
10550
10524
10551
10525
```bash
10552
-
ls artifacts-pvm/contracts/*.sol/
10526
+
ls artifacts/contracts/*.sol/
10553
10527
```
10554
10528
10555
-
You should see JSON files containing the contract ABI and bytecode of the contracts you compiled.
10529
+
You should see JSON files containing the contract ABIs and bytecodes for the contracts you compiled.
10556
10530
10557
10531
## Set Up a Testing Environment
10558
10532
10559
-
Hardhat allows you to spin up a local testing environment to test and validate your smart contract functionalities before deploying to live networks. The `hardhat-polkadot` plugin provides the possibility to spin up a local node with an ETH-RPC adapter for running local tests.
10560
-
10561
-
For complete isolation and control over the testing environment, you can configure Hardhat to work with a fresh local Substrate node. This approach is ideal when you want to test in a clean environment without any existing state or when you need specific node configurations.
10562
-
10563
-
Configure a local node setup by adding the node binary path along with the ETH-RPC adapter path:
10533
+
Hardhat lets you spin up a local testing environment to test and validate your smart contract functionality before deploying to live networks. The `hardhat-polkadot` plugin allows you to spin up a local node with an ETH-RPC adapter for running local tests.
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.
10591
-
10592
-
!!! warning
10593
-
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.
10594
-
10595
-
Once configured, start your chosen testing environment with:
10535
+
Once you have set up the binaries as per the [Compile Your Contract](#compile-your-contract) section, start your local testing node with:
10596
10536
10597
10537
```bash
10598
10538
npx hardhat node
10599
10539
```
10600
10540
10601
-
This command will launch either the forked network or local node (depending on your configuration) along with the ETH-RPC adapter, providing you with a complete testing environment ready for contract deployment and interaction. By default, the Substrate node will be running on `localhost:8000` and the ETH-RPC adapter on `localhost:8545`.
10541
+
This command launches a local node with the ETH-RPC adapter, providing a complete testing environment ready for contract deployment and interaction. By default, the Substrate node runs on `localhost:8000`, and the ETH-RPC adapter on `localhost:8545`.
10602
10542
10603
10543
The output will be something like this:
10604
10544
@@ -10629,7 +10569,7 @@ When testing your contract, be aware that [`@nomicfoundation/hardhat-toolbox/net
10629
10569
10630
10570
To run your test:
10631
10571
10632
-
1. Update the `hardhat.config.js` file accordingly to the [Set Up a Testing Environment](#set-up-a-testing-environment) section.
10572
+
1. Update the `hardhat.config.js` file as per the [Compile Your Contract](#compile-your-contract) section.
10633
10573
10634
10574
2. Execute the following command to run your tests:
10635
10575
@@ -10641,27 +10581,15 @@ To run your test:
10641
10581
10642
10582
Before deploying to a live network, you can deploy your contract to a local node using [Ignition](https://hardhat.org/ignition/docs/getting-started#overview){target=\_blank} modules:
10643
10583
10644
-
1. Update the Hardhat configuration file to add the local network as a target for local deployment:
0 commit comments