From 70701b4afe8830008a7878bce80aeb2dad71593c Mon Sep 17 00:00:00 2001 From: DAWN KELLY Date: Mon, 17 Nov 2025 12:01:29 -0500 Subject: [PATCH 1/8] storytelling clean up cookbook --> smart-contracts --- smart-contracts/cookbook/.nav.yml | 2 +- .../cookbook/dapps/zero-to-hero.md | 6 +- .../cookbook/eth-dapps/uniswap-v2.md | 2 +- smart-contracts/cookbook/index.md | 2 +- .../smart-contracts/deploy-basic/hardhat.md | 74 ++++++++++++------- .../smart-contracts/deploy-basic/remix.md | 20 ++--- 6 files changed, 66 insertions(+), 40 deletions(-) diff --git a/smart-contracts/cookbook/.nav.yml b/smart-contracts/cookbook/.nav.yml index 967a352ff..34648a128 100644 --- a/smart-contracts/cookbook/.nav.yml +++ b/smart-contracts/cookbook/.nav.yml @@ -1,5 +1,5 @@ nav: -- 'Overview': index.md # TODO: Update name of page +- 'Overview': index.md - 'Get Tokens from the Faucet': /smart-contracts/faucet/ - 'EVM Smart Contracts': smart-contracts - 'Create a DApp': dapps diff --git a/smart-contracts/cookbook/dapps/zero-to-hero.md b/smart-contracts/cookbook/dapps/zero-to-hero.md index d45dc3a05..591380895 100644 --- a/smart-contracts/cookbook/dapps/zero-to-hero.md +++ b/smart-contracts/cookbook/dapps/zero-to-hero.md @@ -352,7 +352,7 @@ This file defines the contract address, ABI, and functions to create a viem [con ## Create the Wallet Connection Component -Now, let's create a component to handle wallet connections. Create a new file called `components/WalletConnect.tsx`: +Now, you can create a component to handle wallet connections. Create a new file called `components/WalletConnect.tsx`: ```typescript title="WalletConnect.tsx" "use client"; @@ -535,7 +535,7 @@ This component handles connecting to the wallet, switching networks if necessary ## Create the Read Contract Component -Now, let's create a component to read data from the contract. Create a file called `components/ReadContract.tsx`: +Next, create a component to read data from the contract. Create a file called `components/ReadContract.tsx`: ```typescript title="ReadContract.tsx" 'use client'; @@ -608,7 +608,7 @@ This component reads the `storedNumber` value from the contract and displays it ## Create the Write Contract Component -Finally, let's create a component that allows users to update the stored number. Create a file called `components/WriteContract.tsx`: +Finally, create a component that allows users to update the stored number. Create a file called `components/WriteContract.tsx`: ```typescript title="WriteContract.tsx" "use client"; diff --git a/smart-contracts/cookbook/eth-dapps/uniswap-v2.md b/smart-contracts/cookbook/eth-dapps/uniswap-v2.md index c4bb1c79c..ef1ea1131 100644 --- a/smart-contracts/cookbook/eth-dapps/uniswap-v2.md +++ b/smart-contracts/cookbook/eth-dapps/uniswap-v2.md @@ -28,7 +28,7 @@ Before starting, make sure you have: ## Set Up the Project -Let's start by cloning the Uniswap V2 project: +Start by cloning the Uniswap V2 project: 1. Clone the Uniswap V2 repository: diff --git a/smart-contracts/cookbook/index.md b/smart-contracts/cookbook/index.md index 3245654d9..7586ecbee 100644 --- a/smart-contracts/cookbook/index.md +++ b/smart-contracts/cookbook/index.md @@ -1,5 +1,5 @@ --- -title: Smart Contracts Cookbook Index +title: Smart Contracts Cookbook 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. categories: Basics, dApps, Smart Contracts --- diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md index f9255021b..6d841e673 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md @@ -1,10 +1,10 @@ --- -title: Deploy a Basic Contract with Hardhat +title: Deploy a Contract with Hardhat description: Learn how to deploy a basic smart contract to Polkadot Hub using Hardhat, Perfect for professional workflows requiring comprehensive testing and debugging. categories: Smart Contracts --- -# Deploy a Basic Contract with +# Deploy Basic Contract with Hardhat ## Introduction @@ -12,14 +12,16 @@ This guide demonstrates how to deploy a basic Solidity smart contract to Polkado ## Prerequisites -- Basic understanding of Solidity programming. -- [Node.js](https://nodejs.org/en/download){target=\_blank} v22.13.1 or later. -- 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}. +Before you begin, ensure you have the following: + +- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming. +- [Node.js](https://nodejs.org/en/download){target=\_blank} v22.13.1 or later installed. +- 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. - A wallet with a private key for signing transactions. ## Set Up Your Project -Initialize your Hardhat project: +Use the following terminal commands to create a directory and initialize your Hardhat project inside of it: ```bash mkdir hardhat-deployment @@ -29,7 +31,7 @@ npx hardhat --init ## Configure Hardhat -Edit `hardhat.config.js`: +Open `hardhat.config.js` and update to add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: ```javascript title='hardhat.config.js' hl_lines='39-43' import type { HardhatUserConfig } from 'hardhat/config'; @@ -85,15 +87,21 @@ export default config; !!! tip 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. -## Create Your Contract +## Create the Contract + +Follow these steps to create your smart contract: + +1. Delete the default contract file(s) in the `contracts` directory. -Replace the default contract in `contracts/Storage.sol`: +2. Create a new file named `Storage.sol` inside the `contracts` directory. -```solidity -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.9; +3. Add the following code to create the `Storage.sol` smart contract: -contract Storage { + ```solidity + // SPDX-License-Identifier: MIT + pragma solidity ^0.8.9; + + contract Storage { uint256 private storedNumber; function store(uint256 num) public { @@ -103,31 +111,47 @@ contract Storage { function retrieve() public view returns (uint256) { return storedNumber; } -} -``` + } + ``` + +## Compile the Contract -## Compile +Compile your `Storage.sol` contract using the following command: ```bash npx hardhat build ``` +You will see a message in the terminal confirming the contract was successfully compiled similar to the following: + +
+ npx hardhat build + Downloading solc 0.8.28 + Downloading solc 0.8.28 (WASM build) + Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun) + +
+ ## Set Up Deployment -Create a deployment module in `ignition/modules/Storage.ts`: +1. Delete the default file(s) inside the `ignition/modules` directory. -```typescript title="ignition/modules/Storage.ts" -import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; +2. Create a new file named `Storage.ts` inside the `ignition/modules` directory. -export default buildModule('StorageModule', (m) => { - const storage = m.contract('Storage'); - return { storage }; -}); -``` +3. Open `ignition/modules/Storage.ts` and add the following code to create your deployment module: + + ```typescript title="ignition/modules/Storage.ts" + import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; + + export default buildModule('StorageModule', (m) => { + const storage = m.contract('Storage'); + return { storage }; + }); + ``` ## Deploy the Contract -Deploy to Polkadot Hub TestNet: +Deploy your contract to Polkadot Hub TestNet using the following command: ```bash npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTestnet diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md index 2618936b9..39ae8f298 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md @@ -1,10 +1,10 @@ --- -title: Deploy a Basic Contract with Remix IDE +title: Deploy a Contract with Remix IDE description: Learn how to deploy a basic smart contract to Polkadot Hub using Remix IDE Ideal for rapid prototyping, learning, and visual development. categories: Smart Contracts --- -# Deploy a Basic Contract with Remix IDE +# Deploy Basic Contract with Remix IDE ## Introduction @@ -12,8 +12,10 @@ This guide demonstrates how to deploy a basic Solidity smart contract to Polkado ## Prerequisites -- Basic understanding of Solidity programming. -- 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}. +Before you begin, ensure you have the following: + +- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming. +- 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. - A wallet with a private key for signing transactions. ## Access Remix @@ -24,16 +26,16 @@ The interface will load with a default workspace containing sample contracts. In ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-01.webp) -## Compile +## Compile the Contract -1. Navigate to the **Solidity Compiler** tab, which is the third icon in the left sidebar. +1. Navigate to the **Solidity Compiler** tab. 2. Click **Compile Storage.sol** or press `Ctrl+S`. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-02.webp) -Compilation errors and warnings appear in the terminal panel at the bottom of the screen. +If any issues arise during Compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. -## Deploy +## Deploy the Contract 1. Navigate to the **Deploy & Run Transactions** tab. 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 ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-03.webp) -Your deployed contract will appear in the **Deployed Contracts** section, ready for interaction. +Once successfully deployed, your contract will appear in the **Deployed Contracts** section, ready for interaction. ## Where to Go Next From 9705924cc49f7b9034c4c2395a05d0f3ca35be1e Mon Sep 17 00:00:00 2001 From: DAWN KELLY Date: Mon, 17 Nov 2025 13:52:40 -0500 Subject: [PATCH 2/8] more storytelling/formatting cleanup for cookbooks/smart contracts --- .../smart-contracts/deploy-basic/hardhat.md | 2 +- .../smart-contracts/deploy-basic/remix.md | 15 ++- .../deploy-erc20/erc20-hardhat.md | 93 +++++++----------- .../deploy-erc20/erc20-remix.md | 96 ++++++------------- 4 files changed, 78 insertions(+), 128 deletions(-) diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md index 6d841e673..dc3c8e693 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md @@ -1,5 +1,5 @@ --- -title: Deploy a Contract with Hardhat +title: Deploy Basic Contract with Hardhat description: Learn how to deploy a basic smart contract to Polkadot Hub using Hardhat, Perfect for professional workflows requiring comprehensive testing and debugging. categories: Smart Contracts --- diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md index 39ae8f298..acec09658 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md @@ -1,5 +1,5 @@ --- -title: Deploy a Contract with Remix IDE +title: Deploy Basic Contract with Remix IDE description: Learn how to deploy a basic smart contract to Polkadot Hub using Remix IDE Ideal for rapid prototyping, learning, and visual development. categories: Smart Contracts --- @@ -28,8 +28,11 @@ The interface will load with a default workspace containing sample contracts. In ## Compile the Contract -1. Navigate to the **Solidity Compiler** tab. -2. Click **Compile Storage.sol** or press `Ctrl+S`. +Ensure your contract is open in the Remix IDE Editor, and use the follow steps to compile: + +1. Select the **Solidity Compiler** plugin from the left panel. +2. Select the **Compile MyToken.sol** button. +3. The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-02.webp) @@ -37,9 +40,11 @@ If any issues arise during Compilation, errors and warnings will appear in the t ## Deploy the Contract +Follow these steps to deploy the contract using Remix: + 1. Navigate to the **Deploy & Run Transactions** tab. -2. Click the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet). -3. Click **Deploy**. +2. Select the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet). +3. Select **Deploy**. 4. Approve the transaction in your MetaMask wallet. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-03.webp) diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md index 04ded0978..f3889f415 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md @@ -1,26 +1,27 @@ --- -title: Deploy an ERC-20 to Polkadot Hub +title: Deploy ERC-20 Using Hardhat description: Deploy an ERC-20 token on Polkadot Hub using PolkaVM. This guide covers contract creation, compilation, deployment, and interaction via Hardhat. tutorial_badge: Intermediate categories: Basics, Smart Contracts tools: Hardhat --- -# Deploy an ERC-20 to Polkadot Hub +# Deploy ERC-20 Using Hardhat ## Introduction -[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. +[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. -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}. +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}. ## Prerequisites -Before starting, make sure you have: +Before you begin, ensure sure you have the following: -- Basic understanding of Solidity programming and fungible tokens. -- Node.js v22.13.1 or later. -- 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}. +- 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. +- Node.js v22.13.1 or later installed. +- 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. +- A wallet with a private key for signing transactions. ## Set Up Your Project @@ -38,49 +39,31 @@ This tutorial uses a [Hardhat ERC-20 template](https://github.com/polkadot-devel ```bash npm i ``` - -This will fetch all the necessary packages to help you deploy an ERC-20 with Hardhat to Polkadot. + + This will fetch all the necessary packages to help you deploy an ERC-20 with Hardhat to Polkadot. ## Configure Hardhat -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. - -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: - -```bash -npx hardhat vars set TESTNET_PRIVATE_KEY -``` - -The command will initiate a wizard in which you'll have to enter the value to be stored: +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: -
- npx hardhat vars set TESTNET_PRIVATE_KEY - ✔ Enter value: · ••••••••• - The configuration variable has been stored in /Users/albertoviera/Library/Preferences/hardhat-nodejs/vars.json -
- -??? warning "Key Encryption" - 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. - -You can now use the account related to this private key by importing it into the Hardhat configuration file: - -```ts title="hardhat.config.ts" hl_lines="1 17" +```ts title="hardhat.config.ts" hl_lines="14-19" --8<-- "https://raw.githubusercontent.com/polkadot-developers/revm-hardhat-examples/refs/heads/master/erc20-hardhat/hardhat.config.ts::2" --8<-- "https://raw.githubusercontent.com/polkadot-developers/revm-hardhat-examples/refs/heads/master/erc20-hardhat/hardhat.config.ts:24:45" ``` -## Compile your Contract +!!! tip + 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. -Once you've configured Hardhat, you can compile the contract. +## Compile the Contract -In this tutorial, a simple ERC-20 is provided. Therefore, to compile the contract you can run the following command: +Next, compile the contract included with the template by running the following command: ```bash npx hardhat compile ``` -If everything compiles successfully, you should see the following output: +If everything compiles successfully, you will see output similar to the following:
npx hardhat compile @@ -89,26 +72,26 @@ If everything compiles successfully, you should see the following output: Compiled 21 Solidity files successfully (evm target: paris).
-## Test your Contract +## Test the Contract -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 +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. -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: +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: -1. The token was deployed by verifying its **name** and **symbol**. -2. The token has the right owner configured. -3. The token has an initial supply of zero. -4. The owner can mint tokens. -5. The total supply is increased after a mint. -6. Perform multiple mints to different addresses and checks the balance of each address and the new total supply. +- The token name and symbol exist (confirms deployment) and are correct. +- The token owner is correctly configured. +- The initial token supply is zero. +- The owner can mint tokens. +- The total supply increases after a mint. +- Successful mints to different test addresses with correct corresponding account balance and total supply changes. -To run the test, you can execute the following command: +Run the test using the following command: ```bash npx hardhat test --network polkadotTestnet ``` -If tests are successful, you should see the following logs: +If tests are successful, you will see outputs similar to the following:
npx hardhat test --network polkadotTestnet @@ -127,18 +110,16 @@ If tests are successful, you should see the following logs:   6 passing (369ms)
-## Deploy your Contract - -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. +## Deploy the Contract -To deploy the contract, run the following command: - -```bash -npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet -``` +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: -You'll need to confirm the target network (by chain ID): +1. Run the following command in your terminal: + ```bash + npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet + ``` +2. Confirm the target deployment network name and chain ID when prompted:
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet ✔ Confirm deploy to network polkadotTestnet (420420420)? … yes @@ -160,7 +141,7 @@ You'll need to confirm the target network (by chain ID): TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3
-And that is it! You've successfully deployed an ERC-20 token contract to the Polkadot TestNet using Hardhat. +Congratulations! You've successfully deployed an ERC-20 token contract to the Polkadot TestNet using Hardhat. ## Where to Go Next diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md index 48da3e2a3..75e0a2c15 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md @@ -1,111 +1,81 @@ --- -title: Deploy an ERC-20 to Polkadot Hub +title: Deploy ERC-20 Using Remix IDE description: Deploy an ERC-20 token contract on Polkadot Hub. This guide covers contract creation, compilation, deployment, and interaction via the Remix IDE. tutorial_badge: Beginner categories: Basics, Smart Contracts tools: EVM Wallet, Remix --- -# Deploy an ERC-20 to Polkadot Hub +# Deploy ERC-20 Using Remix IDE ## Introduction [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. -This tutorial covers deploying an ERC-20 contract on the Polkadot Hub TestNet using [Remix IDE](https://remix.ethereum.org/){target=\_blank}, a web-based development tool. 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}. +This tutorial covers deploying an ERC-20 contract on the Polkadot Hub TestNet using [Remix IDE](https://remix.ethereum.org/){target=\_blank}, a web-based development tool. 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}. ## Prerequisites -Before starting, make sure you have: +Before you begin, ensure you have: -- Basic understanding of Solidity programming and fungible tokens. -- An EVM-compatible wallet [connected to Polkadot Hub](/smart-contracts/integrations/wallets){target=\_blank}. This example utilizes [MetaMask](https://metamask.io/){target=\_blank}. -- 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}. +- 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. +- An EVM-compatible [wallet](/smart-contracts/integrations/wallets){target=\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\_blank}. +- 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. ## Create Your Contract -To create the ERC-20 contract, you can follow the steps below: +Follow the steps below to create the ERC-20 contract: 1. Navigate to the [Polkadot Remix IDE](https://remix.polkadot.io){target=\_blank}. -2. Click in the **Create new file** button under the **contracts** folder, and name your contract as `MyToken.sol`. +2. Select the **Create new file** button under the **contracts** folder, and name your contract `MyToken.sol`. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-1.webp) -3. Now, paste the following ERC-20 contract code into the editor: +3. Now, paste the following ERC-20 contract code into `myToken.sol`: ```solidity title="MyToken.sol" --8<-- 'https://raw.githubusercontent.com/polkadot-developers/revm-hardhat-examples/refs/heads/master/erc20-hardhat/contracts/MyToken.sol' ``` - - The key components of the code above are: - - - Contract imports: - - - **[`ERC20.sol`]({{ dependencies.repositories.open_zeppelin_contracts.repository_url}}/tree/{{ dependencies.repositories.open_zeppelin_contracts.version}}/contracts/token/ERC20/ERC20.sol){target=\_blank}**: The base contract for fungible tokens, implementing core functionality like transfers, approvals, and balance tracking. - - **[`ERC20Permit.sol`]({{ dependencies.repositories.open_zeppelin_contracts.repository_url}}/tree/{{ dependencies.repositories.open_zeppelin_contracts.version}}/contracts/token/ERC20/extensions/ERC20Permit.sol){target=\_blank}**: [EIP-2612](https://eips.ethereum.org/EIPS/eip-2612){target=\_blank} extension for ERC-20 that adds the [permit function](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-){target=\_blank}, allowing approvals via off-chain signatures (no on-chain tx from the holder). Manages nonces and EIP-712 domain separator and updates allowances when a valid signature is presented. - - **[`Ownable.sol`]({{ dependencies.repositories.open_zeppelin_contracts.repository_url}}/tree/{{ dependencies.repositories.open_zeppelin_contracts.version}}/contracts/access/Ownable.sol){target=\_blank}**: Provides basic authorization control, ensuring only the contract owner can mint new tokens. - - Constructor parameters: - - - **`initialOwner`**: Sets the address that will have administrative rights over the contract. - - **`"MyToken"`**: The full name of your token. - - **`"MTK"`**: The symbol representing your token in wallets and exchanges. - - - Key functions: - - - **`mint(address to, uint256 amount)`**: Allows the contract owner to create new tokens for any address. The amount should include 18 decimals (e.g., 1 token = 1000000000000000000). - - Inherited [Standard ERC-20](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/){target=\_blank} functions: - - **`transfer(address recipient, uint256 amount)`**: Sends a specified amount of tokens to another address. - - **`approve(address spender, uint256 amount)`**: Grants permission for another address to spend a specific number of tokens on behalf of the token owner. - - **`transferFrom(address sender, address recipient, uint256 amount)`**: Transfers tokens from one address to another, if previously approved. - - **`balanceOf(address account)`**: Returns the token balance of a specific address. - - **`allowance(address owner, address spender)`**: Checks how many tokens an address is allowed to spend on behalf of another address. - !!! tip - Use the [OpenZeppelin Contracts Wizard](https://wizard.openzeppelin.com/){target=\_blank} to generate customized smart contracts quickly. Simply configure your contract, copy the generated code, and paste it into the Remix IDE for deployment. Below is an example of an ERC-20 token contract created with it: - - ![Screenshot of the OpenZeppelin Contracts Wizard showing an ERC-20 contract configuration.](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-2.webp) + The [OpenZeppelin Contracts Wizard](https://wizard.openzeppelin.com/){target=\_blank} was used to generate this example ERC-20 contract. +## Compile the Contract -## Compile +Solidity source code compiles into bytecode that can be deployed on the blockchain. During this process, the compiler checks the contract for syntax errors, ensures type safety, and generates the machine-readable instructions needed for blockchain execution. -The compilation transforms your Solidity source code into bytecode that can be deployed on the blockchain. During this process, the compiler checks your contract for syntax errors, ensures type safety, and generates the machine-readable instructions needed for blockchain execution. - -To compile your contract, ensure you have it opened in the Remix IDE Editor, and follow the instructions below: +Ensure your contract is open in the Remix IDE Editor, and use the follow steps to compile: 1. Select the **Solidity Compiler** plugin from the left panel. -2. Click the **Compile MyToken.sol** button. -3. If the compilation succeeded, you'll see a green checkmark indicating success in the **Solidity Compiler** icon. - -![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-3.gif) +2. Select the **Compile MyToken.sol** button. +3. The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. -## Deploy +If any issues arise during Compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. -Deployment is the process of publishing your compiled smart contract to the blockchain, making it permanently available for interaction. During deployment, you'll create a new instance of your contract on the blockchain, which involves: +![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-3.gif) -1. Select the **Deploy & Run Transactions** plugin from the left panel. -2. Configure the deployment settings: - 1. From the **ENVIRONMENT** dropdown, select **Injected Provider - MetaMask** (check the [Deploying Contracts](/smart-contracts/dev-environments/remix/deploy-a-contract/){target=\_blank} section of the Remix IDE guide for more details). - 2. (Optional) From the **ACCOUNT** dropdown, select the acccount you want to use for the deploy. +## Deploy the Contract -3. Configure the contract parameters: - 1. Enter the address that will own the deployed token contract. - 2. Click the **Deploy** button to initiate the deployment. +Follow these steps to deploy the contract using Remix: -4. **MetaMask will pop up**: Review the transaction details. Click **Confirm** to deploy your contract. -5. If the deployment process succeeded, you will see the transaction details in the terminal, including the contract address and deployment transaction hash. +1. Select **Deploy & Run Transactions** from the left panel. +2. Select the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet). +3. Configure the contract parameters to enter the address that will own the deployed token contract. +4. Click the **Deploy** button to initiate the deployment. +5. Approve the transaction in your MetaMask wallet. +6. If the deployment process succeeded, you will see the transaction details in the terminal, including the contract address and deployment transaction hash. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-4.gif) -## Interact with Your Contract +## Interact With the Contract -Once deployed, you can interact with your contract through Remix. Find your contract under **Deployed/Unpinned Contracts**, and click it to expand the available methods. In this example, you'll mint some tokens to a given address: +Once deployed, you can interact with your contract through Remix. Find your contract under **Deployed/Unpinned Contracts**, and click it to expand the available methods. In this example, you'll mint some tokens to a given address using the following steps: 1. Expand the **mint** function: 1. Enter the recipient address and the amount (remember to add 18 zeros for 1 whole token). 2. Click **transact**. -2. Click **Approve** to confirm the transaction in the MetaMask popup. +2. Approve the transaction in the MetaMask popup. 3. If the transaction succeeds, you will see a green check mark in the terminal. @@ -113,13 +83,7 @@ Once deployed, you can interact with your contract through Remix. Find your cont ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-5.gif) - -Other standard functions you can use: - -- **`transfer(address to, uint256 amount)`**: Send tokens to another address. -- **`approve(address spender, uint256 amount)`**: Allow another address to spend your tokens. - -Feel free to explore and interact with the contract's other functions using the same approach: select the method, provide any required parameters, and confirm the transaction in MetaMask when needed. +Feel free to explore and interact with the contract's other functions by selecting the method, providing any required parameters, and confirming the transaction in MetaMask when prompted. ## Where to Go Next From 95d4479a93552765e56103d143aa6f2c63261180 Mon Sep 17 00:00:00 2001 From: DAWN KELLY Date: Mon, 17 Nov 2025 14:55:27 -0500 Subject: [PATCH 3/8] storytelling cleanup --- .../cookbook/smart-contracts/.nav.yml | 6 +- .../smart-contracts/deploy-basic/.nav.yml | 4 +- .../{hardhat.md => basic-hardhat.md} | 10 +-- .../deploy-basic/{remix.md => basic-remix.md} | 4 +- .../smart-contracts/deploy-erc20/.nav.yml | 2 +- .../deploy-erc20/erc20-hardhat.md | 2 +- .../deploy-erc20/erc20-remix.md | 4 +- .../smart-contracts/deploy-nft/.nav.yml | 4 +- .../deploy-nft/{hardhat.md => nft-hardhat.md} | 64 +++++++++++++------ .../deploy-nft/{remix.md => nft-remix.md} | 2 +- 10 files changed, 65 insertions(+), 37 deletions(-) rename smart-contracts/cookbook/smart-contracts/deploy-basic/{hardhat.md => basic-hardhat.md} (96%) rename smart-contracts/cookbook/smart-contracts/deploy-basic/{remix.md => basic-remix.md} (97%) rename smart-contracts/cookbook/smart-contracts/deploy-nft/{hardhat.md => nft-hardhat.md} (63%) rename smart-contracts/cookbook/smart-contracts/deploy-nft/{remix.md => nft-remix.md} (98%) diff --git a/smart-contracts/cookbook/smart-contracts/.nav.yml b/smart-contracts/cookbook/smart-contracts/.nav.yml index d1235a445..efd9a3f2b 100644 --- a/smart-contracts/cookbook/smart-contracts/.nav.yml +++ b/smart-contracts/cookbook/smart-contracts/.nav.yml @@ -1,4 +1,4 @@ nav: -- 'Deploy a Basic Contract': deploy-basic -- 'Deploy an ERC-20': deploy-erc20 -- 'Deploy an NFT': deploy-nft +- 'Deploy Basic Contract': deploy-basic +- 'Deploy ERC-20 Token': deploy-erc20 +- 'Deploy ERC-721 NFT': deploy-nft diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/.nav.yml b/smart-contracts/cookbook/smart-contracts/deploy-basic/.nav.yml index 65e5ee766..0d5583479 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/.nav.yml +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/.nav.yml @@ -1,4 +1,4 @@ nav: - - 'Using Remix IDE': remix.md - - 'Using Hardhat': hardhat.md + - 'Remix IDE': basic-remix.md + - 'Hardhat': basic-hardhat.md # - 'Using Foundry': foundry.md diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md similarity index 96% rename from smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md rename to smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md index dc3c8e693..cce15fe85 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md @@ -119,13 +119,13 @@ Follow these steps to create your smart contract: Compile your `Storage.sol` contract using the following command: ```bash -npx hardhat build +npx hardhat compile ``` You will see a message in the terminal confirming the contract was successfully compiled similar to the following:
- npx hardhat build + npx hardhat compile Downloading solc 0.8.28 Downloading solc 0.8.28 (WASM build) Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun) @@ -134,6 +134,8 @@ You will see a message in the terminal confirming the contract was successfully ## Set Up Deployment +Follow these steps to prepare for contract deployment: + 1. Delete the default file(s) inside the `ignition/modules` directory. 2. Create a new file named `Storage.ts` inside the `ignition/modules` directory. @@ -175,7 +177,7 @@ npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTes Walk through deploying a fully-functional ERC-20 to the Polkadot Hub using Hardhat. - [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/hardhat/) + [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/) - Guide __Deploy an NFT__ @@ -183,6 +185,6 @@ npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTes Walk through deploying a NFT to the Polkadot Hub using Hardhat. - [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/hardhat/) + [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/)
\ No newline at end of file diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md similarity index 97% rename from smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md rename to smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md index acec09658..938f4610f 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md @@ -69,7 +69,7 @@ Once successfully deployed, your contract will appear in the **Deployed Contract Walk through deploying a fully-functional ERC-20 to the Polkadot Hub using Remix. - [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/remix/) + [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/) - Guide __Deploy an NFT__ @@ -77,6 +77,6 @@ Once successfully deployed, your contract will appear in the **Deployed Contract Walk through deploying a NFT to the Polkadot Hub using Remix. - [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/) + [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/) \ No newline at end of file diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/.nav.yml b/smart-contracts/cookbook/smart-contracts/deploy-erc20/.nav.yml index 377ab7153..0f6a29940 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/.nav.yml +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/.nav.yml @@ -1,5 +1,5 @@ title: Deploy an ERC-20 nav: -- 'Remix': erc20-remix.md +- 'Remix IDE': erc20-remix.md - 'Hardhat': erc20-hardhat.md # - 'Foundry': erc20-foundry.md \ No newline at end of file diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md index f3889f415..4a384a5f3 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md @@ -153,6 +153,6 @@ Congratulations! You've successfully deployed an ERC-20 token contract to the Po Walk through deploying an ERC-721 Non-Fungible Token (NFT) using OpenZeppelin's battle-tested NFT implementation and Remix. - [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/) + [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/) \ No newline at end of file diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md index 75e0a2c15..a6957a78c 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md @@ -63,7 +63,7 @@ Follow these steps to deploy the contract using Remix: 3. Configure the contract parameters to enter the address that will own the deployed token contract. 4. Click the **Deploy** button to initiate the deployment. 5. Approve the transaction in your MetaMask wallet. -6. If the deployment process succeeded, you will see the transaction details in the terminal, including the contract address and deployment transaction hash. +6. You will see the transaction details in the terminal when the deployment succeeds, including the contract address and deployment transaction hash. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-4.gif) @@ -95,6 +95,6 @@ Feel free to explore and interact with the contract's other functions by selecti Walk through deploying an ERC-721 Non-Fungible Token (NFT) using OpenZeppelin's battle-tested NFT implementation and Remix. - [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/) + [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/) \ No newline at end of file diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/.nav.yml b/smart-contracts/cookbook/smart-contracts/deploy-nft/.nav.yml index d4ecb3804..77633ec86 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/.nav.yml +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/.nav.yml @@ -1,4 +1,4 @@ nav: -- 'Using Remix': remix.md -- 'Using Hardhat': hardhat.md +- 'Remix IDE': nft-remix.md +- 'Hardhat': nft-hardhat.md # - 'Using Foundry': foundry.md diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md similarity index 63% rename from smart-contracts/cookbook/smart-contracts/deploy-nft/hardhat.md rename to smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md index 22f09f8fb..5a2b9117d 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md @@ -1,31 +1,31 @@ --- -title: Deploy an NFT to Polkadot Hub with Hardhat +title: Deploy ERC-721 Using Hardhat description: Learn how to deploy an ERC-721 NFT contract to Polkadot Hub with Hardhat, a comprehenive development environment with built-in deployment capabilities. tutorial_badge: Beginner categories: Basics, Smart Contracts tools: EVM Wallet, Hardhat --- -# Deploy an NFT with Hardhat +# Deploy ERC-721 Using Hardhat ## Introduction Non-Fungible Tokens (NFTs) represent unique digital assets commonly used for digital art, collectibles, gaming, and identity verification. -This guide demonstrates how to deploy an [ERC-721](https://eips.ethereum.org/EIPS/eip-721){target=\_blank} NFT contract to [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\_blank}. You'll use [OpenZeppelin's battle-tested NFT implementation](https://github.com/OpenZeppelin/openzeppelin-contracts){target=\_blank} and [Hardhat](https://hardhat.org/docs/getting-started){target=\_blank}, a comprehensive development environment with built-in testing, debugging, and deployment capabilities. Hardhat uses standard Solidity compilation to generate EVM bytecode, making it fully compatible with Polkadot Hub's EVM environment. +This guide demonstrates how to deploy an [ERC-721](https://eips.ethereum.org/EIPS/eip-721){target=\_blank} NFT contract to [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\_blank}. You'll use OpenZeppelin's battle-tested [NFT implementation](https://github.com/OpenZeppelin/openzeppelin-contracts){target=\_blank} and [Hardhat](https://hardhat.org/docs/getting-started){target=\_blank}, a comprehensive development environment with built-in testing, debugging, and deployment capabilities. Hardhat uses standard Solidity compilation to generate EVM bytecode, making it fully compatible with Polkadot Hub's EVM environment. ## Prerequisites -- Basic understanding of Solidity programming and NFT standards. -- Node.js v22.13.1 or later. -- 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}. +Before you begin, ensure you have the following: + +- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming and [ERC-721](https://ethereum.org/developers/docs/standards/tokens/erc-721/){target=\_blank} non-fungible tokens. +- Node.js v22.13.1 or later installed. +- 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. - A wallet with a private key for signing transactions. ## Set Up Your Project -Take the following steps to get started: - -1. Initialize your Hardhat project: +1. Use the following terminal commands to create a directory and initialize your Hardhat project inside of it: ```bash mkdir hardhat-nft-deployment @@ -33,7 +33,7 @@ Take the following steps to get started: npx hardhat --init ``` -2. Install OpenZeppelin contracts: +2. Install the OpenZeppelin contract dependencies using the command: ```bash npm install @openzeppelin/contracts @@ -41,9 +41,9 @@ Take the following steps to get started: ## Configure Hardhat -Edit `hardhat.config.ts`: +Open `hardhat.config.js` and update to add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: -```typescript title="hardhat.config.ts" +```typescript title="hardhat.config.ts" hl_lines='39-44' import type { HardhatUserConfig } from 'hardhat/config'; import hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem'; @@ -97,9 +97,15 @@ export default config; !!! tip 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. -## Create Your Contract +## Create the Contract + +Follow these steps to create your smart contract: + +1. Delete the default contract file(s) in the `contracts` directory. -Create `contracts/MyNFT.sol`: +2. Create a new file named `MyNFT.sol` inside the `contracts` directory. + +3. Add the following code to create the `MyNFT.sol` smart contract: ```solidity title="contracts/MyNFT.sol" // SPDX-License-Identifier: MIT @@ -123,15 +129,33 @@ contract MyNFT is ERC721, Ownable { } ``` -## Compile +## Compile the Contract + +Compile your `MyNFT.sol` contract using the following command: ```bash npx hardhat compile ``` +You will see a message in the terminal confirming the contract was successfully compiled similar to the following: + +
+ npx hardhat compile + Downloading solc 0.8.28 + Downloading solc 0.8.28 (WASM build) + Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun) + +
+ ## Set Up Deployment -Create a deployment module in `ignition/modules/MyNFT.ts`: +Follow these steps to prepare for contract deployment: + +1. Delete the default file(s) inside the `ignition/modules` directory. + +2. Create a new file named `MyNFT.ts` inside the `ignition/modules` directory. + +3. Open `ignition/modules/MyNFT.ts` and add the following code to create your deployment module: ```typescript title="ignition/modules/MyNFT.ts" import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; @@ -145,14 +169,16 @@ export default buildModule('MyNFTModule', (m) => { Replace `INSERT_OWNER_ADDRESS` with your desired owner address. -## Deploy +## Deploy the Contract -Deploy to Polkadot Hub TestNet: +Deploy your contract to Polkadot Hub TestNet using the following command: ```bash npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestnet ``` +Congratulations! You've successfully deployed an ERC-721 NFT contract to the Polkadot TestNet using Hardhat. + ## Where to Go Next
@@ -172,6 +198,6 @@ npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestn Walk through deploying a fully-functional ERC-20 to the Polkadot Hub using Hardhat. - [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/hardhat/) + [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/)
diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/remix.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md similarity index 98% rename from smart-contracts/cookbook/smart-contracts/deploy-nft/remix.md rename to smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md index 3da07008e..982b0f8d3 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md @@ -1,5 +1,5 @@ --- -title: Deploy an NFT to Polkadot Hub with Remix +title: Deploy ERC-721 NFT Using Remix description: Learn how to deploy an ERC-721 NFT contract to Polkadot Hub using Remix, a browser-based IDE for quick prototyping and learning. tutorial_badge: Beginner categories: Basics, Smart Contracts From 6076bb937ade77b628ad9f8f7f6c6176518a76d9 Mon Sep 17 00:00:00 2001 From: DAWN KELLY Date: Mon, 17 Nov 2025 15:52:09 -0500 Subject: [PATCH 4/8] storytelling/cleanup --- .../basic-hardhat/Storage.sol | 14 +++ .../basic-hardhat/compile-output.html | 7 ++ .../basic-hardhat/hardhat.config.js | 47 +++++++++ .../basic-hardhat/storage.ts | 6 ++ .../erc20-hardhat/compile-output.html | 6 ++ .../erc20-hardhat/deploy-output.html | 20 ++++ .../erc20-hardhat/testing-output.html | 16 +++ .../deploy-erc721-nft/nft-hardhat/MyNFT.sol | 18 ++++ .../deploy-erc721-nft/nft-hardhat/MyNFT.ts | 7 ++ .../nft-hardhat/compile-output.html | 7 ++ .../nft-hardhat/hardhat.config.ts | 48 +++++++++ .../deploy-erc721-nft/nft-remix/MyNFT.sol | 18 ++++ .../{ => erc20-remix}/erc20-remix-1.webp | Bin .../{ => erc20-remix}/erc20-remix-2.webp | Bin .../{ => erc20-remix}/erc20-remix-3.gif | Bin .../{ => erc20-remix}/erc20-remix-4.gif | Bin .../{ => erc20-remix}/erc20-remix-5.gif | Bin .../{remix => nft-remix}/remix-01.webp | Bin .../{remix => nft-remix}/remix-02.webp | Bin .../{remix => nft-remix}/remix-03.webp | Bin .../{remix => nft-remix}/remix-04.webp | Bin .../deploy-basic/basic-hardhat.md | 92 ++-------------- .../deploy-basic/basic-remix.md | 9 +- .../deploy-erc20/erc20-hardhat.md | 51 ++------- .../deploy-erc20/erc20-remix.md | 12 ++- .../smart-contracts/deploy-nft/nft-hardhat.md | 99 ++---------------- .../smart-contracts/deploy-nft/nft-remix.md | 36 ++----- 27 files changed, 264 insertions(+), 249 deletions(-) create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/Storage.sol create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.js create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/compile-output.html create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.sol create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.ts create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/hardhat.config.ts create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol rename images/smart-contracts/cookbook/smart-contracts/deploy-erc20/{ => erc20-remix}/erc20-remix-1.webp (100%) rename images/smart-contracts/cookbook/smart-contracts/deploy-erc20/{ => erc20-remix}/erc20-remix-2.webp (100%) rename images/smart-contracts/cookbook/smart-contracts/deploy-erc20/{ => erc20-remix}/erc20-remix-3.gif (100%) rename images/smart-contracts/cookbook/smart-contracts/deploy-erc20/{ => erc20-remix}/erc20-remix-4.gif (100%) rename images/smart-contracts/cookbook/smart-contracts/deploy-erc20/{ => erc20-remix}/erc20-remix-5.gif (100%) rename images/smart-contracts/cookbook/smart-contracts/deploy-nft/{remix => nft-remix}/remix-01.webp (100%) rename images/smart-contracts/cookbook/smart-contracts/deploy-nft/{remix => nft-remix}/remix-02.webp (100%) rename images/smart-contracts/cookbook/smart-contracts/deploy-nft/{remix => nft-remix}/remix-03.webp (100%) rename images/smart-contracts/cookbook/smart-contracts/deploy-nft/{remix => nft-remix}/remix-04.webp (100%) diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/Storage.sol b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/Storage.sol new file mode 100644 index 000000000..49cb1444a --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/Storage.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.9; + +contract Storage { + uint256 private storedNumber; + + function store(uint256 num) public { + storedNumber = num; + } + + function retrieve() public view returns (uint256) { + return storedNumber; + } +} diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html new file mode 100644 index 000000000..54128743a --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html @@ -0,0 +1,7 @@ +
+ npx hardhat compile + Downloading solc 0.8.28 + Downloading solc 0.8.28 (WASM build) + Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun) + +
diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.js b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.js new file mode 100644 index 000000000..5194f0313 --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.js @@ -0,0 +1,47 @@ +import type { HardhatUserConfig } from 'hardhat/config'; + +import hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem'; +import { configVariable } from 'hardhat/config'; + +const config: HardhatUserConfig = { + plugins: [hardhatToolboxViemPlugin], + solidity: { + profiles: { + default: { + version: '0.8.28', + }, + production: { + version: '0.8.28', + settings: { + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, + }, + }, + networks: { + hardhatMainnet: { + type: 'edr-simulated', + chainType: 'l1', + }, + hardhatOp: { + type: 'edr-simulated', + chainType: 'op', + }, + sepolia: { + type: 'http', + chainType: 'l1', + url: configVariable('SEPOLIA_RPC_URL'), + accounts: [configVariable('SEPOLIA_PRIVATE_KEY')], + }, + polkadotHubTestnet: { + url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', + chainId: 420420422, + accounts: [configVariable('PRIVATE_KEY')], + }, + }, +}; + +export default config; diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts new file mode 100644 index 000000000..20cdcf3c7 --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts @@ -0,0 +1,6 @@ +import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; + +export default buildModule('StorageModule', (m) => { + const storage = m.contract('Storage'); + return { storage }; +}); diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/compile-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/compile-output.html new file mode 100644 index 000000000..2f98ae946 --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/compile-output.html @@ -0,0 +1,6 @@ +
+ npx hardhat compile + Generating typings for: 23 artifacts in dir: typechain-types for target: ethers-v6 + Successfully generated 62 typings! + Compiled 21 Solidity files successfully (evm target: paris). +
diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html new file mode 100644 index 000000000..940a6294c --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html @@ -0,0 +1,20 @@ +
+ npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet + ✔ Confirm deploy to network polkadotTestnet (420420420)? … yes +   + Hardhat Ignition 🚀 +   + Deploying [ TokenModule ] +   + Batch #1 + Executed TokenModule#MyToken +   + Batch #2 + Executed TokenModule#MyToken.mint +   + [ TokenModule ] successfully deployed 🚀 +   + Deployed Addresses +   + TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3 +
diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html new file mode 100644 index 000000000..dd15a74ac --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html @@ -0,0 +1,16 @@ +
+ npx hardhat test --network polkadotTestnet + +   MyToken +     Deployment +       ✔ Should have correct name and symbol +       ✔ Should set the right owner +       ✔ Should have zero initial supply +     Minting +       ✔ Should allow owner to mint tokens +       ✔ Should increase total supply on mint +     Multiple mints +       ✔ Should correctly track balance after multiple mints + +   6 passing (369ms) +
diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.sol b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.sol new file mode 100644 index 000000000..0bcab0501 --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; + +contract MyNFT is ERC721, Ownable { + uint256 private _nextTokenId; + + constructor( + address initialOwner + ) ERC721("MyToken", "MTK") Ownable(initialOwner) {} + + function safeMint(address to) public onlyOwner { + uint256 tokenId = _nextTokenId++; + _safeMint(to, tokenId); + } +} diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.ts new file mode 100644 index 000000000..0be0a559c --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.ts @@ -0,0 +1,7 @@ +import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; + +export default buildModule('MyNFTModule', (m) => { + const initialOwner = m.getParameter('initialOwner', 'INSERT_OWNER_ADDRESS'); + const myNFT = m.contract('MyNFT', [initialOwner]); + return { myNFT }; +}); diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html new file mode 100644 index 000000000..17867ca16 --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html @@ -0,0 +1,7 @@ +
+ npx hardhat compile + Downloading solc 0.8.28 + Downloading solc 0.8.28 (WASM build) + Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun) + +
\ No newline at end of file diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/hardhat.config.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/hardhat.config.ts new file mode 100644 index 000000000..1877f91a8 --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/hardhat.config.ts @@ -0,0 +1,48 @@ +import type { HardhatUserConfig } from 'hardhat/config'; + +import hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem'; +import { configVariable } from 'hardhat/config'; + +const config: HardhatUserConfig = { + plugins: [hardhatToolboxViemPlugin], + solidity: { + profiles: { + default: { + version: '0.8.28', + }, + production: { + version: '0.8.28', + settings: { + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, + }, + }, + networks: { + hardhatMainnet: { + type: 'edr-simulated', + chainType: 'l1', + }, + hardhatOp: { + type: 'edr-simulated', + chainType: 'op', + }, + sepolia: { + type: 'http', + chainType: 'l1', + url: configVariable('SEPOLIA_RPC_URL'), + accounts: [configVariable('SEPOLIA_PRIVATE_KEY')], + }, + polkadotHubTestnet: { + type: 'http', + url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', + chainId: 420420422, + accounts: [configVariable('PRIVATE_KEY')], + }, + }, +}; + +export default config; \ No newline at end of file diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol new file mode 100644 index 000000000..0bcab0501 --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; + +contract MyNFT is ERC721, Ownable { + uint256 private _nextTokenId; + + constructor( + address initialOwner + ) ERC721("MyToken", "MTK") Ownable(initialOwner) {} + + function safeMint(address to) public onlyOwner { + uint256 tokenId = _nextTokenId++; + _safeMint(to, tokenId); + } +} diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-1.webp b/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-1.webp similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-1.webp rename to images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-1.webp diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-2.webp b/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-2.webp similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-2.webp rename to images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-2.webp diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-3.gif b/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-3.gif similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-3.gif rename to images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-3.gif diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-4.gif b/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-4.gif similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-4.gif rename to images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-4.gif diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-5.gif b/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-5.gif similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-5.gif rename to images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-5.gif diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-01.webp b/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-01.webp similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-01.webp rename to images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-01.webp diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-02.webp b/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-02.webp similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-02.webp rename to images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-02.webp diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-03.webp b/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-03.webp similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-03.webp rename to images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-03.webp diff --git a/images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-04.webp b/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-04.webp similarity index 100% rename from images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-04.webp rename to images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-04.webp diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md index cce15fe85..e1d7ae08f 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md @@ -31,57 +31,10 @@ npx hardhat --init ## Configure Hardhat -Open `hardhat.config.js` and update to add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: +Open `hardhat.config.js` and add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: ```javascript title='hardhat.config.js' hl_lines='39-43' -import type { HardhatUserConfig } from 'hardhat/config'; - -import hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem'; -import { configVariable } from 'hardhat/config'; - -const config: HardhatUserConfig = { - plugins: [hardhatToolboxViemPlugin], - solidity: { - profiles: { - default: { - version: '0.8.28', - }, - production: { - version: '0.8.28', - settings: { - optimizer: { - enabled: true, - runs: 200, - }, - }, - }, - }, - }, - networks: { - hardhatMainnet: { - type: 'edr-simulated', - chainType: 'l1', - }, - hardhatOp: { - type: 'edr-simulated', - chainType: 'op', - }, - sepolia: { - type: 'http', - chainType: 'l1', - url: configVariable('SEPOLIA_RPC_URL'), - accounts: [configVariable('SEPOLIA_PRIVATE_KEY')], - }, - polkadotHubTestnet: { - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, - accounts: [configVariable('PRIVATE_KEY')], - }, - }, -}; - -export default config; - +--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.js' ``` !!! tip @@ -96,23 +49,9 @@ Follow these steps to create your smart contract: 2. Create a new file named `Storage.sol` inside the `contracts` directory. 3. Add the following code to create the `Storage.sol` smart contract: - - ```solidity - // SPDX-License-Identifier: MIT - pragma solidity ^0.8.9; - - contract Storage { - uint256 private storedNumber; - - function store(uint256 num) public { - storedNumber = num; - } - - function retrieve() public view returns (uint256) { - return storedNumber; - } - } - ``` + ```solidity title="Storage.sol" + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/Storage.sol' + ``` ## Compile the Contract @@ -124,13 +63,7 @@ npx hardhat compile You will see a message in the terminal confirming the contract was successfully compiled similar to the following: -
- npx hardhat compile - Downloading solc 0.8.28 - Downloading solc 0.8.28 (WASM build) - Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun) - -
+--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html' ## Set Up Deployment @@ -142,14 +75,9 @@ Follow these steps to prepare for contract deployment: 3. Open `ignition/modules/Storage.ts` and add the following code to create your deployment module: - ```typescript title="ignition/modules/Storage.ts" - import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; - - export default buildModule('StorageModule', (m) => { - const storage = m.contract('Storage'); - return { storage }; - }); - ``` + ```typescript title="ignition/modules/Storage.ts" + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts' + ``` ## Deploy the Contract @@ -159,6 +87,8 @@ Deploy your contract to Polkadot Hub TestNet using the following command: npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTestnet ``` +Congratulations! You've now deployed a basic smart contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress. + ## Where to Go Next
diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md index 938f4610f..28f5b7d24 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md @@ -32,11 +32,10 @@ Ensure your contract is open in the Remix IDE Editor, and use the follow steps t 1. Select the **Solidity Compiler** plugin from the left panel. 2. Select the **Compile MyToken.sol** button. -3. The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. -![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-02.webp) + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-02.webp) -If any issues arise during Compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. +The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. If any issues arise during contract compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. ## Deploy the Contract @@ -47,10 +46,12 @@ Follow these steps to deploy the contract using Remix: 3. Select **Deploy**. 4. Approve the transaction in your MetaMask wallet. -![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-03.webp) + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-03.webp) Once successfully deployed, your contract will appear in the **Deployed Contracts** section, ready for interaction. +Congratulations! You've now deployed a basic smart contract to Polkadot Hub TestNet using Remix IDE. Consider the following resources to build upon your progress. + ## Where to Go Next
diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md index 4a384a5f3..823a01d8b 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md @@ -65,12 +65,8 @@ npx hardhat compile If everything compiles successfully, you will see output similar to the following: -
- npx hardhat compile - Generating typings for: 23 artifacts in dir: typechain-types for target: ethers-v6 - Successfully generated 62 typings! - Compiled 21 Solidity files successfully (evm target: paris). -
+--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/compile-output.html' + ## Test the Contract @@ -93,22 +89,7 @@ npx hardhat test --network polkadotTestnet If tests are successful, you will see outputs similar to the following: -
- npx hardhat test --network polkadotTestnet - -   MyToken -     Deployment -       ✔ Should have correct name and symbol -       ✔ Should set the right owner -       ✔ Should have zero initial supply -     Minting -       ✔ Should allow owner to mint tokens -       ✔ Should increase total supply on mint -     Multiple mints -       ✔ Should correctly track balance after multiple mints - -   6 passing (369ms) -
+--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html' ## Deploy the Contract @@ -120,28 +101,10 @@ You are now ready to deploy the contract to your chosen network. This example de ``` 2. Confirm the target deployment network name and chain ID when prompted: -
- npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet - ✔ Confirm deploy to network polkadotTestnet (420420420)? … yes -   - Hardhat Ignition 🚀 -   - Deploying [ TokenModule ] -   - Batch #1 - Executed TokenModule#MyToken -   - Batch #2 - Executed TokenModule#MyToken.mint -   - [ TokenModule ] successfully deployed 🚀 -   - Deployed Addresses -   - TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3 -
- -Congratulations! You've successfully deployed an ERC-20 token contract to the Polkadot TestNet using Hardhat. + + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html' + +Congratulations! You've successfully deployed an ERC-20 token contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress. ## Where to Go Next diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md index a6957a78c..c4873d640 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md @@ -29,7 +29,7 @@ Follow the steps below to create the ERC-20 contract: 1. Navigate to the [Polkadot Remix IDE](https://remix.polkadot.io){target=\_blank}. 2. Select the **Create new file** button under the **contracts** folder, and name your contract `MyToken.sol`. - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-1.webp) + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-1.webp) 3. Now, paste the following ERC-20 contract code into `myToken.sol`: @@ -50,9 +50,9 @@ Ensure your contract is open in the Remix IDE Editor, and use the follow steps t 2. Select the **Compile MyToken.sol** button. 3. The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. -If any issues arise during Compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. +If any issues arise during contract compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. -![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-3.gif) +![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-3.gif) ## Deploy the Contract @@ -65,7 +65,7 @@ Follow these steps to deploy the contract using Remix: 5. Approve the transaction in your MetaMask wallet. 6. You will see the transaction details in the terminal when the deployment succeeds, including the contract address and deployment transaction hash. -![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-4.gif) + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-4.gif) ## Interact With the Contract @@ -81,10 +81,12 @@ Once deployed, you can interact with your contract through Remix. Find your cont 4. You can also call the **balanceOf** function by passing the address of the **mint** call to confirm the new balance. -![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix-5.gif) + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-5.gif) Feel free to explore and interact with the contract's other functions by selecting the method, providing any required parameters, and confirming the transaction in MetaMask when prompted. +Congratulations! You've successfully deployed an ERC-20 token contract to Polkadot Hub TestNet using Remix IDE. Consider the following resources to build upon your progress. + ## Where to Go Next
diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md index 5a2b9117d..3dae2c391 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md @@ -44,54 +44,7 @@ Before you begin, ensure you have the following: Open `hardhat.config.js` and update to add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: ```typescript title="hardhat.config.ts" hl_lines='39-44' -import type { HardhatUserConfig } from 'hardhat/config'; - -import hardhatToolboxViemPlugin from '@nomicfoundation/hardhat-toolbox-viem'; -import { configVariable } from 'hardhat/config'; - -const config: HardhatUserConfig = { - plugins: [hardhatToolboxViemPlugin], - solidity: { - profiles: { - default: { - version: '0.8.28', - }, - production: { - version: '0.8.28', - settings: { - optimizer: { - enabled: true, - runs: 200, - }, - }, - }, - }, - }, - networks: { - hardhatMainnet: { - type: 'edr-simulated', - chainType: 'l1', - }, - hardhatOp: { - type: 'edr-simulated', - chainType: 'op', - }, - sepolia: { - type: 'http', - chainType: 'l1', - url: configVariable('SEPOLIA_RPC_URL'), - accounts: [configVariable('SEPOLIA_PRIVATE_KEY')], - }, - polkadotHubTestnet: { - type: 'http', - url: 'https://testnet-passet-hub-eth-rpc.polkadot.io', - chainId: 420420422, - accounts: [configVariable('PRIVATE_KEY')], - }, - }, -}; - -export default config; +--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/hardhat.config.ts' ``` !!! tip @@ -106,28 +59,9 @@ Follow these steps to create your smart contract: 2. Create a new file named `MyNFT.sol` inside the `contracts` directory. 3. Add the following code to create the `MyNFT.sol` smart contract: - -```solidity title="contracts/MyNFT.sol" -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; - -contract MyNFT is ERC721, Ownable { - uint256 private _nextTokenId; - - constructor(address initialOwner) - ERC721("MyToken", "MTK") - Ownable(initialOwner) - {} - - function safeMint(address to) public onlyOwner { - uint256 tokenId = _nextTokenId++; - _safeMint(to, tokenId); - } -} -``` + ```solidity title="contracts/MyNFT.sol" + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.sol' + ``` ## Compile the Contract @@ -139,13 +73,7 @@ npx hardhat compile You will see a message in the terminal confirming the contract was successfully compiled similar to the following: -
- npx hardhat compile - Downloading solc 0.8.28 - Downloading solc 0.8.28 (WASM build) - Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun) - -
+--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html' ## Set Up Deployment @@ -156,18 +84,11 @@ Follow these steps to prepare for contract deployment: 2. Create a new file named `MyNFT.ts` inside the `ignition/modules` directory. 3. Open `ignition/modules/MyNFT.ts` and add the following code to create your deployment module: + ```typescript title="ignition/modules/MyNFT.ts" + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.ts' + ``` -```typescript title="ignition/modules/MyNFT.ts" -import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; - -export default buildModule('MyNFTModule', (m) => { - const initialOwner = m.getParameter('initialOwner', 'INSERT_OWNER_ADDRESS'); - const myNFT = m.contract('MyNFT', [initialOwner]); - return { myNFT }; -}); -``` - -Replace `INSERT_OWNER_ADDRESS` with your desired owner address. + Replace `INSERT_OWNER_ADDRESS` with your desired owner address. ## Deploy the Contract @@ -177,7 +98,7 @@ Deploy your contract to Polkadot Hub TestNet using the following command: npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestnet ``` -Congratulations! You've successfully deployed an ERC-721 NFT contract to the Polkadot TestNet using Hardhat. +Congratulations! You've successfully deployed an ERC-721 NFT contract to the Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress. ## Where to Go Next diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md index 982b0f8d3..6cab99ce8 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md @@ -29,57 +29,41 @@ The interface will load with a default workspace containing sample contracts. In ## Create Your Contract 1. Create a new file `contracts/MyNFT.sol`. -2. Paste the following code: +2. Now, paste the following ERC-721 contract code into `MyNFT.sol`: ```solidity title="contracts/MyNFT.sol" - // SPDX-License-Identifier: MIT - pragma solidity ^0.8.20; - - import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; - import "@openzeppelin/contracts/access/Ownable.sol"; - - contract MyNFT is ERC721, Ownable { - uint256 private _nextTokenId; - - constructor(address initialOwner) - ERC721("MyToken", "MTK") - Ownable(initialOwner) - {} - - function safeMint(address to) public onlyOwner { - uint256 tokenId = _nextTokenId++; - _safeMint(to, tokenId); - } - } + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol' ``` -![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-01.webp) + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-01.webp) -## Compile +## Compile the Contract 1. Navigate to the **Solidity Compiler** tab (third icon in the left sidebar). 2. Click **Compile MyNFT.sol** or press `Ctrl+S`. -![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-02.webp) +![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-02.webp) Compilation errors and warnings appear in the terminal panel at the bottom of the screen. -## Deploy +## Deploy the Contract 1. Navigate to the **Deploy & Run Transactions** tab. 2. Click the **Environment** dropdown, select **Browser Extension**, and click on **Injected Provider - MetaMask**. - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-03.webp) + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-03.webp) 3. In the deploy section, enter the initial owner address in the constructor parameter field. 4. Click **Deploy**. - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/remix-04.webp) + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-04.webp) 5. Approve the transaction in your MetaMask wallet. Your deployed contract will appear in the **Deployed Contracts** section, ready for interaction. +Congratulations! You've successfully deployed an ERC-721 NFT contract to the Polkadot Hub TestNet using Remix IDE. Consider the following resources to build upon your progress. + ## Where to Go Next
From 0f355af4b2d1f6fe0ba4e7f4b283193bcd8f2ba2 Mon Sep 17 00:00:00 2001 From: DAWN KELLY Date: Mon, 17 Nov 2025 16:04:22 -0500 Subject: [PATCH 5/8] grammarly pass --- .../deploy-basic/basic-hardhat.md | 8 ++++---- .../smart-contracts/deploy-basic/basic-remix.md | 8 ++++---- .../deploy-erc20/erc20-hardhat.md | 16 +++++++++------- .../smart-contracts/deploy-erc20/erc20-remix.md | 4 ++-- .../smart-contracts/deploy-nft/nft-hardhat.md | 6 +++--- .../smart-contracts/deploy-nft/nft-remix.md | 2 +- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md index e1d7ae08f..8ae71cd50 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md @@ -1,6 +1,6 @@ --- title: Deploy Basic Contract with Hardhat -description: Learn how to deploy a basic smart contract to Polkadot Hub using Hardhat, Perfect for professional workflows requiring comprehensive testing and debugging. +description: Learn how to deploy a basic smart contract to Polkadot Hub using Hardhat, ideal for professional workflows that require comprehensive testing and debugging. categories: Smart Contracts --- @@ -38,7 +38,7 @@ Open `hardhat.config.js` and add `polkadotHubTestnet` to the `networks` configur ``` !!! tip - 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. + Learn how to use Hardhat's [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} to handle your private keys securely. ## Create the Contract @@ -61,7 +61,7 @@ Compile your `Storage.sol` contract using the following command: npx hardhat compile ``` -You will see a message in the terminal confirming the contract was successfully compiled similar to the following: +You will see a message in the terminal confirming the contract was successfully compiled, similar to the following: --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html' @@ -113,7 +113,7 @@ Congratulations! You've now deployed a basic smart contract to Polkadot Hub Test --- - Walk through deploying a NFT to the Polkadot Hub using Hardhat. + Walk through deploying an NFT to the Polkadot Hub using Hardhat. [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/) diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md index 28f5b7d24..2e56a8dff 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md @@ -1,6 +1,6 @@ --- title: Deploy Basic Contract with Remix IDE -description: Learn how to deploy a basic smart contract to Polkadot Hub using Remix IDE Ideal for rapid prototyping, learning, and visual development. +description: Learn how to deploy a basic smart contract to Polkadot Hub using Remix IDE, ideal for rapid prototyping, learning, and visual development. categories: Smart Contracts --- @@ -22,13 +22,13 @@ Before you begin, ensure you have the following: Navigate to [Remix](https://remix.ethereum.org/){target=\_blank} in your web browser. -The interface will load with a default workspace containing sample contracts. In this interface, you can access a file explorer, edit your code, interact with various plugins for development, and use a terminal. By default, you will see the `contracts` folder with the `Storage.sol` file, which will be used as the example contract throughout this guide. +The interface will load with a default workspace containing sample contracts. In this interface, you can access a file explorer, edit your code, interact with various development plugins, and use a terminal. By default, you will see the `contracts` folder with the `Storage.sol` file, which will be used as the example contract throughout this guide. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-01.webp) ## Compile the Contract -Ensure your contract is open in the Remix IDE Editor, and use the follow steps to compile: +Ensure your contract is open in the Remix IDE Editor, and use the following steps to compile: 1. Select the **Solidity Compiler** plugin from the left panel. 2. Select the **Compile MyToken.sol** button. @@ -76,7 +76,7 @@ Congratulations! You've now deployed a basic smart contract to Polkadot Hub Test --- - Walk through deploying a NFT to the Polkadot Hub using Remix. + Walk through deploying an NFT to the Polkadot Hub using Remix. [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/) diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md index 823a01d8b..d5d975ded 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md @@ -10,13 +10,13 @@ tools: Hardhat ## Introduction -[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. +[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 deployment of ERC-20 tokens via Ethereum-compatible smart contracts and tools. 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}. ## Prerequisites -Before you begin, ensure sure you have the following: +Before you begin, ensure you have the following: - 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. - Node.js v22.13.1 or later installed. @@ -25,7 +25,9 @@ Before you begin, ensure sure you have the following: ## Set Up Your Project -This tutorial uses a [Hardhat ERC-20 template](https://github.com/polkadot-developers/revm-hardhat-examples/tree/master/erc20-hardhat){target=\_blank} that contains all the necessary files. To get started, take the following steps: +This tutorial uses a [Hardhat ERC-20 template](https://github.com/polkadot-developers/revm-hardhat-examples/tree/master/erc20-hardhat){target=\_blank} that contains all the necessary files. + +To get started, take the following steps: 1. Clone the GitHub repository locally: @@ -34,13 +36,13 @@ This tutorial uses a [Hardhat ERC-20 template](https://github.com/polkadot-devel cd revm-hardhat-examples/erc20-hardhat ``` -2. Install the dependencies: +2. Install the dependencies using the following command: ```bash npm i ``` - This will fetch all the necessary packages to help you deploy an ERC-20 with Hardhat to Polkadot. + This command will fetch all the necessary packages to help you deploy an ERC-20 with Hardhat to Polkadot. ## Configure Hardhat @@ -53,7 +55,7 @@ If you started with the cloned Hardhat ERC-20 template, `hardhat.config.js` is a ``` !!! tip - 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. + 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. ## Compile the Contract @@ -79,7 +81,7 @@ You can view the predefined test file at [`test/MyToken.test.ts`](https://github - The initial token supply is zero. - The owner can mint tokens. - The total supply increases after a mint. -- Successful mints to different test addresses with correct corresponding account balance and total supply changes. +- Successful mints to different test addresses with expected account balance and total supply changes. Run the test using the following command: diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md index c4873d640..b19828665 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md @@ -44,7 +44,7 @@ Follow the steps below to create the ERC-20 contract: Solidity source code compiles into bytecode that can be deployed on the blockchain. During this process, the compiler checks the contract for syntax errors, ensures type safety, and generates the machine-readable instructions needed for blockchain execution. -Ensure your contract is open in the Remix IDE Editor, and use the follow steps to compile: +Ensure your contract is open in the Remix IDE Editor, and use the following steps to compile: 1. Select the **Solidity Compiler** plugin from the left panel. 2. Select the **Compile MyToken.sol** button. @@ -72,7 +72,7 @@ Follow these steps to deploy the contract using Remix: Once deployed, you can interact with your contract through Remix. Find your contract under **Deployed/Unpinned Contracts**, and click it to expand the available methods. In this example, you'll mint some tokens to a given address using the following steps: 1. Expand the **mint** function: - 1. Enter the recipient address and the amount (remember to add 18 zeros for 1 whole token). + 1. Enter the recipient address and the amount (remember to add 18 zeros for one whole token). 2. Click **transact**. 2. Approve the transaction in the MetaMask popup. diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md index 3dae2c391..60a90ab18 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md @@ -1,6 +1,6 @@ --- title: Deploy ERC-721 Using Hardhat -description: Learn how to deploy an ERC-721 NFT contract to Polkadot Hub with Hardhat, a comprehenive development environment with built-in deployment capabilities. +description: Learn how to deploy an ERC-721 NFT contract to Polkadot Hub using Hardhat, a comprehensive development environment with built-in deployment capabilities. tutorial_badge: Beginner categories: Basics, Smart Contracts tools: EVM Wallet, Hardhat @@ -48,7 +48,7 @@ Open `hardhat.config.js` and update to add `polkadotHubTestnet` to the `networks ``` !!! tip - 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. + Learn how to use Hardhat's [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} to handle your private keys securely. ## Create the Contract @@ -71,7 +71,7 @@ Compile your `MyNFT.sol` contract using the following command: npx hardhat compile ``` -You will see a message in the terminal confirming the contract was successfully compiled similar to the following: +You will see a message in the terminal confirming the contract was successfully compiled, similar to the following: --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html' diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md index 6cab99ce8..550083c1e 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md @@ -24,7 +24,7 @@ This guide demonstrates how to deploy an [ERC-721](https://eips.ethereum.org/EIP Navigate to [Remix](https://remix.ethereum.org/){target=\_blank} in your web browser. -The interface will load with a default workspace containing sample contracts. In this interface, you can access a file explorer, edit your code, interact with various plugins for development, and use a terminal. +The interface will load with a default workspace containing sample contracts. In this interface, you can access a file explorer, edit your code, interact with various development plugins, and use a terminal. ## Create Your Contract From 45c992e239de1994e884d5df052b1aad1908530a Mon Sep 17 00:00:00 2001 From: DAWN KELLY Date: Thu, 20 Nov 2025 10:12:55 -0500 Subject: [PATCH 6/8] applying feedback --- .../{hardhat.config.js => hardhat.config.ts} | 0 .../cookbook/smart-contracts/.nav.yml | 6 ++--- .../deploy-basic/basic-hardhat.md | 22 +++++-------------- .../deploy-basic/basic-remix.md | 16 ++++---------- .../smart-contracts/deploy-erc20/.nav.yml | 1 - .../deploy-erc20/erc20-hardhat.md | 10 ++++----- .../deploy-erc20/erc20-remix.md | 10 ++++----- 7 files changed, 23 insertions(+), 42 deletions(-) rename .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/{hardhat.config.js => hardhat.config.ts} (100%) diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.js b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.ts similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.js rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.ts diff --git a/smart-contracts/cookbook/smart-contracts/.nav.yml b/smart-contracts/cookbook/smart-contracts/.nav.yml index efd9a3f2b..0aaa313cc 100644 --- a/smart-contracts/cookbook/smart-contracts/.nav.yml +++ b/smart-contracts/cookbook/smart-contracts/.nav.yml @@ -1,4 +1,4 @@ nav: -- 'Deploy Basic Contract': deploy-basic -- 'Deploy ERC-20 Token': deploy-erc20 -- 'Deploy ERC-721 NFT': deploy-nft +- 'Deploy a Basic Contract': deploy-basic +- 'Deploy an ERC-20 Token': deploy-erc20 +- 'Deploy an ERC-721 NFT': deploy-nft diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md index 8ae71cd50..641b7a450 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md @@ -1,10 +1,10 @@ --- -title: Deploy Basic Contract with Hardhat +title: Deploy a Basic Contract with Hardhat description: Learn how to deploy a basic smart contract to Polkadot Hub using Hardhat, ideal for professional workflows that require comprehensive testing and debugging. categories: Smart Contracts --- -# Deploy Basic Contract with Hardhat +# Deploy a Basic Contract with Hardhat ## Introduction @@ -33,8 +33,8 @@ npx hardhat --init Open `hardhat.config.js` and add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: -```javascript title='hardhat.config.js' hl_lines='39-43' ---8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.js' +```typescript title='hardhat.config.ts' hl_lines='39-43' +--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.ts' ``` !!! tip @@ -65,7 +65,7 @@ You will see a message in the terminal confirming the contract was successfully --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html' -## Set Up Deployment +## Deploy the Contract Follow these steps to prepare for contract deployment: @@ -79,9 +79,7 @@ Follow these steps to prepare for contract deployment: --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts' ``` -## Deploy the Contract - -Deploy your contract to Polkadot Hub TestNet using the following command: +4. Deploy your contract to Polkadot Hub TestNet using the following command: ```bash npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTestnet @@ -93,14 +91,6 @@ Congratulations! You've now deployed a basic smart contract to Polkadot Hub Test
-- Guide __Verify Your Contract__ - - --- - - Now that you've deployed a basic contract, learn how to verify it with Hardhat. - - [:octicons-arrow-right-24: Get Started](/smart-contracts/dev-environments/hardhat/verify-a-contract/) - - Guide __Deploy an ERC-20__ --- diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md index 2e56a8dff..414d63acb 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md @@ -1,10 +1,10 @@ --- -title: Deploy Basic Contract with Remix IDE +title: Deploy a Basic Contract with Remix IDE description: Learn how to deploy a basic smart contract to Polkadot Hub using Remix IDE, ideal for rapid prototyping, learning, and visual development. categories: Smart Contracts --- -# Deploy Basic Contract with Remix IDE +# Deploy a Basic Contract with Remix IDE ## Introduction @@ -24,14 +24,14 @@ Navigate to [Remix](https://remix.ethereum.org/){target=\_blank} in your web bro The interface will load with a default workspace containing sample contracts. In this interface, you can access a file explorer, edit your code, interact with various development plugins, and use a terminal. By default, you will see the `contracts` folder with the `Storage.sol` file, which will be used as the example contract throughout this guide. -![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-01.webp) +![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix/basic-remix-01.webp) ## Compile the Contract Ensure your contract is open in the Remix IDE Editor, and use the following steps to compile: 1. Select the **Solidity Compiler** plugin from the left panel. -2. Select the **Compile MyToken.sol** button. +2. Select the **Compile Storage.sol** button. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-02.webp) @@ -56,14 +56,6 @@ Congratulations! You've now deployed a basic smart contract to Polkadot Hub Test
-- Guide __Verify Your Contract__ - - --- - - Now that you've deployed a basic contract, learn how to verify it with Remix. - - [:octicons-arrow-right-24: Get Started](/smart-contracts/dev-environments/remix/verify-a-contract/) - - Guide __Deploy an ERC-20__ --- diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/.nav.yml b/smart-contracts/cookbook/smart-contracts/deploy-erc20/.nav.yml index 0f6a29940..0e8ca6a78 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/.nav.yml +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/.nav.yml @@ -1,4 +1,3 @@ -title: Deploy an ERC-20 nav: - 'Remix IDE': erc20-remix.md - 'Hardhat': erc20-hardhat.md diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md index d5d975ded..6721e7e35 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md @@ -1,12 +1,12 @@ --- -title: Deploy ERC-20 Using Hardhat +title: Deploy an ERC-20 Using Hardhat description: Deploy an ERC-20 token on Polkadot Hub using PolkaVM. This guide covers contract creation, compilation, deployment, and interaction via Hardhat. tutorial_badge: Intermediate categories: Basics, Smart Contracts tools: Hardhat --- -# Deploy ERC-20 Using Hardhat +# Deploy an ERC-20 Using Hardhat ## Introduction @@ -18,7 +18,7 @@ This tutorial covers deploying an ERC-20 contract on the Polkadot Hub TestNet us Before you begin, ensure you have the following: -- 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. +- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming and [ERC-20](https://ethereum.org/developers/docs/standards/tokens/erc-20/){target=\_blank} fungible tokens. - Node.js v22.13.1 or later installed. - 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. - A wallet with a private key for signing transactions. @@ -46,7 +46,7 @@ To get started, take the following steps: ## Configure Hardhat -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: +If you started with the cloned Hardhat ERC-20 template, `hardhat.config.ts` is already configured to deploy to the Polkadot TestNet as shown in the example below: ```ts title="hardhat.config.ts" hl_lines="14-19" --8<-- "https://raw.githubusercontent.com/polkadot-developers/revm-hardhat-examples/refs/heads/master/erc20-hardhat/hardhat.config.ts::2" @@ -72,7 +72,7 @@ If everything compiles successfully, you will see output similar to the followin ## Test the Contract -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. +Using Hardhat's native features to test contracts against a local Hardhat development node is challenging due to some technical differences between the local node and Polkadot. This example tests contracts against a local Polkadot development node to account for these differences. 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: diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md index b19828665..d69400857 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md @@ -6,7 +6,7 @@ categories: Basics, Smart Contracts tools: EVM Wallet, Remix --- -# Deploy ERC-20 Using Remix IDE +# Deploy an ERC-20 Using Remix IDE ## Introduction @@ -18,7 +18,7 @@ This tutorial covers deploying an ERC-20 contract on the Polkadot Hub TestNet us Before you begin, ensure you have: -- 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. +- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming and [ERC-20](https://ethereum.org/developers/docs/standards/tokens/erc-20/){target=\_blank} fungible tokens. - An EVM-compatible [wallet](/smart-contracts/integrations/wallets){target=\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\_blank}. - 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. @@ -31,7 +31,7 @@ Follow the steps below to create the ERC-20 contract: ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-1.webp) -3. Now, paste the following ERC-20 contract code into `myToken.sol`: +3. Now, paste the following ERC-20 contract code into `MyToken.sol`: ```solidity title="MyToken.sol" --8<-- 'https://raw.githubusercontent.com/polkadot-developers/revm-hardhat-examples/refs/heads/master/erc20-hardhat/contracts/MyToken.sol' @@ -60,14 +60,14 @@ Follow these steps to deploy the contract using Remix: 1. Select **Deploy & Run Transactions** from the left panel. 2. Select the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet). -3. Configure the contract parameters to enter the address that will own the deployed token contract. +3. Configure the contract parameters by entering the address that will own the deployed token contract. 4. Click the **Deploy** button to initiate the deployment. 5. Approve the transaction in your MetaMask wallet. 6. You will see the transaction details in the terminal when the deployment succeeds, including the contract address and deployment transaction hash. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-4.gif) -## Interact With the Contract +## Interact with the Contract Once deployed, you can interact with your contract through Remix. Find your contract under **Deployed/Unpinned Contracts**, and click it to expand the available methods. In this example, you'll mint some tokens to a given address using the following steps: From 9e3169b11a9a19f33109bb0702b4c3cb65651189 Mon Sep 17 00:00:00 2001 From: DAWN KELLY Date: Thu, 20 Nov 2025 12:19:11 -0500 Subject: [PATCH 7/8] match snippet paths to file paths, standardize across hardhat guides in section --- .../basic-hardhat/Storage.sol | 0 .../basic-hardhat/compile-output.html | 0 .../basic-hardhat/deploy-output.html | 15 ++++++ .../basic-hardhat/hardhat.config.ts | 0 .../basic-hardhat/storage.ts | 0 .../erc20-hardhat/compile-output.html | 1 + .../erc20-hardhat/deploy-output.html | 1 + .../erc20-hardhat/testing-output.html | 1 + .../nft-hardhat/MyNFT.sol | 0 .../nft-hardhat/MyNFT.ts | 0 .../nft-hardhat/compile-output.html | 0 .../deploy-nft/nft-hardhat/deploy-output.html | 21 ++++++++ .../nft-hardhat/hardhat.config.ts | 0 .../nft-remix/MyNFT.sol | 0 .../deploy-basic/basic-hardhat.md | 26 +++++----- .../deploy-basic/basic-remix.md | 6 +-- .../deploy-erc20/erc20-hardhat.md | 14 +++--- .../smart-contracts/deploy-nft/nft-hardhat.md | 49 ++++++++----------- .../smart-contracts/deploy-nft/nft-remix.md | 2 +- 19 files changed, 85 insertions(+), 51 deletions(-) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-basic-contract => deploy-basic}/basic-hardhat/Storage.sol (100%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-basic-contract => deploy-basic}/basic-hardhat/compile-output.html (100%) create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-basic-contract => deploy-basic}/basic-hardhat/hardhat.config.ts (100%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-basic-contract => deploy-basic}/basic-hardhat/storage.ts (100%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-erc20-token => deploy-erc20}/erc20-hardhat/compile-output.html (84%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-erc20-token => deploy-erc20}/erc20-hardhat/deploy-output.html (93%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-erc20-token => deploy-erc20}/erc20-hardhat/testing-output.html (94%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-erc721-nft => deploy-nft}/nft-hardhat/MyNFT.sol (100%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-erc721-nft => deploy-nft}/nft-hardhat/MyNFT.ts (100%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-erc721-nft => deploy-nft}/nft-hardhat/compile-output.html (100%) create mode 100644 .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/deploy-output.html rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-erc721-nft => deploy-nft}/nft-hardhat/hardhat.config.ts (100%) rename .snippets/code/smart-contracts/cookbook/smart-contracts/{deploy-erc721-nft => deploy-nft}/nft-remix/MyNFT.sol (100%) diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/Storage.sol b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/Storage.sol similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/Storage.sol rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/Storage.sol diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/compile-output.html similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/compile-output.html diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html new file mode 100644 index 000000000..408a91af2 --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html @@ -0,0 +1,15 @@ +
+ npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTestnet + ✔ Confirm deploy to network polkadotTestnet (420420420)? … yes +   + Hardhat Ignition 🚀 +   + Deploying [ StorageModule ] +   + [ StorageModule ] successfully deployed 🚀 +   + Deployed Addresses +   + Storage - 0x12345..... + +
\ No newline at end of file diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/hardhat.config.ts similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.ts rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/hardhat.config.ts diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/storage.ts similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/storage.ts diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/compile-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/compile-output.html similarity index 84% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/compile-output.html rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/compile-output.html index 2f98ae946..525fade08 100644 --- a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/compile-output.html +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/compile-output.html @@ -3,4 +3,5 @@ Generating typings for: 23 artifacts in dir: typechain-types for target: ethers-v6 Successfully generated 62 typings! Compiled 21 Solidity files successfully (evm target: paris). +
diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html similarity index 93% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html index 940a6294c..5a29c3a74 100644 --- a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html @@ -17,4 +17,5 @@ Deployed Addresses   TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3 +
diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/testing-output.html similarity index 94% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/testing-output.html index dd15a74ac..2be1b9f77 100644 --- a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/testing-output.html @@ -13,4 +13,5 @@       ✔ Should correctly track balance after multiple mints   6 passing (369ms) +
diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.sol b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/MyNFT.sol similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.sol rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/MyNFT.sol diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/MyNFT.ts similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.ts rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/MyNFT.ts diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/compile-output.html similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/compile-output.html diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/deploy-output.html b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/deploy-output.html new file mode 100644 index 000000000..40137cd7c --- /dev/null +++ b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/deploy-output.html @@ -0,0 +1,21 @@ +
+ npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestnet + ✔ Confirm deploy to network polkadotTestnet (420420420)? … yes +   + Hardhat Ignition 🚀 +   + Deploying [ MyNFTModule ] +   + Batch #1 + Executed MyNFTModule#MyNFT +   + Batch #2 + Executed MyNFTModule#MyNFT.safeMint +   + [ TokenModule ] successfully deployed 🚀 +   + Deployed Addresses +   + MyNFTModule#MyNFT - 0x1234....... + +
\ No newline at end of file diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/hardhat.config.ts b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/hardhat.config.ts similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/hardhat.config.ts rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/hardhat.config.ts diff --git a/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol b/.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/MyNFT.sol similarity index 100% rename from .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol rename to .snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/MyNFT.sol diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md index 641b7a450..b585bbb5a 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat.md @@ -8,7 +8,7 @@ categories: Smart Contracts ## Introduction -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. +This guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub TestNet 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. ## Prerequisites @@ -31,14 +31,14 @@ npx hardhat --init ## Configure Hardhat -Open `hardhat.config.js` and add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: +Open `hardhat.config.ts` and update to add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: ```typescript title='hardhat.config.ts' hl_lines='39-43' ---8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/hardhat.config.ts' +--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/hardhat.config.ts' ``` !!! tip - Learn how to use Hardhat's [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} to handle your private keys securely. + 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. ## Create the Contract @@ -50,7 +50,7 @@ Follow these steps to create your smart contract: 3. Add the following code to create the `Storage.sol` smart contract: ```solidity title="Storage.sol" - --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/Storage.sol' + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/Storage.sol' ``` ## Compile the Contract @@ -63,11 +63,11 @@ npx hardhat compile You will see a message in the terminal confirming the contract was successfully compiled, similar to the following: ---8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/compile-output.html' +--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/compile-output.html' ## Deploy the Contract -Follow these steps to prepare for contract deployment: +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: 1. Delete the default file(s) inside the `ignition/modules` directory. @@ -76,14 +76,18 @@ Follow these steps to prepare for contract deployment: 3. Open `ignition/modules/Storage.ts` and add the following code to create your deployment module: ```typescript title="ignition/modules/Storage.ts" - --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/basic-hardhat/storage.ts' + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/storage.ts' ``` 4. Deploy your contract to Polkadot Hub TestNet using the following command: -```bash -npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTestnet -``` + ```bash + npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTestnet + ``` + +5. Confirm the target deployment network name and chain ID when prompted: + + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html' Congratulations! You've now deployed a basic smart contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress. diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md index 414d63acb..def3b0c62 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md @@ -28,7 +28,7 @@ The interface will load with a default workspace containing sample contracts. In ## Compile the Contract -Ensure your contract is open in the Remix IDE Editor, and use the following steps to compile: +Ensure your contract is open in the Remix IDE editor, and use the following steps to compile: 1. Select the **Solidity Compiler** plugin from the left panel. 2. Select the **Compile Storage.sol** button. @@ -60,7 +60,7 @@ Congratulations! You've now deployed a basic smart contract to Polkadot Hub Test --- - Walk through deploying a fully-functional ERC-20 to the Polkadot Hub using Remix. + Walk through deploying a fully-functional ERC-20 to Polkadot Hub using Remix. [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/) @@ -68,7 +68,7 @@ Congratulations! You've now deployed a basic smart contract to Polkadot Hub Test --- - Walk through deploying an NFT to the Polkadot Hub using Remix. + Walk through deploying an NFT to Polkadot Hub using Remix. [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/) diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md index 6721e7e35..430a7a383 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md @@ -12,14 +12,14 @@ tools: Hardhat [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 deployment of ERC-20 tokens via Ethereum-compatible smart contracts and tools. -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}. +This guide demonstrates how to deploy an ERC-20 contract on 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}. ## Prerequisites Before you begin, ensure you have the following: - A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming and [ERC-20](https://ethereum.org/developers/docs/standards/tokens/erc-20/){target=\_blank} fungible tokens. -- Node.js v22.13.1 or later installed. +- [Node.js](https://nodejs.org/en/download){target=\_blank} v22.13.1 or later installed. - 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. - A wallet with a private key for signing transactions. @@ -42,7 +42,7 @@ To get started, take the following steps: npm i ``` - This command will fetch all the necessary packages to help you deploy an ERC-20 with Hardhat to Polkadot. + This command will fetch all the necessary packages to help you use Hardhat to deploy an ERC-20 to Polkadot. ## Configure Hardhat @@ -72,8 +72,6 @@ If everything compiles successfully, you will see output similar to the followin ## Test the Contract -Using Hardhat's native features to test contracts against a local Hardhat development node is challenging due to some technical differences between the local node and Polkadot. This example tests contracts against a local Polkadot development node to account for these differences. - 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: - The token name and symbol exist (confirms deployment) and are correct. @@ -83,7 +81,7 @@ You can view the predefined test file at [`test/MyToken.test.ts`](https://github - The total supply increases after a mint. - Successful mints to different test addresses with expected account balance and total supply changes. -Run the test using the following command: +Run the tests using the following command: ```bash npx hardhat test --network polkadotTestnet @@ -91,7 +89,7 @@ npx hardhat test --network polkadotTestnet If tests are successful, you will see outputs similar to the following: ---8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/testing-output.html' +--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/testing-output.html' ## Deploy the Contract @@ -104,7 +102,7 @@ You are now ready to deploy the contract to your chosen network. This example de 2. Confirm the target deployment network name and chain ID when prompted: - --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc20-token/erc20-hardhat/deploy-output.html' + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html' Congratulations! You've successfully deployed an ERC-20 token contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress. diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md index 60a90ab18..f314c77d6 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat.md @@ -1,25 +1,25 @@ --- -title: Deploy ERC-721 Using Hardhat +title: Deploy an ERC-721 Using Hardhat description: Learn how to deploy an ERC-721 NFT contract to Polkadot Hub using Hardhat, a comprehensive development environment with built-in deployment capabilities. tutorial_badge: Beginner categories: Basics, Smart Contracts tools: EVM Wallet, Hardhat --- -# Deploy ERC-721 Using Hardhat +# Deploy an ERC-721 Using Hardhat ## Introduction Non-Fungible Tokens (NFTs) represent unique digital assets commonly used for digital art, collectibles, gaming, and identity verification. -This guide demonstrates how to deploy an [ERC-721](https://eips.ethereum.org/EIPS/eip-721){target=\_blank} NFT contract to [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\_blank}. You'll use OpenZeppelin's battle-tested [NFT implementation](https://github.com/OpenZeppelin/openzeppelin-contracts){target=\_blank} and [Hardhat](https://hardhat.org/docs/getting-started){target=\_blank}, a comprehensive development environment with built-in testing, debugging, and deployment capabilities. Hardhat uses standard Solidity compilation to generate EVM bytecode, making it fully compatible with Polkadot Hub's EVM environment. +This guide demonstrates how to deploy an [ERC-721](https://eips.ethereum.org/EIPS/eip-721){target=\_blank} NFT contract to [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\_blank} TestNet. You'll use OpenZeppelin's battle-tested [NFT implementation](https://github.com/OpenZeppelin/openzeppelin-contracts){target=\_blank} and [Hardhat](https://hardhat.org/docs/getting-started){target=\_blank}, a comprehensive development environment with built-in testing, debugging, and deployment capabilities. Hardhat uses standard Solidity compilation to generate EVM bytecode, making it fully compatible with Polkadot Hub's EVM environment. ## Prerequisites Before you begin, ensure you have the following: - A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming and [ERC-721](https://ethereum.org/developers/docs/standards/tokens/erc-721/){target=\_blank} non-fungible tokens. -- Node.js v22.13.1 or later installed. +- [Node.js](https://nodejs.org/en/download){target=\_blank} v22.13.1 or later installed. - 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. - A wallet with a private key for signing transactions. @@ -41,14 +41,14 @@ Before you begin, ensure you have the following: ## Configure Hardhat -Open `hardhat.config.js` and update to add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: +Open `hardhat.config.ts` and update to add `polkadotHubTestnet` to the `networks` configuration as highlighted in the following example code: ```typescript title="hardhat.config.ts" hl_lines='39-44' ---8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/hardhat.config.ts' +--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/hardhat.config.ts' ``` !!! tip - Learn how to use Hardhat's [Config Variables](https://hardhat.org/docs/learn-more/configuration-variables){target=\_blank} to handle your private keys securely. + 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. ## Create the Contract @@ -60,7 +60,7 @@ Follow these steps to create your smart contract: 3. Add the following code to create the `MyNFT.sol` smart contract: ```solidity title="contracts/MyNFT.sol" - --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.sol' + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/MyNFT.sol' ``` ## Compile the Contract @@ -73,11 +73,11 @@ npx hardhat compile You will see a message in the terminal confirming the contract was successfully compiled, similar to the following: ---8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/compile-output.html' +--8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/compile-output.html' -## Set Up Deployment +## Deploy the Contract -Follow these steps to prepare for contract deployment: +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: 1. Delete the default file(s) inside the `ignition/modules` directory. @@ -85,39 +85,32 @@ Follow these steps to prepare for contract deployment: 3. Open `ignition/modules/MyNFT.ts` and add the following code to create your deployment module: ```typescript title="ignition/modules/MyNFT.ts" - --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-hardhat/MyNFT.ts' + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/MyNFT.ts' ``` Replace `INSERT_OWNER_ADDRESS` with your desired owner address. -## Deploy the Contract +4. Deploy your contract to Polkadot Hub TestNet using the following command: -Deploy your contract to Polkadot Hub TestNet using the following command: + ```bash + npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestnet + ``` -```bash -npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestnet -``` +5. Confirm the target deployment network name and chain ID when prompted: + + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/deploy-output.html' -Congratulations! You've successfully deployed an ERC-721 NFT contract to the Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress. +Congratulations! You've successfully deployed an ERC-721 NFT contract to Polkadot Hub TestNet using Hardhat. Consider the following resources to build upon your progress. ## Where to Go Next
-- Guide __Verify Your Contract__ - - --- - - Now that you've deployed an NFT contract, learn how to verify it with Hardhat. - - [:octicons-arrow-right-24: Get Started](/smart-contracts/dev-environments/hardhat/verify-a-contract/) - - - Guide __Deploy an ERC-20__ --- - Walk through deploying a fully-functional ERC-20 to the Polkadot Hub using Hardhat. + Walk through deploying a fully-functional ERC-20 to Polkadot Hub using Hardhat. [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/) diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md index 550083c1e..bc776d900 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md @@ -35,7 +35,7 @@ The interface will load with a default workspace containing sample contracts. In --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol' ``` - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-01.webp) +![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-01.webp) ## Compile the Contract From b68d5534772ba042ca4abbad42deb3db87fe6fdf Mon Sep 17 00:00:00 2001 From: DAWN KELLY Date: Thu, 20 Nov 2025 13:40:54 -0500 Subject: [PATCH 8/8] standardize across guides for remix --- .../deploy-basic/basic-remix.md | 31 +++++---- .../deploy-erc20/erc20-remix.md | 41 ++++++------ .../smart-contracts/deploy-nft/nft-remix.md | 67 +++++++++---------- 3 files changed, 70 insertions(+), 69 deletions(-) diff --git a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md index def3b0c62..ca65761d5 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix.md @@ -15,42 +15,47 @@ This guide demonstrates how to deploy a basic Solidity smart contract to Polkado Before you begin, ensure you have the following: - A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming. +- An EVM-compatible [wallet](/smart-contracts/connect/){target=\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\_blank}. - 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. -- A wallet with a private key for signing transactions. -## Access Remix +## Locate Your Contract -Navigate to [Remix](https://remix.ethereum.org/){target=\_blank} in your web browser. +This guide uses a default contract contract provided by Remix IDE. Follow these steps to locate the contract in Remix: -The interface will load with a default workspace containing sample contracts. In this interface, you can access a file explorer, edit your code, interact with various development plugins, and use a terminal. By default, you will see the `contracts` folder with the `Storage.sol` file, which will be used as the example contract throughout this guide. +1. Navigate to [Remix IDE](https://remix.ethereum.org/){target=\_blank} in your web browser. + +2. Once the default workspace loads, locate the `contracts` folder. Inside `contracts`, locate the `Storage.sol` file which you will use as your sample contract throughout this guide. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix/basic-remix-01.webp) ## Compile the Contract -Ensure your contract is open in the Remix IDE editor, and use the following steps to compile: +Solidity source code compiles into bytecode that can be deployed on the blockchain. During this process, the compiler checks the contract for syntax errors, ensures type safety, and generates the machine-readable instructions needed for blockchain execution. + +Ensure your `Storage.sol` contract is open in the Remix IDE editor, and use the following steps to compile: 1. Select the **Solidity Compiler** plugin from the left panel. 2. Select the **Compile Storage.sol** button. - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-02.webp) - The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. If any issues arise during contract compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. +![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-02.webp) + ## Deploy the Contract Follow these steps to deploy the contract using Remix: -1. Navigate to the **Deploy & Run Transactions** tab. -2. Select the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet). -3. Select **Deploy**. -4. Approve the transaction in your MetaMask wallet. +1. Select **Deploy & Run Transactions** from the left panel. +2. Ensure your MetaMask wallet is connected to Polkadot Hub TestNet, then select the **Environment** dropdown and select **Injected Provider - MetaMask**. +3. Select the **Deploy** button to initiate the deployment. +4. Approve the transaction in your MetaMask wallet when prompted. +5. You will see the transaction details in the terminal when the deployment succeeds, including the contract address and deployment transaction hash. - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-03.webp) +![](/images/smart-contracts/cookbook/smart-contracts/deploy-basic/deploy-basic/deploy-basic-03.webp) Once successfully deployed, your contract will appear in the **Deployed Contracts** section, ready for interaction. -Congratulations! You've now deployed a basic smart contract to Polkadot Hub TestNet using Remix IDE. Consider the following resources to build upon your progress. +Congratulations! You've successfully deployed a basic smart contract to Polkadot Hub TestNet using Remix IDE. Consider the following resources to build upon your progress. ## Where to Go Next diff --git a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md index d69400857..d92da4761 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix.md @@ -1,5 +1,5 @@ --- -title: Deploy ERC-20 Using Remix IDE +title: Deploy an ERC-20 Using Remix IDE description: Deploy an ERC-20 token contract on Polkadot Hub. This guide covers contract creation, compilation, deployment, and interaction via the Remix IDE. tutorial_badge: Beginner categories: Basics, Smart Contracts @@ -12,21 +12,21 @@ tools: EVM Wallet, Remix [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. -This tutorial covers deploying an ERC-20 contract on the Polkadot Hub TestNet using [Remix IDE](https://remix.ethereum.org/){target=\_blank}, a web-based development tool. 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}. +This tutorial covers deploying an ERC-20 contract on Polkadot Hub TestNet using [Remix IDE](https://remix.ethereum.org/){target=\_blank}, a web-based development tool. 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}. ## Prerequisites Before you begin, ensure you have: - A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming and [ERC-20](https://ethereum.org/developers/docs/standards/tokens/erc-20/){target=\_blank} fungible tokens. -- An EVM-compatible [wallet](/smart-contracts/integrations/wallets){target=\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\_blank}. +- An EVM-compatible [wallet](/smart-contracts/connect/){target=\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\_blank}. - 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. ## Create Your Contract Follow the steps below to create the ERC-20 contract: -1. Navigate to the [Polkadot Remix IDE](https://remix.polkadot.io){target=\_blank}. +1. Navigate to [Remix IDE](https://remix.ethereum.org/){target=\_blank} in your web browser. 2. Select the **Create new file** button under the **contracts** folder, and name your contract `MyToken.sol`. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-1.webp) @@ -44,13 +44,12 @@ Follow the steps below to create the ERC-20 contract: Solidity source code compiles into bytecode that can be deployed on the blockchain. During this process, the compiler checks the contract for syntax errors, ensures type safety, and generates the machine-readable instructions needed for blockchain execution. -Ensure your contract is open in the Remix IDE Editor, and use the following steps to compile: +Ensure your `MyToken.sol` contract is open in the Remix IDE Editor, and use the following steps to compile: 1. Select the **Solidity Compiler** plugin from the left panel. 2. Select the **Compile MyToken.sol** button. -3. The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. -If any issues arise during contract compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. +The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. If any issues arise during contract compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-3.gif) @@ -59,29 +58,27 @@ If any issues arise during contract compilation, errors and warnings will appear Follow these steps to deploy the contract using Remix: 1. Select **Deploy & Run Transactions** from the left panel. -2. Select the **Environment** dropdown and select **Injected Provider - MetaMask** (ensure your MetaMask wallet is connected to Polkadot Hub TestNet). +2. Ensure your MetaMask wallet is connected to Polkadot Hub TestNet, then select the **Environment** dropdown and select **Injected Provider - MetaMask**. 3. Configure the contract parameters by entering the address that will own the deployed token contract. -4. Click the **Deploy** button to initiate the deployment. -5. Approve the transaction in your MetaMask wallet. +4. Select the **Deploy** button to initiate the deployment. +4. Approve the transaction in your MetaMask wallet when prompted. 6. You will see the transaction details in the terminal when the deployment succeeds, including the contract address and deployment transaction hash. - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-4.gif) +![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-4.gif) -## Interact with the Contract - -Once deployed, you can interact with your contract through Remix. Find your contract under **Deployed/Unpinned Contracts**, and click it to expand the available methods. In this example, you'll mint some tokens to a given address using the following steps: +Once successfully deployed, your contract will appear in the **Deployed Contracts** section, ready for interaction. -1. Expand the **mint** function: - 1. Enter the recipient address and the amount (remember to add 18 zeros for one whole token). - 2. Click **transact**. - -2. Approve the transaction in the MetaMask popup. +## Interact with the Contract -3. If the transaction succeeds, you will see a green check mark in the terminal. +Once deployed, you can interact with your contract through Remix. Find your contract under **Deployed/Unpinned Contracts**, and select it to expand the available methods. In this example, you'll mint some tokens to a given address using the following steps: -4. You can also call the **balanceOf** function by passing the address of the **mint** call to confirm the new balance. +1. Expand the **mint** function, then enter the recipient address and the amount (remember to add 18 zeros for one whole token). +2. Select **transact**. +3. Approve the transaction in your MetaMask wallet when prompted. +4. You will see a green check mark in the terminal when the transaction is successful. +5. You can also call the **balanceOf** function by passing the address of the **mint** call to confirm the new balance. - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-5.gif) +![](/images/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/erc20-remix-5.gif) Feel free to explore and interact with the contract's other functions by selecting the method, providing any required parameters, and confirming the transaction in MetaMask when prompted. diff --git a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md index bc776d900..c865070aa 100644 --- a/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md +++ b/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix.md @@ -1,5 +1,5 @@ --- -title: Deploy ERC-721 NFT Using Remix +title: Deploy an ERC-721 NFT Using Remix description: Learn how to deploy an ERC-721 NFT contract to Polkadot Hub using Remix, a browser-based IDE for quick prototyping and learning. tutorial_badge: Beginner categories: Basics, Smart Contracts @@ -16,71 +16,70 @@ This guide demonstrates how to deploy an [ERC-721](https://eips.ethereum.org/EIP ## Prerequisites -- Basic understanding of Solidity programming and NFT standards. -- 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} -- A wallet with a private key for signing transactions. +- A basic understanding of [Solidity](https://www.soliditylang.org/){target=\_blank} programming and [ERC-721 NFT](https://ethereum.org/developers/docs/standards/tokens/erc-721/) standards. +- An EVM-compatible [wallet](/smart-contracts/connect/){target=\_blank} connected to Polkadot Hub. This example utilizes [MetaMask](https://metamask.io/){target=\_blank}. +- 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. -## Access Remix +## Create Your Contract -Navigate to [Remix](https://remix.ethereum.org/){target=\_blank} in your web browser. +Follow the steps below to create the ERC-721 contract: -The interface will load with a default workspace containing sample contracts. In this interface, you can access a file explorer, edit your code, interact with various development plugins, and use a terminal. +1. Navigate to [Remix IDE](https://remix.ethereum.org/){target=\_blank} in your web browser. +2. Select the **Create new file** button under the **contracts** folder, and name your contract `MyNFT.sol`. -## Create Your Contract + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-01.webp) -1. Create a new file `contracts/MyNFT.sol`. -2. Now, paste the following ERC-721 contract code into `MyNFT.sol`: +3. Now, paste the following ERC-721 contract code into `MyNFT.sol`: ```solidity title="contracts/MyNFT.sol" - --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-erc721-nft/nft-remix/MyNFT.sol' + --8<-- 'code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/MyNFT.sol' ``` -![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-01.webp) + !!! tip + The [OpenZeppelin Contracts Wizard](https://wizard.openzeppelin.com/){target=\_blank} was used to generate this example ERC-721 contract. ## Compile the Contract -1. Navigate to the **Solidity Compiler** tab (third icon in the left sidebar). -2. Click **Compile MyNFT.sol** or press `Ctrl+S`. +Solidity source code compiles into bytecode that can be deployed on the blockchain. During this process, the compiler checks the contract for syntax errors, ensures type safety, and generates the machine-readable instructions needed for blockchain execution. -![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-02.webp) +Ensure your `MyNFT.sol` contract is open in the Remix IDE Editor, and use the following steps to compile: + +1. Select the **Solidity Compiler** plugin from the left panel. +2. Select the **Compile MyToken.sol** button. -Compilation errors and warnings appear in the terminal panel at the bottom of the screen. +The **Solidity Compiler** icon will display a green checkmark once the contract compiles successfully. If any issues arise during contract compilation, errors and warnings will appear in the terminal panel at the bottom of the screen. + +![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-02.webp) ## Deploy the Contract -1. Navigate to the **Deploy & Run Transactions** tab. -2. Click the **Environment** dropdown, select **Browser Extension**, and click on **Injected Provider - MetaMask**. +Follow these steps to deploy the contract using Remix: - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-03.webp) +1. Select **Deploy & Run Transactions** from the left panel. +2. Ensure your MetaMask wallet is connected to Polkadot Hub TestNet, then select the **Environment** dropdown and select **Injected Provider - MetaMask**. -3. In the deploy section, enter the initial owner address in the constructor parameter field. -4. Click **Deploy**. + ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-03.webp) - ![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-04.webp) +3. Configure the contract parameters by entering the address that will own the deployed NFT contract. +4. Select the **Deploy** button to initiate the deployment. +5. Approve the transaction in your MetaMask wallet when prompted. +6. You will see the transaction details in the terminal when the deployment succeeds, including the contract address and deployment transaction hash. -5. Approve the transaction in your MetaMask wallet. +![](/images/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/remix-04.webp) -Your deployed contract will appear in the **Deployed Contracts** section, ready for interaction. +Once successfully deployed, your contract will appear in the **Deployed Contracts** section, ready for interaction. -Congratulations! You've successfully deployed an ERC-721 NFT contract to the Polkadot Hub TestNet using Remix IDE. Consider the following resources to build upon your progress. +Congratulations! You've successfully deployed an ERC-721 NFT contract to Polkadot Hub TestNet using Remix IDE. Consider the following resources to build upon your progress. ## Where to Go Next
-- Guide __Verify Your Contract__ - - --- - - Now that you've deployed an NFT contract, learn how to verify it with Remix. - - [:octicons-arrow-right-24: Get Started](/smart-contracts/dev-environments/remix/verify-a-contract/) - - Guide __Deploy an ERC-20__ --- - Walk through deploying a fully-functional ERC-20 to the Polkadot Hub using Remix. + Walk through deploying a fully-functional ERC-20 to Polkadot Hub using Remix. [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/smart-contracts/deploy-erc20/remix/)