Skip to content

Commit 6f8dc5c

Browse files
eshabennhussein11
andauthored
Update cookbook guides to use hardhat v2 (#1266)
* update hardhat cookbook guides to use v2 * llms * update erc-20 hardhat guide * update where to go next * llms * Update smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md Co-authored-by: Nicolás Hussein <[email protected]> * llms --------- Co-authored-by: Nicolás Hussein <[email protected]>
1 parent b53bca7 commit 6f8dc5c

File tree

18 files changed

+405
-513
lines changed

18 files changed

+405
-513
lines changed

.ai/categories/basics.md

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export default config;
303303
```
304304

305305
!!! tip
306-
Visit the Hardhat [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} documentation to learn how to use Hardhat to handle your private keys securely.
306+
Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\_blank} documentation to learn how to use Hardhat to handle your private keys securely.
307307

308308
## Compile the Contract
309309

@@ -358,9 +358,10 @@ If tests are successful, you will see outputs similar to the following:
358358
You are now ready to deploy the contract to your chosen network. This example demonstrates deployment to the Polkadot TestNet. Deploy the contract as follows:
359359

360360
1. Run the following command in your terminal:
361-
```bash
362-
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet
363-
```
361+
362+
```bash
363+
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet
364+
```
364365

365366
2. Confirm the target deployment network name and chain ID when prompted:
366367

@@ -392,13 +393,21 @@ Congratulations! You've successfully deployed an ERC-20 token contract to Polkad
392393
393394
<div class="grid cards" markdown>
394395
395-
- <span class="badge guide">Guide</span> __Deploy an NFT with Remix__
396+
- <span class="badge guide">Guide</span> __Deploy an NFT__
396397
397398
---
398399
399-
Walk through deploying an ERC-721 Non-Fungible Token (NFT) using OpenZeppelin's battle-tested NFT implementation and Remix.
400+
Walk through deploying an NFT to the Polkadot Hub using Hardhat.
400401
401-
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/)
402+
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/)
403+
404+
- <span class="badge guide">Guide</span> __Create a DApp__
405+
406+
---
407+
408+
Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.
409+
410+
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)
402411
403412
</div>
404413
@@ -660,7 +669,7 @@ Before you begin, ensure you have the following:
660669
```bash
661670
mkdir hardhat-nft-deployment
662671
cd hardhat-nft-deployment
663-
npx hardhat --init
672+
npx hardhat@^2.27.0 init
664673
```
665674

666675
2. Install the OpenZeppelin contract dependencies using the command:
@@ -673,50 +682,28 @@ Before you begin, ensure you have the following:
673682

674683
Open `hardhat.config.ts` and update to add `polkadotTestnet` to the `networks` configuration as highlighted in the following example code:
675684

676-
```typescript title="hardhat.config.ts" hl_lines='39-44'
685+
```typescript title="hardhat.config.ts" hl_lines='18-23'
677686
import type { HardhatUserConfig } from 'hardhat/config';
678687
679688
import hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem';
680-
import { configVariable } from 'hardhat/config';
689+
import { vars } from 'hardhat/config';
681690
682691
const config: HardhatUserConfig = {
683692
plugins: [hardhatToolboxViemPlugin],
684693
solidity: {
685-
profiles: {
686-
default: {
687-
version: '0.8.28',
688-
},
689-
production: {
690-
version: '0.8.28',
691-
settings: {
692-
optimizer: {
693-
enabled: true,
694-
runs: 200,
695-
},
696-
},
694+
version: '0.8.28',
695+
settings: {
696+
optimizer: {
697+
enabled: true,
698+
runs: 200,
697699
},
698700
},
699701
},
700702
networks: {
701-
hardhatMainnet: {
702-
type: 'edr-simulated',
703-
chainType: 'l1',
704-
},
705-
hardhatOp: {
706-
type: 'edr-simulated',
707-
chainType: 'op',
708-
},
709-
sepolia: {
710-
type: 'http',
711-
chainType: 'l1',
712-
url: configVariable('SEPOLIA_RPC_URL'),
713-
accounts: [configVariable('SEPOLIA_PRIVATE_KEY')],
714-
},
715703
polkadotTestnet: {
716-
type: 'http',
717704
url: 'https://testnet-passet-hub-eth-rpc.polkadot.io',
718705
chainId: 420420422,
719-
accounts: [configVariable('PRIVATE_KEY')],
706+
accounts: [vars.get('PRIVATE_KEY')],
720707
},
721708
},
722709
};
@@ -725,7 +712,7 @@ export default config;
725712
```
726713
727714
!!! tip
728-
Visit the Hardhat [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} documentation to learn how to use Hardhat to handle your private keys securely.
715+
Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\_blank} documentation to learn how to use Hardhat to handle your private keys securely.
729716
730717
## Create the Contract
731718
@@ -840,6 +827,14 @@ Congratulations! You've successfully deployed an ERC-721 NFT contract to Polkado
840827
841828
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)
842829
830+
- <span class="badge guide">Guide</span> __Create a DApp__
831+
832+
---
833+
834+
Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.
835+
836+
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)
837+
843838
</div>
844839
845840

.ai/categories/dapps.md

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export default config;
304304
```
305305

306306
!!! tip
307-
Visit the Hardhat [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} documentation to learn how to use Hardhat to handle your private keys securely.
307+
Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\_blank} documentation to learn how to use Hardhat to handle your private keys securely.
308308

309309
## Compile the Contract
310310

@@ -359,9 +359,10 @@ If tests are successful, you will see outputs similar to the following:
359359
You are now ready to deploy the contract to your chosen network. This example demonstrates deployment to the Polkadot TestNet. Deploy the contract as follows:
360360

361361
1. Run the following command in your terminal:
362-
```bash
363-
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet
364-
```
362+
363+
```bash
364+
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet
365+
```
365366

366367
2. Confirm the target deployment network name and chain ID when prompted:
367368

@@ -393,13 +394,21 @@ Congratulations! You've successfully deployed an ERC-20 token contract to Polkad
393394
394395
<div class="grid cards" markdown>
395396
396-
- <span class="badge guide">Guide</span> __Deploy an NFT with Remix__
397+
- <span class="badge guide">Guide</span> __Deploy an NFT__
397398
398399
---
399400
400-
Walk through deploying an ERC-721 Non-Fungible Token (NFT) using OpenZeppelin's battle-tested NFT implementation and Remix.
401+
Walk through deploying an NFT to the Polkadot Hub using Hardhat.
401402
402-
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/)
403+
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/)
404+
405+
- <span class="badge guide">Guide</span> __Create a DApp__
406+
407+
---
408+
409+
Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.
410+
411+
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)
403412
404413
</div>
405414
@@ -661,7 +670,7 @@ Before you begin, ensure you have the following:
661670
```bash
662671
mkdir hardhat-nft-deployment
663672
cd hardhat-nft-deployment
664-
npx hardhat --init
673+
npx hardhat@^2.27.0 init
665674
```
666675

667676
2. Install the OpenZeppelin contract dependencies using the command:
@@ -674,50 +683,28 @@ Before you begin, ensure you have the following:
674683

675684
Open `hardhat.config.ts` and update to add `polkadotTestnet` to the `networks` configuration as highlighted in the following example code:
676685

677-
```typescript title="hardhat.config.ts" hl_lines='39-44'
686+
```typescript title="hardhat.config.ts" hl_lines='18-23'
678687
import type { HardhatUserConfig } from 'hardhat/config';
679688
680689
import hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem';
681-
import { configVariable } from 'hardhat/config';
690+
import { vars } from 'hardhat/config';
682691
683692
const config: HardhatUserConfig = {
684693
plugins: [hardhatToolboxViemPlugin],
685694
solidity: {
686-
profiles: {
687-
default: {
688-
version: '0.8.28',
689-
},
690-
production: {
691-
version: '0.8.28',
692-
settings: {
693-
optimizer: {
694-
enabled: true,
695-
runs: 200,
696-
},
697-
},
695+
version: '0.8.28',
696+
settings: {
697+
optimizer: {
698+
enabled: true,
699+
runs: 200,
698700
},
699701
},
700702
},
701703
networks: {
702-
hardhatMainnet: {
703-
type: 'edr-simulated',
704-
chainType: 'l1',
705-
},
706-
hardhatOp: {
707-
type: 'edr-simulated',
708-
chainType: 'op',
709-
},
710-
sepolia: {
711-
type: 'http',
712-
chainType: 'l1',
713-
url: configVariable('SEPOLIA_RPC_URL'),
714-
accounts: [configVariable('SEPOLIA_PRIVATE_KEY')],
715-
},
716704
polkadotTestnet: {
717-
type: 'http',
718705
url: 'https://testnet-passet-hub-eth-rpc.polkadot.io',
719706
chainId: 420420422,
720-
accounts: [configVariable('PRIVATE_KEY')],
707+
accounts: [vars.get('PRIVATE_KEY')],
721708
},
722709
},
723710
};
@@ -726,7 +713,7 @@ export default config;
726713
```
727714
728715
!!! tip
729-
Visit the Hardhat [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} documentation to learn how to use Hardhat to handle your private keys securely.
716+
Visit the Hardhat [Configuration variables](https://v2.hardhat.org/hardhat-runner/docs/guides/configuration-variables){target=\_blank} documentation to learn how to use Hardhat to handle your private keys securely.
730717
731718
## Create the Contract
732719
@@ -841,6 +828,14 @@ Congratulations! You've successfully deployed an ERC-721 NFT contract to Polkado
841828
842829
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)
843830
831+
- <span class="badge guide">Guide</span> __Create a DApp__
832+
833+
---
834+
835+
Learn step-by-step how to build a fully functional dApp that interacts with a smart contract deployed via Hardhat.
836+
837+
[:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/dapps/zero-to-hero/)
838+
844839
</div>
845840
846841

0 commit comments

Comments
 (0)