Skip to content

hardhat: fix docs according to expected kusama launch #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

BigTava
Copy link

@BigTava BigTava commented Apr 15, 2025

No description provided.

@BigTava BigTava requested a review from a team as a code owner April 15, 2025 10:26
@eshaben eshaben requested review from nhussein11 and 0xLucca April 15, 2025 22:31
Copy link
Collaborator

@nhussein11 nhussein11 left a comment

Choose a reason for hiding this comment

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

@BigTava Thanks! Left some comments

Comment on lines 54 to 57
To interact with Polkadot Hub, Hardhat requires a plugin to compile contracts to PolkaVM bytecode and the and to spawn a local node compatible with PolkaVM.

```bash
npm install --save-dev hardhat-resolc hardhat-revive-node
npm install --save-dev @parity/hardhat-polkadot
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason for this update? I checked https://www.npmjs.com/ and there is no package named @parity/hardhat-polkadot, so If we move on with this change the instruction would not work

Copy link
Author

@BigTava BigTava Apr 21, 2025

Choose a reason for hiding this comment

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

We are releasing an umbrella package to 1) simplify onboarding 2) simplify adding more packages/features without the user having to install them

Copy link
Author

Choose a reason for hiding this comment

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

What do you think about this move?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, having only one package will be much better for devs, I fully agree with that. However, I was suggesting that we need to implement this change only after the package has been deployed and we confirm that the command npm install @parity/hardhat-polkadot actually works

Copy link
Author

Choose a reason for hiding this comment

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

Absolutely. This PR should only be merged after the package is available

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah okay, I'd put this PR as a draft PR then, and it will get unblock once that package is available :)


- **Remix compiler** - uses the Remix online compiler backend for simplicity and ease of use
- **Npm compiler** - uses library [@parity/revive](https://www.npmjs.com/package/@parity/revive){target=\_blank} for simplicity and ease of use
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the @parity/revive be integrated into the hardhat workflow? Otherwise I think this would be misleading

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh just saw that you can do:

resolc: {
    compilerSource: 'npm',
    settings: {},
  },

Would it be possible to add a complete example of how to use npm, then, so users can compare the binary and the npm library

Copy link
Author

Choose a reason for hiding this comment

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

Can the @parity/revive be integrated into the hardhat workflow

@parity/revive is already integrated right? Users don't have to install it.

Would it be possible to add a complete example of how to use npm

Is npm.config.ts enough? I am proposing we add full project examples and not just the hardhat.config.ts? What do you think? In addition to this, do you think users will use binary configuration? What if they don't even add this "resolc" key to config? We just compile the thing if the package is imported and if someone wants to debug the compiler they can configure the "resolc" with the binary. Looking forward to your feedback

Copy link
Collaborator

Choose a reason for hiding this comment

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

We do have some full project examples available here - https://github.com/polkadot-developers/polkavm-hardhat-examples

From my experience, the binary configuration was quite complex from a developer experience standpoint. I had to download the binary, switch the solc version on my machine to a compatible one, and then check out and compile a matching version of the Polkadot SDK to generate a compatible substrate-node and eth-rpc-adapter.

Now that there's an npm-based option, I think we should emphasize using that as much as possible.

That said, for this guide—which serves as a starting point for developers—I suggest we explain both approaches. We can highlight the npm.config.ts setup (https://github.com/paritytech/hardhat-polkadot/blob/main/examples/npm.config.ts) and pull that file directly from the Hardhat repo to avoid duplication. After covering the npm path, we can still include the binary configuration for projects that might require customizing the resolc binary, as you mentioned.

@BigTava, what do you think?

Copy link
Author

Choose a reason for hiding this comment

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

We do have some full project examples available here

Nice! Where will you feature these? I think it is key we have an examples folder too in our repo. They will also be part of our e2e test suite. Maybe you could just link to our folder so we reduce maintenance overhead.

what do you think

I think we shouldn't frame 2 options. We just mention there is a more advanced option to compile the contracts. The user shouldn't even need to configure the compiler. It just needs to import the package and it uses the npm as default. For now, let's keep as is and rename Remix -> Npm. But, if you agree, we would reduce the step "Compiling Your Contract" to just step 2 and 3 and briefly mention the binary configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice! Where will you feature these? I think it is key we have an examples folder too in our repo. They will also be part of our e2e test suite. Maybe you could just link to our folder so we reduce maintenance overhead.

I believe that for tutorials, we should keep them in the repository I shared previously since it would be easier to update those projects as the tutorial requires if we need to adjust something in the documentation. However, if you all add some projects and examples in the Hardhat Revive repository, we can also add references so that people can check different use cases as soon as those projects are pinned to a specific tag or release, ensuring that the documentation does not break even if the project gets updated.

I think we shouldn't frame 2 options. We just mention there is a more advanced option to compile the contracts. The user shouldn't even need to configure the compiler. It just needs to import the package and it uses the npm as default. For now, let's keep as is and rename Remix -> Npm. But, if you agree, we would reduce the step "Compiling Your Contract" to just step 2 and 3 and briefly mention the binary configuration.

I like this, yeah I agree!

@@ -109,7 +109,7 @@ To compile your project, follow these instructions:
--8<-- 'code/develop/smart-contracts/dev-environments/hardhat/hardhat.config.js:65:66'
```

For the binary configuration, replace `INSERT_PATH_TO_RESOLC_COMPILER` with the proper path to the binary. For more information about its installation, check the [installation](https://github.com/paritytech/revive?tab=readme-ov-file#installation){target=\_blank} section of the `pallet-revive`.
For the binary configuration, check the [installation](https://github.com/paritytech/revive?tab=readme-ov-file#installation){target=\_blank} section of the `pallet-revive`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wouldn't remove "replace INSERT_PATH_TO_RESOLC_COMPILER with the proper path to the binary. For more information about its installation,". This aims to add clarity for those who have no experience with the plugin, so if we take this out, it would be harder to grasp. Would you agree @BigTava ?

Copy link
Author

Choose a reason for hiding this comment

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

Agree, thanks

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please roll back this change?

@@ -303,7 +303,7 @@ For example, for the default `Lock.sol` contract, you can use the following file
Run your interaction script:

```bash
npx hardhat run scripts/interact.js --network westendAssetHub
npx hardhat run scripts/interact.js --network polkadotHub
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps this should be westendHub, in any case, this also requires updating the hardhat.config.js code snippet

Copy link
Author

@BigTava BigTava Apr 21, 2025

Choose a reason for hiding this comment

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

We want to avoid using anything but polkadot, to reduce friction. polkadotHub is already a stretch for technical audiences. What is your opinion on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mmm, I do understand your point, and I think @0xLucca worked in a PR to emphasize the usage of Polkadot Hub here - https://github.com/polkadot-developers/polkadot-docs/pull/572/files

But in this case, how would we differentiate if a user is trying to interact with Westend Asset Hub or polkadot asset hub? That's why I thought about using Westend Hub, as it'd be changed here

Copy link
Author

@BigTava BigTava Apr 21, 2025

Choose a reason for hiding this comment

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

Exactly, the PR 572 is good. You're right, what about just calling it here in the docs polkadotTestnet? IMO, it would help developers associate westend as a testnet of Polkadot. In the end, I am just trying to minimize the different names we use, which cause real pain in developer onboarding. Polkadot is known for being quite confusing. The change starts here

Copy link
Collaborator

@nhussein11 nhussein11 Apr 21, 2025

Choose a reason for hiding this comment

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

Totally, I agree with that point. I'm just a bit concerned about Paseo, because if, at some point, Paseo is also upgraded to support polkavm, the word polkadotTestnet would not be enough to cover both, westend and paseo. What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

Good point. I will confirm that point. IMO developers only care, if testnet 1 is better than testnet 2 for some reason. If not, they just care it is a testnet

@nhussein11
Copy link
Collaborator

Marking this PR as blocked since it needs to wait until the hardhat-polkadot npm package is realesed (reference)

@nhussein11 nhussein11 added the B2 - Blocked Pull request is blocked and should not be merged label Apr 22, 2025
@@ -28,7 +28,7 @@ Before getting started, ensure you have:
- [Node.js](https://nodejs.org/){target=\_blank} (v16.0.0 or later) and npm installed
- Basic understanding of Solidity programming
- Some WND test tokens to cover transaction fees (easily obtainable from the [Polkadot faucet](https://faucet.polkadot.io/westend?parachain=1000){target=\_blank}). To learn how to get test tokens, check out the [Test Tokens](/develop/smart-contracts/connect-to-asset-hub/#test-tokens){target=\_blank} section
- [MetaMask](https://metamask.io/){target=\_blank} installed and connected to [Westend Asset Hub](https://chainlist.org/chain/420420421){target=\_blank}. For more detailed instructions on connecting your wallet, see the [Connect Your Wallet](/develop/smart-contracts/connect-to-asset-hub/#connect-your-wallet){target=\_blank} section
- [MetaMask](https://metamask.io/){target=\_blank} installed and connected to [Westend Hub](https://chainlist.org/chain/420420421){target=\_blank}. For more detailed instructions on connecting your wallet, see the [Connect Your Wallet](/develop/smart-contracts/connect-to-asset-hub/#connect-your-wallet){target=\_blank} section

## Setting Up Hardhat
Copy link

Choose a reason for hiding this comment

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

This whole section needs to be updated, now that we have npx hardhat-polkadot init.

Copy link
Author

@BigTava BigTava May 6, 2025

Choose a reason for hiding this comment

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

I also thought about that, but I think to also target users that already have a hardhat.config.ts and want to adapt, the existing flow is preferable. But we should use npx hardhat-polkadot init in the tutorial section Setting up the Development Environment. How does that sound to you? Ideally we should have 2 guides: One for Getting started from scratch and another to Migrate existing setup.

Copy link

Choose a reason for hiding this comment

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

If that's the goal, it makes sense 👍


- **Remix compiler** - uses the Remix online compiler backend for simplicity and ease of use
- **Npm compiler** - uses library [@parity/revive](https://www.npmjs.com/package/@parity/revive){target=\_blank} for simplicity and ease of use
- **Binary compiler** - uses the resolc binary directly for more control and configuration options
Copy link

Choose a reason for hiding this comment

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

Suggested change
- **Binary compiler** - uses the resolc binary directly for more control and configuration options
- **Binary compiler** - uses your local `resolc` binary directly for more control and configuration options

Copy link
Author

Choose a reason for hiding this comment

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

Thanks!

6. Deploy your contract using Ignition:

```bash
npx hardhat ignition deploy ./ignition/modules/Lock.js --network westendHub
Copy link

Choose a reason for hiding this comment

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

If we are running a local node in the previous step, we should use --network localhost. Or if we want to make a live deployment the step 5 doesn't make sense.

Copy link
Author

@BigTava BigTava May 8, 2025

Choose a reason for hiding this comment

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

Removed step 5. For some reason I couldn't deploy to westendHub without the node running

@@ -303,7 +313,7 @@ For example, for the default `Lock.sol` contract, you can use the following file
Run your interaction script:

```bash
npx hardhat run scripts/interact.js --network westendAssetHub
npx hardhat run scripts/interact.js --network westendHub
Copy link

Choose a reason for hiding this comment

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

Same comment as above

@nhussein11 nhussein11 changed the base branch from staging-ah-smart-contracts to nhussein11/update-hardhat-polkadot-docs May 9, 2025 12:38
@nhussein11 nhussein11 changed the base branch from nhussein11/update-hardhat-polkadot-docs to staging-ah-smart-contracts May 9, 2025 12:38
@nhussein11 nhussein11 changed the base branch from staging-ah-smart-contracts to nhussein11/update-hardhat-polkadot-docs May 9, 2025 12:40
@nhussein11 nhussein11 merged commit 50457ac into polkadot-developers:nhussein11/update-hardhat-polkadot-docs May 9, 2025
eshaben added a commit that referenced this pull request May 13, 2025
…polkadot (#623)

* hardhat: fix docs according to expected kusama launch (#563)

* hardhat: fix docs according to expected kusama launch

* fix: title

* feat: proposes  hardhat.config and hardhat.md

* fix: rename polkadotTestnest to westendHub

* fix: replaces `npx hardhat node` with `npx hardhat node-polkavm`

* docs: small changes in "Use Hardhat with Polkadot"

* docs: minor fixes

* fix: tested and adjusting snippets

* Apply suggestions from code review

Co-authored-by: Alberto Nicolas Penayo <[email protected]>

* fix: optimizer settings

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

Co-authored-by: Alberto Nicolas Penayo <[email protected]>

* fix: missing polkavm true

* fix: docs

* fix: placeholder

* Apply suggestions from code review

Co-authored-by: Erin Shaben <[email protected]>

* fix: feedback

---------

Co-authored-by: Tiago Tavares ⭕️ <[email protected]>
Co-authored-by: Alberto Nicolas Penayo <[email protected]>
Co-authored-by: Erin Shaben <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B2 - Blocked Pull request is blocked and should not be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants