Skip to content

Commit 64e08a5

Browse files
nhussein11eshaben
andauthored
Add Deploy NFT page (new IA) (#1137)
* fix: wip * refactor: update NFT deployment and compilation scripts * fix: update links to open in new tab for better user experience * fix: llms * delete: remove unused NFT deployment image * split up the deploy an nft page * update remix images and deleted unused ones * update formatting * llms * delete old files * llms --------- Co-authored-by: Erin Shaben <[email protected]>
1 parent e4de6be commit 64e08a5

File tree

58 files changed

+9394
-985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+9394
-985
lines changed

.ai/categories/basics.md

Lines changed: 170 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ First, you'll update the runtime's `Cargo.toml` file to include the Utility pall
256256
1. Open the `runtime/Cargo.toml` file and locate the `[dependencies]` section. Add pallet-utility as one of the features for the `polkadot-sdk` dependency with the following line:
257257

258258
```toml hl_lines="4" title="runtime/Cargo.toml"
259-
259+
[dependencies]
260260
...
261261
polkadot-sdk = { workspace = true, features = [
262262
"pallet-utility",
@@ -267,17 +267,19 @@ First, you'll update the runtime's `Cargo.toml` file to include the Utility pall
267267
2. In the same `[dependencies]` section, add the custom pallet that you built from scratch with the following line:
268268

269269
```toml hl_lines="3" title="Cargo.toml"
270-
270+
[dependencies]
271271
...
272-
272+
custom-pallet = { path = "../pallets/custom-pallet", default-features = false }
273273
```
274274

275275
3. In the `[features]` section, add the custom pallet to the `std` feature list:
276276

277277
```toml hl_lines="5" title="Cargo.toml"
278-
278+
[features]
279+
default = ["std"]
280+
std = [
279281
...
280-
282+
"custom-pallet/std",
281283
...
282284
]
283285
```
@@ -2699,13 +2701,53 @@ To build the smart contract, follow the steps below:
26992701
6. Add the getter and setter functions:
27002702

27012703
```solidity
2702-
2704+
// SPDX-License-Identifier: MIT
2705+
pragma solidity ^0.8.28;
2706+
2707+
contract Storage {
2708+
// State variable to store our number
2709+
uint256 private number;
2710+
2711+
// Event to notify when the number changes
2712+
event NumberChanged(uint256 newNumber);
2713+
2714+
// Function to store a new number
2715+
function store(uint256 newNumber) public {
2716+
number = newNumber;
2717+
emit NumberChanged(newNumber);
2718+
}
2719+
2720+
// Function to retrieve the stored number
2721+
function retrieve() public view returns (uint256) {
2722+
return number;
2723+
}
2724+
}
27032725
```
27042726

27052727
??? code "Complete Storage.sol contract"
27062728

27072729
```solidity title="Storage.sol"
2708-
2730+
// SPDX-License-Identifier: MIT
2731+
pragma solidity ^0.8.28;
2732+
2733+
contract Storage {
2734+
// State variable to store our number
2735+
uint256 private number;
2736+
2737+
// Event to notify when the number changes
2738+
event NumberChanged(uint256 newNumber);
2739+
2740+
// Function to store a new number
2741+
function store(uint256 newNumber) public {
2742+
number = newNumber;
2743+
emit NumberChanged(newNumber);
2744+
}
2745+
2746+
// Function to retrieve the stored number
2747+
function retrieve() public view returns (uint256) {
2748+
return number;
2749+
}
2750+
}
27092751
```
27102752

27112753
## Understanding the Code
@@ -3343,7 +3385,23 @@ To create the ERC-20 contract, you can follow the steps below:
33433385
3. Now, paste the following ERC-20 contract code into the editor:
33443386

33453387
```solidity title="MyToken.sol"
3346-
3388+
// SPDX-License-Identifier: MIT
3389+
// Compatible with OpenZeppelin Contracts ^5.0.0
3390+
pragma solidity ^0.8.22;
3391+
3392+
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
3393+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
3394+
3395+
contract MyToken is ERC20, Ownable {
3396+
constructor(address initialOwner)
3397+
ERC20("MyToken", "MTK")
3398+
Ownable(initialOwner)
3399+
{}
3400+
3401+
function mint(address to, uint256 amount) public onlyOwner {
3402+
_mint(to, amount);
3403+
}
3404+
}
33473405
```
33483406

33493407
The key components of the code above are:
@@ -8224,7 +8282,16 @@ The [`Account` data type](https://paritytech.github.io/polkadot-sdk/master/frame
82248282
The code snippet below shows how accounts are defined:
82258283

82268284
```rs
8227-
8285+
/// The full account information for a particular account ID.
8286+
#[pallet::storage]
8287+
#[pallet::getter(fn account)]
8288+
pub type Account<T: Config> = StorageMap<
8289+
_,
8290+
Blake2_128Concat,
8291+
T::AccountId,
8292+
AccountInfo<T::Nonce, T::AccountData>,
8293+
ValueQuery,
8294+
>;
82288295
```
82298296

82308297
The preceding code block defines a storage map named `Account`. The `StorageMap` is a type of on-chain storage that maps keys to values. In the `Account` map, the key is an account ID, and the value is the account's information. Here, `T` represents the generic parameter for the runtime configuration, which is defined by the pallet's configuration trait (`Config`).
@@ -8248,7 +8315,24 @@ For a detailed explanation of storage maps, see the [`StorageMap`](https://parit
82488315
The `AccountInfo` structure is another key element within the [System pallet](https://paritytech.github.io/polkadot-sdk/master/src/frame_system/lib.rs.html){target=\_blank}, providing more granular details about each account's state. This structure tracks vital data, such as the number of transactions and the account’s relationships with other modules.
82498316

82508317
```rs
8251-
8318+
/// Information of an account.
8319+
#[derive(Clone, Eq, PartialEq, Default, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)]
8320+
pub struct AccountInfo<Nonce, AccountData> {
8321+
/// The number of transactions this account has sent.
8322+
pub nonce: Nonce,
8323+
/// The number of other modules that currently depend on this account's existence. The account
8324+
/// cannot be reaped until this is zero.
8325+
pub consumers: RefCount,
8326+
/// The number of other modules that allow this account to exist. The account may not be reaped
8327+
/// until this and `sufficients` are both zero.
8328+
pub providers: RefCount,
8329+
/// The number of modules that allow this account to exist for their own purposes only. The
8330+
/// account may not be reaped until this and `providers` are both zero.
8331+
pub sufficients: RefCount,
8332+
/// The additional data that belongs to this account. Used to store the balance(s) in a lot of
8333+
/// chains.
8334+
pub data: AccountData,
8335+
}
82528336
```
82538337

82548338
The `AccountInfo` structure includes the following components:
@@ -9262,7 +9346,8 @@ The [`XcmRouter`](https://paritytech.github.io/polkadot-sdk/master/pallet_xcm/pa
92629346
For instance, the Kusama network employs the [`ChildParachainRouter`](https://paritytech.github.io/polkadot-sdk/master/polkadot_runtime_common/xcm_sender/struct.ChildParachainRouter.html){target=\_blank}, which restricts routing to [Downward Message Passing (DMP)](https://wiki.polkadot.com/learn/learn-xcm-transport/#dmp-downward-message-passing){target=\_blank} from the relay chain to parachains, ensuring secure and controlled communication.
92639347

92649348
```rust
9265-
9349+
pub type PriceForChildParachainDelivery =
9350+
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, Dmp>;
92669351
```
92679352

92689353
For more details about XCM transport protocols, see the [XCM Channels](/develop/interoperability/xcm-channels/){target=\_blank} page.
@@ -10388,25 +10473,95 @@ The `xcm-emulator` provides macros for defining a mocked testing environment. Ch
1038810473
- **[`decl_test_relay_chains`](https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2506-2/cumulus/xcm/xcm-emulator/src/lib.rs#L361){target=\_blank}**: Defines runtime and configuration for the relay chains. Example:
1038910474

1039010475
```rust
10391-
10476+
decl_test_relay_chains! {
10477+
#[api_version(13)]
10478+
pub struct Westend {
10479+
genesis = genesis::genesis(),
10480+
on_init = (),
10481+
runtime = westend_runtime,
10482+
core = {
10483+
SovereignAccountOf: westend_runtime::xcm_config::LocationConverter,
10484+
},
10485+
pallets = {
10486+
XcmPallet: westend_runtime::XcmPallet,
10487+
Sudo: westend_runtime::Sudo,
10488+
Balances: westend_runtime::Balances,
10489+
Treasury: westend_runtime::Treasury,
10490+
AssetRate: westend_runtime::AssetRate,
10491+
Hrmp: westend_runtime::Hrmp,
10492+
Identity: westend_runtime::Identity,
10493+
IdentityMigrator: westend_runtime::IdentityMigrator,
10494+
}
10495+
},
10496+
}
1039210497
```
1039310498

1039410499
- **[`decl_test_parachains`](https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2506-2/cumulus/xcm/xcm-emulator/src/lib.rs#L596){target=\_blank}**: Defines runtime and configuration for parachains. Example:
1039510500

1039610501
```rust
10397-
10502+
decl_test_parachains! {
10503+
pub struct AssetHubWestend {
10504+
genesis = genesis::genesis(),
10505+
on_init = {
10506+
asset_hub_westend_runtime::AuraExt::on_initialize(1);
10507+
},
10508+
runtime = asset_hub_westend_runtime,
10509+
core = {
10510+
XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue,
10511+
LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId,
10512+
ParachainInfo: asset_hub_westend_runtime::ParachainInfo,
10513+
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
10514+
DigestProvider: (),
10515+
},
10516+
pallets = {
10517+
PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm,
10518+
Balances: asset_hub_westend_runtime::Balances,
10519+
Assets: asset_hub_westend_runtime::Assets,
10520+
ForeignAssets: asset_hub_westend_runtime::ForeignAssets,
10521+
PoolAssets: asset_hub_westend_runtime::PoolAssets,
10522+
AssetConversion: asset_hub_westend_runtime::AssetConversion,
10523+
SnowbridgeSystemFrontend: asset_hub_westend_runtime::SnowbridgeSystemFrontend,
10524+
Revive: asset_hub_westend_runtime::Revive,
10525+
}
10526+
},
10527+
}
1039810528
```
1039910529

1040010530
- **[`decl_test_bridges`](https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2506-2/cumulus/xcm/xcm-emulator/src/lib.rs#L1221){target=\_blank}**: Creates bridges between chains, specifying the source, target, and message handler. Example:
1040110531

1040210532
```rust
10403-
10533+
decl_test_bridges! {
10534+
pub struct RococoWestendMockBridge {
10535+
source = BridgeHubRococoPara,
10536+
target = BridgeHubWestendPara,
10537+
handler = RococoWestendMessageHandler
10538+
},
10539+
pub struct WestendRococoMockBridge {
10540+
source = BridgeHubWestendPara,
10541+
target = BridgeHubRococoPara,
10542+
handler = WestendRococoMessageHandler
10543+
}
10544+
}
1040410545
```
1040510546

1040610547
- **[`decl_test_networks`](https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2506-2/cumulus/xcm/xcm-emulator/src/lib.rs#L958){target=\_blank}**: Defines a testing network with relay chains, parachains, and bridges, implementing message transport and processing logic. Example:
1040710548

1040810549
```rust
10409-
10550+
decl_test_networks! {
10551+
pub struct WestendMockNet {
10552+
relay_chain = Westend,
10553+
parachains = vec![
10554+
AssetHubWestend,
10555+
BridgeHubWestend,
10556+
CollectivesWestend,
10557+
CoretimeWestend,
10558+
PeopleWestend,
10559+
PenpalA,
10560+
PenpalB,
10561+
],
10562+
bridge = ()
10563+
},
10564+
}
1041010565
```
1041110566

1041210567
By leveraging these macros, developers can customize their testing networks by defining relay chains and parachains tailored to their needs. For guidance on implementing a mock runtime for a Polkadot SDK-based chain, refer to the [Pallet Testing](/parachains/customize-runtime/pallet-development/pallet-testing/){target=\_blank} article.

0 commit comments

Comments
 (0)