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
Copy file name to clipboardExpand all lines: smart-contracts/cookbook/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Smart Contracts Cookbook Index
2
+
title: Smart Contracts Cookbook
3
3
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.
Copy file name to clipboardExpand all lines: smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md
+49-25Lines changed: 49 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,27 @@
1
1
---
2
-
title: Deploy a Basic Contract with Hardhat
2
+
title: Deploy a Contract with Hardhat
3
3
description: Learn how to deploy a basic smart contract to Polkadot Hub using Hardhat, Perfect for professional workflows requiring comprehensive testing and debugging.
4
4
categories: Smart Contracts
5
5
---
6
6
7
-
# Deploy a Basic Contract with
7
+
# Deploy Basic Contract with Hardhat
8
8
9
9
## Introduction
10
10
11
11
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.
12
12
13
13
## Prerequisites
14
14
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.
18
20
- A wallet with a private key for signing transactions.
19
21
20
22
## Set Up Your Project
21
23
22
-
Initialize your Hardhat project:
24
+
Use the following terminal commands to create a directory and initialize your Hardhat project inside of it:
23
25
24
26
```bash
25
27
mkdir hardhat-deployment
@@ -29,7 +31,7 @@ npx hardhat --init
29
31
30
32
## Configure Hardhat
31
33
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:
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.
87
89
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.
89
95
90
-
Replace the default contract in `contracts/Storage.sol`:
96
+
2. Create a new file named `Storage.sol` inside the `contracts` directory.
91
97
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:
95
99
96
-
contract Storage {
100
+
```solidity
101
+
// SPDX-License-Identifier: MIT
102
+
pragma solidity ^0.8.9;
103
+
104
+
contract Storage {
97
105
uint256 private storedNumber;
98
106
99
107
function store(uint256 num) public {
@@ -103,31 +111,47 @@ contract Storage {
103
111
function retrieve() public view returns (uint256) {
104
112
return storedNumber;
105
113
}
106
-
}
107
-
```
114
+
}
115
+
```
116
+
117
+
## Compile the Contract
108
118
109
-
## Compile
119
+
Compile your `Storage.sol` contract using the following command:
110
120
111
121
```bash
112
122
npx hardhat build
113
123
```
114
124
125
+
You will see a message in the terminal confirming the contract was successfully compiled similar to the following:
Copy file name to clipboardExpand all lines: smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,21 @@
1
1
---
2
-
title: Deploy a Basic Contract with Remix IDE
2
+
title: Deploy a Contract with Remix IDE
3
3
description: Learn how to deploy a basic smart contract to Polkadot Hub using Remix IDE Ideal for rapid prototyping, learning, and visual development.
4
4
categories: Smart Contracts
5
5
---
6
6
7
-
# Deploy a Basic Contract with Remix IDE
7
+
# Deploy Basic Contract with Remix IDE
8
8
9
9
## Introduction
10
10
11
11
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.
12
12
13
13
## Prerequisites
14
14
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.
17
19
- A wallet with a private key for signing transactions.
18
20
19
21
## Access Remix
@@ -24,16 +26,16 @@ The interface will load with a default workspace containing sample contracts. In
0 commit comments