Skip to content

Commit 9705924

Browse files
committed
more storytelling/formatting cleanup for cookbooks/smart contracts
1 parent 70701b4 commit 9705924

File tree

4 files changed

+78
-128
lines changed

4 files changed

+78
-128
lines changed

smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Deploy a Contract with Hardhat
2+
title: Deploy Basic Contract with Hardhat
33
description: Learn how to deploy a basic smart contract to Polkadot Hub using Hardhat, Perfect for professional workflows requiring comprehensive testing and debugging.
44
categories: Smart Contracts
55
---

smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Deploy a Contract with Remix IDE
2+
title: Deploy Basic Contract with Remix IDE
33
description: Learn how to deploy a basic smart contract to Polkadot Hub using Remix IDE Ideal for rapid prototyping, learning, and visual development.
44
categories: Smart Contracts
55
---
@@ -28,18 +28,23 @@ The interface will load with a default workspace containing sample contracts. In
2828

2929
## Compile the Contract
3030

31-
1. Navigate to the **Solidity Compiler** tab.
32-
2. Click **Compile Storage.sol** or press `Ctrl+S`.
31+
Ensure your contract is open in the Remix IDE Editor, and use the follow steps to compile:
32+
33+
1. Select the **Solidity Compiler** plugin from the left panel.
34+
2. Select the **Compile MyToken.sol** button.
35+
3. The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully.
3336

3437
![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-02.webp)
3538

3639
If any issues arise during Compilation, errors and warnings will appear in the terminal panel at the bottom of the screen.
3740

3841
## Deploy the Contract
3942

43+
Follow these steps to deploy the contract using Remix:
44+
4045
1. Navigate to the **Deploy & Run Transactions** tab.
41-
2. Click the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet).
42-
3. Click **Deploy**.
46+
2. Select the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet).
47+
3. Select **Deploy**.
4348
4. Approve the transaction in your MetaMask wallet.
4449

4550
![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-03.webp)

smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md

Lines changed: 37 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
---
2-
title: Deploy an ERC-20 to Polkadot Hub
2+
title: Deploy ERC-20 Using Hardhat
33
description: Deploy an ERC-20 token on Polkadot Hub using PolkaVM. This guide covers contract creation, compilation, deployment, and interaction via Hardhat.
44
tutorial_badge: Intermediate
55
categories: Basics, Smart Contracts
66
tools: Hardhat
77
---
88

9-
# Deploy an ERC-20 to Polkadot Hub
9+
# Deploy ERC-20 Using Hardhat
1010

1111
## Introduction
1212

13-
[ERC-20](https://eips.ethereum.org/EIPS/eip-20){target=\_blank} tokens are fungible tokens commonly used for creating cryptocurrencies, governance tokens, and staking mechanisms. Polkadot Hub enables easy token deployment with Ethereum-compatible smart contracts and tools via the EVM backend.
13+
[ERC-20](https://eips.ethereum.org/EIPS/eip-20){target=\_blank} tokens are fungible tokens commonly used for creating cryptocurrencies, governance tokens, and staking mechanisms. Polkadot Hub enables easy ERC-20 token deployment with Ethereum-compatible smart contracts and tools via the EVM backend.
1414

15-
This tutorial covers deploying an ERC-20 contract on the Polkadot Hub TestNet using [Hardhat](https://hardhat.org/){target=\_blank}, an Ethereum development environment. The ERC-20 contract can be retrieved from OpenZeppelin's [GitHub repository]({{ dependencies.repositories.open_zeppelin_contracts.repository_url}}/tree/{{ dependencies.repositories.open_zeppelin_contracts.version}}/contracts/token/ERC20){target=\_blank} or their [Contract Wizard](https://wizard.openzeppelin.com/){target=\_blank}.
15+
This tutorial covers deploying an ERC-20 contract on the Polkadot Hub TestNet using [Hardhat](https://hardhat.org/){target=\_blank}, an Ethereum development environment. The ERC-20 contract can be retrieved from OpenZeppelin's [GitHub repository]({{ dependencies.repositories.open_zeppelin_contracts.repository_url}}/tree/{{ dependencies.repositories.open_zeppelin_contracts.version}}/contracts/token/ERC20){target=\_blank} or their [Contract Wizard](https://wizard.openzeppelin.com/){target=\_blank}.
1616

1717
## Prerequisites
1818

19-
Before starting, make sure you have:
19+
Before you begin, ensure sure you have the following:
2020

21-
- Basic understanding of Solidity programming and fungible tokens.
22-
- Node.js v22.13.1 or later.
23-
- A funded account with tokens for transaction fees. This example will deploy the contract to the Polkadot TestNet, so you'll [need some TestNet tokens](/smart-contracts/faucet/#get-test-tokens){target=\_blank} from the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\_blank}.
21+
- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming and [ERC-20](https://ethereum.org/developers/docs/standards/tokens/erc-20/) fungible tokens.
22+
- Node.js v22.13.1 or later installed.
23+
- Test tokens for gas fees, available from the [Polkadot faucet](https://faucet.polkadot.io/){target=\_blank}. See [Get Test Tokens](/smart-contracts/faucet/#get-test-tokens){target=\_blank} for a guide to using the faucet.
24+
- A wallet with a private key for signing transactions.
2425

2526
## Set Up Your Project
2627

@@ -38,49 +39,31 @@ This tutorial uses a [Hardhat ERC-20 template](https://github.com/polkadot-devel
3839
```bash
3940
npm i
4041
```
41-
42-
This will fetch all the necessary packages to help you deploy an ERC-20 with Hardhat to Polkadot.
42+
43+
This will fetch all the necessary packages to help you deploy an ERC-20 with Hardhat to Polkadot.
4344

4445
## Configure Hardhat
4546

46-
Once you've [setup your project](#set-up-your-project), you can configure the `hardhat.config.ts` to your needs. This tutorial has the file prepared to deploy to the Polkadot TestNet.
47-
48-
To store and use private keys or network URLs, you can use Hardhat's configuration variables. This can be set via tasks in the **vars** scope. For example, to store the private key to deploy to the Polkadot TestNet, run the following command:
49-
50-
```bash
51-
npx hardhat vars set TESTNET_PRIVATE_KEY
52-
```
53-
54-
The command will initiate a wizard in which you'll have to enter the value to be stored:
47+
If you started with the cloned Hardhat ERC-20 template, `hardhat.config.js` is already configured to deploy to the Polkadot TestNet as shown in the example below:
5548

56-
<div id="termynal" data-termynal markdown>
57-
<span data-ty="input">npx hardhat vars set TESTNET_PRIVATE_KEY</span>
58-
<span data-ty>✔ Enter value: · •••••••••</span>
59-
<span data-ty>The configuration variable has been stored in /Users/albertoviera/Library/Preferences/hardhat-nodejs/vars.json</span>
60-
</div>
61-
62-
??? warning "Key Encryption"
63-
This solution just prevents variables to be included in the code repository. You should find a solution that encrypts private keys and access them securely.
64-
65-
You can now use the account related to this private key by importing it into the Hardhat configuration file:
66-
67-
```ts title="hardhat.config.ts" hl_lines="1 17"
49+
```ts title="hardhat.config.ts" hl_lines="14-19"
6850
--8<-- "https://raw.githubusercontent.com/polkadot-developers/revm-hardhat-examples/refs/heads/master/erc20-hardhat/hardhat.config.ts::2"
6951
7052
--8<-- "https://raw.githubusercontent.com/polkadot-developers/revm-hardhat-examples/refs/heads/master/erc20-hardhat/hardhat.config.ts:24:45"
7153
```
7254

73-
## Compile your Contract
55+
!!! tip
56+
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 in a secure way.
7457

75-
Once you've configured Hardhat, you can compile the contract.
58+
## Compile the Contract
7659

77-
In this tutorial, a simple ERC-20 is provided. Therefore, to compile the contract you can run the following command:
60+
Next, compile the contract included with the template by running the following command:
7861

7962
```bash
8063
npx hardhat compile
8164
```
8265

83-
If everything compiles successfully, you should see the following output:
66+
If everything compiles successfully, you will see output similar to the following:
8467

8568
<div id="termynal" data-termynal markdown>
8669
<span data-ty="input">npx hardhat compile</span>
@@ -89,26 +72,26 @@ If everything compiles successfully, you should see the following output:
8972
<span data-ty>Compiled 21 Solidity files successfully (evm target: paris).</span>
9073
</div>
9174

92-
## Test your Contract
75+
## Test the Contract
9376

94-
Hardhat has a native feature to test contracts. You can run tests against the local Hardhat development node, but it could have some technical differences to Polkadot. Therefore, in this tutorial, you'll be testing against the Polkadot TestNet
77+
Using Hardhat's native features to test contracts against the local Hardhat development node is challenging due to some technical differences between the local node and Polkadot. This example tests contracts against the Polkadot TestNet to account for these differences.
9578
96-
This example has a predefined test file located in [`test/Token.test.js`](https://github.com/polkadot-developers/revm-hardhat-examples/blob/master/erc20-hardhat/test/MyToken.test.ts){target=\_blank}, that runs the following tests:
79+
You can view the predefined test file at [`test/MyToken.test.ts`](https://github.com/polkadot-developers/revm-hardhat-examples/blob/master/erc20-hardhat/test/MyToken.test.ts){target=\_blank}. This example test includes verification of the following:
9780
98-
1. The token was deployed by verifying its **name** and **symbol**.
99-
2. The token has the right owner configured.
100-
3. The token has an initial supply of zero.
101-
4. The owner can mint tokens.
102-
5. The total supply is increased after a mint.
103-
6. Perform multiple mints to different addresses and checks the balance of each address and the new total supply.
81+
- The token name and symbol exist (confirms deployment) and are correct.
82+
- The token owner is correctly configured.
83+
- The initial token supply is zero.
84+
- The owner can mint tokens.
85+
- The total supply increases after a mint.
86+
- Successful mints to different test addresses with correct corresponding account balance and total supply changes.
10487
105-
To run the test, you can execute the following command:
88+
Run the test using the following command:
10689
10790
```bash
10891
npx hardhat test --network polkadotTestnet
10992
```
11093
111-
If tests are successful, you should see the following logs:
94+
If tests are successful, you will see outputs similar to the following:
11295
11396
<div id="termynal" data-termynal markdown>
11497
<span data-ty="input">npx hardhat test --network polkadotTestnet</span>
@@ -127,18 +110,16 @@ If tests are successful, you should see the following logs:
127110
<span data-ty>&nbsp;&nbsp;6 passing (369ms)</span>
128111
</div>
129112
130-
## Deploy your Contract
131-
132-
With the Hardhat configuration file ready, the private key stored as a variable under **vars**, and the contract compiled, you can proceed to deploy the contract to a given network. In this tutorial, you are deploying it to the Polkadot TestNet.
113+
## Deploy the Contract
133114
134-
To deploy the contract, run the following command:
135-
136-
```bash
137-
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet
138-
```
115+
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:
139116
140-
You'll need to confirm the target network (by chain ID):
117+
1. Run the following command in your terminal:
118+
```bash
119+
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet
120+
```
141121
122+
2. Confirm the target deployment network name and chain ID when prompted:
142123
<div id="termynal" data-termynal markdown>
143124
<span data-ty="input">npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet</span>
144125
<span data-ty>✔ Confirm deploy to network polkadotTestnet (420420420)? … yes</span>
@@ -160,7 +141,7 @@ You'll need to confirm the target network (by chain ID):
160141
<span data-ty>TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3</span>
161142
</div>
162143
163-
And that is it! You've successfully deployed an ERC-20 token contract to the Polkadot TestNet using Hardhat.
144+
Congratulations! You've successfully deployed an ERC-20 token contract to the Polkadot TestNet using Hardhat.
164145

165146
## Where to Go Next
166147

0 commit comments

Comments
 (0)