Skip to content

Commit 70701b4

Browse files
committed
storytelling clean up cookbook --> smart-contracts
1 parent 6e80b33 commit 70701b4

File tree

6 files changed

+66
-40
lines changed

6 files changed

+66
-40
lines changed

smart-contracts/cookbook/.nav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
nav:
2-
- 'Overview': index.md # TODO: Update name of page
2+
- 'Overview': index.md
33
- 'Get Tokens from the Faucet': /smart-contracts/faucet/
44
- 'EVM Smart Contracts': smart-contracts
55
- 'Create a DApp': dapps

smart-contracts/cookbook/dapps/zero-to-hero.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ This file defines the contract address, ABI, and functions to create a viem [con
352352

353353
## Create the Wallet Connection Component
354354

355-
Now, let's create a component to handle wallet connections. Create a new file called `components/WalletConnect.tsx`:
355+
Now, you can create a component to handle wallet connections. Create a new file called `components/WalletConnect.tsx`:
356356

357357
```typescript title="WalletConnect.tsx"
358358
"use client";
@@ -535,7 +535,7 @@ This component handles connecting to the wallet, switching networks if necessary
535535

536536
## Create the Read Contract Component
537537

538-
Now, let's create a component to read data from the contract. Create a file called `components/ReadContract.tsx`:
538+
Next, create a component to read data from the contract. Create a file called `components/ReadContract.tsx`:
539539

540540
```typescript title="ReadContract.tsx"
541541
'use client';
@@ -608,7 +608,7 @@ This component reads the `storedNumber` value from the contract and displays it
608608

609609
## Create the Write Contract Component
610610

611-
Finally, let's create a component that allows users to update the stored number. Create a file called `components/WriteContract.tsx`:
611+
Finally, create a component that allows users to update the stored number. Create a file called `components/WriteContract.tsx`:
612612

613613
```typescript title="WriteContract.tsx"
614614
"use client";

smart-contracts/cookbook/eth-dapps/uniswap-v2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Before starting, make sure you have:
2828

2929
## Set Up the Project
3030

31-
Let's start by cloning the Uniswap V2 project:
31+
Start by cloning the Uniswap V2 project:
3232

3333
1. Clone the Uniswap V2 repository:
3434

smart-contracts/cookbook/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Smart Contracts Cookbook Index
2+
title: Smart Contracts Cookbook
33
description: Explore our full collection of tutorials and guides to learn step-by-step how to build, deploy, and work with smart contracts on Polkadot.
44
categories: Basics, dApps, Smart Contracts
55
---

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

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
---
2-
title: Deploy a Basic Contract with Hardhat
2+
title: Deploy a 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
---
66

7-
# Deploy a Basic Contract with
7+
# Deploy Basic Contract with Hardhat
88

99
## Introduction
1010

1111
This guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub using [Hardhat](https://hardhat.org/){target=\_blank}, which provides a comprehensive development environment with built-in testing, debugging, and deployment capabilities. It's ideal for professional development workflows and team projects.
1212

1313
## Prerequisites
1414

15-
- Basic understanding of Solidity programming.
16-
- [Node.js](https://nodejs.org/en/download){target=\_blank} v22.13.1 or later.
17-
- Test tokens for gas fees (available from the [Polkadot faucet](https://faucet.polkadot.io/){target=\_blank}). See the [step-by-step instructions](/smart-contracts/faucet/#get-test-tokens){target=\_blank}.
15+
Before you begin, ensure you have the following:
16+
17+
- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming.
18+
- [Node.js](https://nodejs.org/en/download){target=\_blank} v22.13.1 or later installed.
19+
- 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.
1820
- A wallet with a private key for signing transactions.
1921

2022
## Set Up Your Project
2123

22-
Initialize your Hardhat project:
24+
Use the following terminal commands to create a directory and initialize your Hardhat project inside of it:
2325

2426
```bash
2527
mkdir hardhat-deployment
@@ -29,7 +31,7 @@ npx hardhat --init
2931

3032
## Configure Hardhat
3133

32-
Edit `hardhat.config.js`:
34+
Open `hardhat.config.js` and update to add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code:
3335

3436
```javascript title='hardhat.config.js' hl_lines='39-43'
3537
import type { HardhatUserConfig } from 'hardhat/config';
@@ -85,15 +87,21 @@ export default config;
8587
!!! tip
8688
Learn how to use Hardhat's [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} to handle your private keys in a secure way.
8789

88-
## Create Your Contract
90+
## Create the Contract
91+
92+
Follow these steps to create your smart contract:
93+
94+
1. Delete the default contract file(s) in the `contracts` directory.
8995

90-
Replace the default contract in `contracts/Storage.sol`:
96+
2. Create a new file named `Storage.sol` inside the `contracts` directory.
9197

92-
```solidity
93-
// SPDX-License-Identifier: MIT
94-
pragma solidity ^0.8.9;
98+
3. Add the following code to create the `Storage.sol` smart contract:
9599

96-
contract Storage {
100+
```solidity
101+
// SPDX-License-Identifier: MIT
102+
pragma solidity ^0.8.9;
103+
104+
contract Storage {
97105
uint256 private storedNumber;
98106
99107
function store(uint256 num) public {
@@ -103,31 +111,47 @@ contract Storage {
103111
function retrieve() public view returns (uint256) {
104112
return storedNumber;
105113
}
106-
}
107-
```
114+
}
115+
```
116+
117+
## Compile the Contract
108118

109-
## Compile
119+
Compile your `Storage.sol` contract using the following command:
110120

111121
```bash
112122
npx hardhat build
113123
```
114124

125+
You will see a message in the terminal confirming the contract was successfully compiled similar to the following:
126+
127+
<div id="termynal" data-termynal>
128+
<span data-ty="input"><span class="file-path"></span>npx hardhat build</span>
129+
<span data-ty>Downloading solc 0.8.28</span>
130+
<span data-ty>Downloading solc 0.8.28 (WASM build)</span>
131+
<span data-ty>Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun)</span>
132+
<span data-ty="input"><span class="file-path"></span></span>
133+
</div>
134+
115135
## Set Up Deployment
116136

117-
Create a deployment module in `ignition/modules/Storage.ts`:
137+
1. Delete the default file(s) inside the `ignition/modules` directory.
118138

119-
```typescript title="ignition/modules/Storage.ts"
120-
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules';
139+
2. Create a new file named `Storage.ts` inside the `ignition/modules` directory.
121140

122-
export default buildModule('StorageModule', (m) => {
123-
const storage = m.contract('Storage');
124-
return { storage };
125-
});
126-
```
141+
3. Open `ignition/modules/Storage.ts` and add the following code to create your deployment module:
142+
143+
```typescript title="ignition/modules/Storage.ts"
144+
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules';
145+
146+
export default buildModule('StorageModule', (m) => {
147+
const storage = m.contract('Storage');
148+
return { storage };
149+
});
150+
```
127151

128152
## Deploy the Contract
129153

130-
Deploy to Polkadot Hub TestNet:
154+
Deploy your contract to Polkadot Hub TestNet using the following command:
131155

132156
```bash
133157
npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTestnet

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
---
2-
title: Deploy a Basic Contract with Remix IDE
2+
title: Deploy a 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
---
66

7-
# Deploy a Basic Contract with Remix IDE
7+
# Deploy Basic Contract with Remix IDE
88

99
## Introduction
1010

1111
This guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub using [Remix IDE](https://remix.ethereum.org/){target=\_blank}, which offers a visual, browser-based environment perfect for rapid prototyping and learning. It requires no local installation and provides an intuitive interface for contract development.
1212

1313
## Prerequisites
1414

15-
- Basic understanding of Solidity programming.
16-
- Test tokens for gas fees (available from the [Polkadot faucet](https://faucet.polkadot.io/){target=\_blank}). See the [step-by-step instructions](/smart-contracts/faucet/#get-test-tokens){target=\_blank}.
15+
Before you begin, ensure you have the following:
16+
17+
- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming.
18+
- 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.
1719
- A wallet with a private key for signing transactions.
1820

1921
## Access Remix
@@ -24,16 +26,16 @@ The interface will load with a default workspace containing sample contracts. In
2426

2527
![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-01.webp)
2628

27-
## Compile
29+
## Compile the Contract
2830

29-
1. Navigate to the **Solidity Compiler** tab, which is the third icon in the left sidebar.
31+
1. Navigate to the **Solidity Compiler** tab.
3032
2. Click **Compile Storage.sol** or press `Ctrl+S`.
3133

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

34-
Compilation errors and warnings appear in the terminal panel at the bottom of the screen.
36+
If any issues arise during Compilation, errors and warnings will appear in the terminal panel at the bottom of the screen.
3537

36-
## Deploy
38+
## Deploy the Contract
3739

3840
1. Navigate to the **Deploy & Run Transactions** tab.
3941
2. Click the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet).
@@ -42,7 +44,7 @@ Compilation errors and warnings appear in the terminal panel at the bottom of th
4244

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

45-
Your deployed contract will appear in the **Deployed Contracts** section, ready for interaction.
47+
Once successfully deployed, your contract will appear in the **Deployed Contracts** section, ready for interaction.
4648

4749
## Where to Go Next
4850

0 commit comments

Comments
 (0)