You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -403,13 +403,7 @@ Update your root parachain template's `Cargo.toml` file to include your custom p
403
403
Make sure the `custom-pallet` is a member of the workspace:
404
404
405
405
```toml hl_lines="4" title="Cargo.toml"
406
-
[workspace]
407
-
default-members = ["pallets/template", "runtime"]
408
-
members = [
409
-
"node", "pallets/custom-pallet",
410
-
"pallets/template",
411
-
"runtime",
412
-
]
406
+
413
407
```
414
408
415
409
???- code "./Cargo.toml"
@@ -2590,53 +2584,13 @@ To build the smart contract, follow the steps below:
2590
2584
6. Add the getter and setter functions:
2591
2585
2592
2586
```solidity
2593
-
// SPDX-License-Identifier: MIT
2594
-
pragma solidity ^0.8.28;
2595
-
2596
-
contract Storage {
2597
-
// State variable to store our number
2598
-
uint256 private number;
2599
-
2600
-
// Event to notify when the number changes
2601
-
event NumberChanged(uint256 newNumber);
2602
-
2603
-
// Function to store a new number
2604
-
function store(uint256 newNumber) public {
2605
-
number = newNumber;
2606
-
emit NumberChanged(newNumber);
2607
-
}
2608
-
2609
-
// Function to retrieve the stored number
2610
-
function retrieve() public view returns (uint256) {
2611
-
return number;
2612
-
}
2613
-
}
2587
+
2614
2588
```
2615
2589
2616
2590
??? code "Complete Storage.sol contract"
2617
2591
2618
2592
```solidity title="Storage.sol"
2619
-
// SPDX-License-Identifier: MIT
2620
-
pragma solidity ^0.8.28;
2621
-
2622
-
contract Storage {
2623
-
// State variable to store our number
2624
-
uint256 private number;
2625
-
2626
-
// Event to notify when the number changes
2627
-
event NumberChanged(uint256 newNumber);
2628
-
2629
-
// Function to store a new number
2630
-
function store(uint256 newNumber) public {
2631
-
number = newNumber;
2632
-
emit NumberChanged(newNumber);
2633
-
}
2634
-
2635
-
// Function to retrieve the stored number
2636
-
function retrieve() public view returns (uint256) {
2637
-
return number;
2638
-
}
2639
-
}
2593
+
2640
2594
```
2641
2595
2642
2596
## Understanding the Code
@@ -3274,23 +3228,7 @@ To create the ERC-20 contract, you can follow the steps below:
3274
3228
3. Now, paste the following ERC-20 contract code into the editor:
3275
3229
3276
3230
```solidity title="MyToken.sol"
3277
-
// SPDX-License-Identifier: MIT
3278
-
// Compatible with OpenZeppelin Contracts ^5.0.0
3279
-
pragma solidity ^0.8.22;
3280
-
3281
-
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
3282
-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
3283
-
3284
-
contract MyToken is ERC20, Ownable {
3285
-
constructor(address initialOwner)
3286
-
ERC20("MyToken", "MTK")
3287
-
Ownable(initialOwner)
3288
-
{}
3289
-
3290
-
function mint(address to, uint256 amount) public onlyOwner {
3291
-
_mint(to, amount);
3292
-
}
3293
-
}
3231
+
3294
3232
```
3295
3233
3296
3234
The key components of the code above are:
@@ -3608,26 +3546,7 @@ To create the NFT contract, you can follow the steps below:
3608
3546
3. Now, paste the following NFT contract code into the editor.
3609
3547
3610
3548
```solidity title="MyNFT.sol"
3611
-
// SPDX-License-Identifier: MIT
3612
-
// Compatible with OpenZeppelin Contracts ^5.0.0
3613
-
pragma solidity ^0.8.22;
3614
-
3615
-
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
3616
-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
3617
-
3618
-
contract MyToken is ERC721, Ownable {
3619
-
uint256 private _nextTokenId;
3620
-
3621
-
constructor(address initialOwner)
3622
-
ERC721("MyToken", "MTK")
3623
-
Ownable(initialOwner)
3624
-
{}
3625
-
3626
-
function safeMint(address to) public onlyOwner {
3627
-
uint256 tokenId = _nextTokenId++;
3628
-
_safeMint(to, tokenId);
3629
-
}
3630
-
}
3549
+
3631
3550
```
3632
3551
3633
3552
The key components of the code above are:
@@ -9254,8 +9173,7 @@ The [`XcmRouter`](https://paritytech.github.io/polkadot-sdk/master/pallet_xcm/pa
9254
9173
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.
For more details about XCM transport protocols, see the [XCM Channels](/develop/interoperability/xcm-channels/){target=\_blank} page.
@@ -10381,95 +10299,25 @@ The `xcm-emulator` provides macros for defining a mocked testing environment. Ch
10381
10299
- **[`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:
- **[`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:
- **[`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:
10439
10312
10440
10313
```rust
10441
-
decl_test_bridges! {
10442
-
pub struct RococoWestendMockBridge {
10443
-
source = BridgeHubRococoPara,
10444
-
target = BridgeHubWestendPara,
10445
-
handler = RococoWestendMessageHandler
10446
-
},
10447
-
pub struct WestendRococoMockBridge {
10448
-
source = BridgeHubWestendPara,
10449
-
target = BridgeHubRococoPara,
10450
-
handler = WestendRococoMessageHandler
10451
-
}
10452
-
}
10314
+
10453
10315
```
10454
10316
10455
10317
- **[`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:
10456
10318
10457
10319
```rust
10458
-
decl_test_networks! {
10459
-
pub struct WestendMockNet {
10460
-
relay_chain = Westend,
10461
-
parachains = vec![
10462
-
AssetHubWestend,
10463
-
BridgeHubWestend,
10464
-
CollectivesWestend,
10465
-
CoretimeWestend,
10466
-
PeopleWestend,
10467
-
PenpalA,
10468
-
PenpalB,
10469
-
],
10470
-
bridge = ()
10471
-
},
10472
-
}
10320
+
10473
10321
```
10474
10322
10475
10323
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