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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File path here doesn't match either can drop -contract so it's just deploy-basic like the directory

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')],
},
polkadotHubTestnet: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, should have shared before, but Nico said we should follow these conventions:

revive dev node -> localNode -> rpc: localhost:8545
live network -> polkadotTestNet -> rpc: https://testnet-passet-hub-eth-rpc.polkadot.io/

So can you please rename this to polkadotTestNet? And any other instances too please?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, just saw we're using polkadotTestnet no capitalized Net in the demo repo: https://github.com/polkadot-developers/revm-hardhat-examples/blob/master/erc20-hardhat/hardhat.config.ts#L35

So let's do that here please

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,6 @@
<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>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<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>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File path isn't correct, it should be deploy-erc20 (can drop -token). This is important to make sure they're exactly 1:1 matches because when we do a reorg next time, we can use a script that just grabs them by their file path, but in order to do this, we need to make sure the file path actually matches, otherwise the script doesn't pick up on these and it's a lot of manual work.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<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>
</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,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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file path doesn't match the file, need to remove erc721 from the path so it's just deploy-nft

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);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some inconsistencies here with the numbers we're using. Can we make them all double-digit like -01.webp?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also inconsistencies with the paths: erc20-remix/erc20-remix-1.webp vs nft-remix/remix-01.webp

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
6 changes: 3 additions & 3 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 Basic Contract': deploy-basic
- 'Deploy ERC-20 Token': deploy-erc20
- 'Deploy ERC-721 NFT': deploy-nft
Comment on lines +2 to +4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the “verb + article + object” pattern in many other pages (e.g., “Create a DApp,” “Get Tokens From the Faucet”), so switching to titles like “Deploy Basic Contract” is a bit of an inconsistent change. So I think we should switch it back in this case

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