Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>npx hardhat compile</span>
<span data-ty>Downloading solc 0.8.28</span>
<span data-ty>Downloading solc 0.8.28 (WASM build)</span>
<span data-ty>Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun)</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div id="termynal" data-termynal markdown>
<span data-ty="input">npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnet</span>
<span data-ty>βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes</span>
<span data-ty>&nbsp;</span>
<span data-ty>Hardhat Ignition πŸš€</span>
<span data-ty>&nbsp;</span>
<span data-ty>Deploying [ StorageModule ]</span>
<span data-ty>&nbsp;</span>
<span data-ty>[ StorageModule ] successfully deployed πŸš€</span>
<span data-ty>&nbsp;</span>
<span data-ty>Deployed Addresses</span>
<span data-ty>&nbsp;</span>
<span data-ty>Storage - 0x12345.....</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
Original file line number Diff line number Diff line change
@@ -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')],
},
polkadotTestnet: {
url: 'https://testnet-passet-hub-eth-rpc.polkadot.io',
chainId: 420420422,
accounts: [configVariable('PRIVATE_KEY')],
},
},
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules';

export default buildModule('StorageModule', (m) => {
const storage = m.contract('Storage');
return { storage };
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="termynal" data-termynal markdown>
<span data-ty="input">npx hardhat compile</span>
<span data-ty>Generating typings for: 23 artifacts in dir: typechain-types for target: ethers-v6</span>
<span data-ty>Successfully generated 62 typings!</span>
<span data-ty>Compiled 21 Solidity files successfully (evm target: paris).</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div id="termynal" data-termynal markdown>
<span data-ty="input">npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotTestnet</span>
<span data-ty>βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes</span>
<span data-ty>&nbsp;</span>
<span data-ty>Hardhat Ignition πŸš€</span>
<span data-ty>&nbsp;</span>
<span data-ty>Deploying [ TokenModule ]</span>
<span data-ty>&nbsp;</span>
<span data-ty>Batch #1</span>
<span data-ty> Executed TokenModule#MyToken</span>
<span data-ty>&nbsp;</span>
<span data-ty>Batch #2</span>
<span data-ty> Executed TokenModule#MyToken.mint</span>
<span data-ty>&nbsp;</span>
<span data-ty>[ TokenModule ] successfully deployed πŸš€</span>
<span data-ty>&nbsp;</span>
<span data-ty>Deployed Addresses</span>
<span data-ty>&nbsp;</span>
<span data-ty>TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div id="termynal" data-termynal markdown>
<span data-ty="input">npx hardhat test --network polkadotTestnet</span>
<span data-ty></span>
<span data-ty>&nbsp;&nbsp;MyToken</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;Deployment</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;βœ” Should have correct name and symbol</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;βœ” Should set the right owner</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;βœ” Should have zero initial supply</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;Minting</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;βœ” Should allow owner to mint tokens</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;βœ” Should increase total supply on mint</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;Multiple mints</span>
<span data-ty>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;βœ” Should correctly track balance after multiple mints</span>
<span data-ty></span>
<span data-ty>&nbsp;&nbsp;6 passing (369ms)</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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 };
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>npx hardhat compile</span>
<span data-ty>Downloading solc 0.8.28</span>
<span data-ty>Downloading solc 0.8.28 (WASM build)</span>
<span data-ty>Compiled 1 Solidity file with solc 0.8.28 (evm target: cancun)</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div id="termynal" data-termynal markdown>
<span data-ty="input">npx hardhat ignition deploy ignition/modules/MyNFT.ts --network polkadotHubTestnet</span>
<span data-ty>βœ” Confirm deploy to network polkadotTestnet (420420420)? … yes</span>
<span data-ty>&nbsp;</span>
<span data-ty>Hardhat Ignition πŸš€</span>
<span data-ty>&nbsp;</span>
<span data-ty>Deploying [ MyNFTModule ]</span>
<span data-ty>&nbsp;</span>
<span data-ty>Batch #1</span>
<span data-ty> Executed MyNFTModule#MyNFT</span>
<span data-ty>&nbsp;</span>
<span data-ty>Batch #2</span>
<span data-ty> Executed MyNFTModule#MyNFT.safeMint</span>
<span data-ty>&nbsp;</span>
<span data-ty>[ TokenModule ] successfully deployed πŸš€</span>
<span data-ty>&nbsp;</span>
<span data-ty>Deployed Addresses</span>
<span data-ty>&nbsp;</span>
<span data-ty>MyNFTModule#MyNFT - 0x1234.......</span>
<span data-ty="input"><span class="file-path"></span></span>
</div>
Original file line number Diff line number Diff line change
@@ -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')],
},
polkadotTestnet: {
type: 'http',
url: 'https://testnet-passet-hub-eth-rpc.polkadot.io',
chainId: 420420422,
accounts: [configVariable('PRIVATE_KEY')],
},
},
};

export default config;
Original file line number Diff line number Diff line change
@@ -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);
}
}
File renamed without changes
2 changes: 1 addition & 1 deletion smart-contracts/cookbook/.nav.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions smart-contracts/cookbook/dapps/zero-to-hero.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion smart-contracts/cookbook/eth-dapps/uniswap-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion smart-contracts/cookbook/index.md
Original file line number Diff line number Diff line change
@@ -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
---
Expand Down
4 changes: 2 additions & 2 deletions smart-contracts/cookbook/smart-contracts/.nav.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nav:
- 'Deploy a Basic Contract': deploy-basic
- 'Deploy an ERC-20': deploy-erc20
- 'Deploy an NFT': deploy-nft
- 'Deploy an ERC-20 Token': deploy-erc20
- 'Deploy an ERC-721 NFT': deploy-nft
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading