-
Notifications
You must be signed in to change notification settings - Fork 75
Cleanup smart contracts/cookbook/EVM smart contracts #1243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dawnkelly09
wants to merge
9
commits into
staging/product-ia
Choose a base branch
from
dawn/cookbook-evmsc-storytelling
base: staging/product-ia
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+748
β711
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
70701b4
storytelling clean up cookbook --> smart-contracts
dawnkelly09 9705924
more storytelling/formatting cleanup for cookbooks/smart contracts
dawnkelly09 95d4479
storytelling cleanup
dawnkelly09 6076bb9
storytelling/cleanup
dawnkelly09 0f355af
grammarly pass
dawnkelly09 45c992e
applying feedback
dawnkelly09 9e3169b
match snippet paths to file paths, standardize across hardhat guides β¦
dawnkelly09 b68d553
standardize across guides for remix
dawnkelly09 1cde7be
rename and update image paths, polkadotHubTestnet -> polkadotTestnet β¦
dawnkelly09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...pets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/Storage.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
...e/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/compile-output.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
15 changes: 15 additions & 0 deletions
15
...de/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/deploy-output.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> </span> | ||
| <span data-ty>Hardhat Ignition π</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Deploying [ StorageModule ]</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>[ StorageModule ] successfully deployed π</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Deployed Addresses</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Storage - 0x12345.....</span> | ||
| <span data-ty="input"><span class="file-path"></span></span> | ||
| </div> |
47 changes: 47 additions & 0 deletions
47
...ode/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/hardhat.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
6 changes: 6 additions & 0 deletions
6
...ppets/code/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-hardhat/storage.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }; | ||
| }); |
7 changes: 7 additions & 0 deletions
7
...e/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/compile-output.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
21 changes: 21 additions & 0 deletions
21
...de/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/deploy-output.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> </span> | ||
| <span data-ty>Hardhat Ignition π</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Deploying [ TokenModule ]</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Batch #1</span> | ||
| <span data-ty> Executed TokenModule#MyToken</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Batch #2</span> | ||
| <span data-ty> Executed TokenModule#MyToken.mint</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>[ TokenModule ] successfully deployed π</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Deployed Addresses</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>TokenModule#MyToken - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3</span> | ||
| <span data-ty="input"><span class="file-path"></span></span> | ||
| </div> |
17 changes: 17 additions & 0 deletions
17
...e/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat/testing-output.html
dawnkelly09 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> MyToken</span> | ||
| <span data-ty> Deployment</span> | ||
| <span data-ty> β Should have correct name and symbol</span> | ||
| <span data-ty> β Should set the right owner</span> | ||
| <span data-ty> β Should have zero initial supply</span> | ||
| <span data-ty> Minting</span> | ||
| <span data-ty> β Should allow owner to mint tokens</span> | ||
| <span data-ty> β Should increase total supply on mint</span> | ||
| <span data-ty> Multiple mints</span> | ||
| <span data-ty> β Should correctly track balance after multiple mints</span> | ||
| <span data-ty></span> | ||
| <span data-ty> 6 passing (369ms)</span> | ||
| <span data-ty="input"><span class="file-path"></span></span> | ||
| </div> |
18 changes: 18 additions & 0 deletions
18
.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/MyNFT.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/MyNFT.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }; | ||
| }); |
7 changes: 7 additions & 0 deletions
7
.../code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/compile-output.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
21 changes: 21 additions & 0 deletions
21
...s/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/deploy-output.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> </span> | ||
| <span data-ty>Hardhat Ignition π</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Deploying [ MyNFTModule ]</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Batch #1</span> | ||
| <span data-ty> Executed MyNFTModule#MyNFT</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Batch #2</span> | ||
| <span data-ty> Executed MyNFTModule#MyNFT.safeMint</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>[ TokenModule ] successfully deployed π</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>Deployed Addresses</span> | ||
| <span data-ty> </span> | ||
| <span data-ty>MyNFTModule#MyNFT - 0x1234.......</span> | ||
| <span data-ty="input"><span class="file-path"></span></span> | ||
| </div> |
48 changes: 48 additions & 0 deletions
48
...ts/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-hardhat/hardhat.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
18 changes: 18 additions & 0 deletions
18
.snippets/code/smart-contracts/cookbook/smart-contracts/deploy-nft/nft-remix/MyNFT.sol
dawnkelly09 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
dawnkelly09 marked this conversation as resolved.
Show resolved
Hide resolved
|
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
4 changes: 2 additions & 2 deletions
4
smart-contracts/cookbook/smart-contracts/deploy-basic/.nav.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.