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
* add pallet unit testing
* add pallet testing
* Adding a pallet is included in the create a pallet page
* Resolve PR review comments
- Add periods to bullet points for consistency
- Change Events and Block Number admonition from warning to info
- Add title to lib.rs code block
* Resolve PR review comments and add pallet code reference
- Add periods to all bullet points for consistency
- Change Events and Block Number admonition from warning to info
- Add title to lib.rs code block
- Add collapsible complete pallet code reference using snippet include
- Add test descriptions as sentences under section headers
* llms
* resolve llms
* Formatting
* terminal element
* fix spacing
* check links and update .nav.yml to remove add-pallet-to-runtime page
* Merge staging/product-ia
---------
Co-authored-by: Taylor Lucero <Telucero@users.noreply.github.com>
Co-authored-by: Taylor Lucero <67010424+Telucero@users.noreply.github.com>
Co-authored-by: Erin Shaben <eshaben@icloud.com>
Copy file name to clipboardExpand all lines: .ai/categories/basics.md
-357Lines changed: 0 additions & 357 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,362 +117,6 @@ The address mapping system maintains security through several design choices evi
117
117
All source code references are from the [`address.rs`](https://github.com/paritytech/polkadot-sdk/blob/stable2412/substrate/frame/revive/src/address.rs){target=\_blank} file in the Revive pallet of the Polkadot SDK repository.
- Summary: Add pallets to your runtime for custom functionality. Learn to configure and integrate pallets in Polkadot SDK-based blockchains.
127
-
128
-
# Add Pallets to the Runtime
129
-
130
-
## Introduction
131
-
132
-
In previous tutorials, you learned how to [create a custom pallet](/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/){target=\_blank} and [test it](/tutorials/polkadot-sdk/parachains/zero-to-hero/pallet-unit-testing/){target=\_blank}. The next step is to include this pallet in your runtime, integrating it into the core logic of your blockchain.
133
-
134
-
This tutorial will guide you through adding two pallets to your runtime: the custom pallet you previously developed and the [utility pallet](https://paritytech.github.io/polkadot-sdk/master/pallet_utility/index.html){target=\_blank}. This standard Polkadot SDK pallet provides powerful dispatch functionality. The utility pallet offers, for example, batch dispatch, a stateless operation that enables executing multiple calls in a single transaction.
135
-
136
-
## Add the Pallets as Dependencies
137
-
138
-
First, you'll update the runtime's `Cargo.toml` file to include the Utility pallet and your custom pallets as dependencies for the runtime. Follow these steps:
139
-
140
-
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:
141
-
142
-
```toml hl_lines="4" title="runtime/Cargo.toml"
143
-
[dependencies]
144
-
...
145
-
polkadot-sdk = { workspace = true, features = [
146
-
"pallet-utility",
147
-
...
148
-
], default-features = false }
149
-
```
150
-
151
-
2. In the same `[dependencies]` section, add the custom pallet that you built from scratch with the following line:
Configure the pallets by implementing their `Config` trait and update the runtime macro to include the new pallets:
353
-
354
-
1. Add the `OriginCaller` import:
355
-
356
-
```rust title="mod.rs"hl_lines="8"
357
-
// Local module imports
358
-
use super::OriginCaller;
359
-
...
360
-
```
361
-
362
-
2. Implement the [`Config`](https://paritytech.github.io/polkadot-sdk/master/pallet_utility/pallet/trait.Config.html){target=\_blank} trait for both pallets at the end of the `runtime/src/config/mod.rs` file:
363
-
364
-
```rust title="mod.rs"hl_lines="8-25"
365
-
...
366
-
/// Configure the pallet template in pallets/template.
367
-
impl pallet_parachain_template::Config for Runtime {
368
-
type RuntimeEvent = RuntimeEvent;
369
-
type WeightInfo = pallet_parachain_template::weights::SubstrateWeight<Runtime>;
370
-
}
371
-
372
-
// Configure utility pallet.
373
-
impl pallet_utility::Config for Runtime {
374
-
type RuntimeEvent = RuntimeEvent;
375
-
type RuntimeCall = RuntimeCall;
376
-
type PalletsOrigin = OriginCaller;
377
-
type WeightInfo = pallet_utility::weights::SubstrateWeight<Runtime>;
378
-
}
379
-
// Define counter max value runtime constant.
380
-
parameter_types! {
381
-
pub const CounterMaxValue: u32 = 500;
382
-
}
383
-
384
-
// Configure custom pallet.
385
-
impl custom_pallet::Config for Runtime {
386
-
type RuntimeEvent = RuntimeEvent;
387
-
type CounterMaxValue = CounterMaxValue;
388
-
}
389
-
```
390
-
391
-
3. Locate the `#[frame_support::runtime]` macro in the `runtime/src/lib.rs` file and add the pallets:
392
-
393
-
```rust hl_lines="9-14"title="lib.rs"
394
-
#[frame_support::runtime]
395
-
mod runtime {
396
-
#[runtime::runtime]
397
-
#[runtime::derive(
398
-
...
399
-
)]
400
-
pub struct Runtime;
401
-
#[runtime::pallet_index(51)]
402
-
pub type Utility = pallet_utility;
403
-
404
-
#[runtime::pallet_index(52)]
405
-
pub type CustomPallet = custom_pallet;
406
-
}
407
-
```
408
-
409
-
## Recompile the Runtime
410
-
411
-
After adding and configuring your pallets in the runtime, the next step is to ensure everything is set up correctly. To do this, recompile the runtime with the following command (make sure you're in the project's root directory):
412
-
413
-
```bash
414
-
cargo build --release
415
-
```
416
-
417
-
This command ensures the runtime compiles without errors, validates the pallet configurations, and prepares the build for subsequent testing or deployment.
418
-
419
-
## Run Your Chain Locally
420
-
421
-
Launch your parachain locally and start producing blocks:
422
-
423
-
!!!tip
424
-
Generated chain TestNet specifications include development accounts "Alice" and "Bob." These accounts are pre-funded with native parachain currency, allowing you to sign and send TestNet transactions. Take a look at the [Polkadot.js Accounts section](https://polkadot.js.org/apps/#/accounts){target=\_blank} to view the development accounts for your chain.
425
-
426
-
1. Create a new chain specification file with the updated runtime:
3. Verify you can interact with the new pallets using the [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/extrinsics){target=\_blank} interface. Navigate to the **Extrinsics** tab and check that you can see both pallets:
Discover how to measure extrinsic costs and assign precise weights to optimize your pallet for accurate fees and runtime performance.
470
-
471
-
[:octicons-arrow-right-24: Get Started](/tutorials/polkadot-sdk/parachains/zero-to-hero/pallet-benchmarking/)
472
-
473
-
</div>
474
-
475
-
476
120
---
477
121
478
122
Page Title: Contract Deployment
@@ -1514,7 +1158,6 @@ Deep dive into creating and managing custom pallets for your parachain.
1514
1158
| [Create a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) | Build a pallet from scratch with custom logic |
1515
1159
| [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) | Set up a mock runtime environment for testing |
1516
1160
| [Pallet Unit Testing](/parachains/customize-runtime/pallet-development/pallet-testing/) | Write comprehensive tests for your pallet logic |
1517
-
| [Add Your Custom Pallet to the Runtime](/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/) | Integrate your custom pallet into your parachain runtime |
1518
1161
| [Benchmark the Custom Pallet](/parachains/customize-runtime/pallet-development/benchmark-pallet/) | Measure and optimize pallet performance with benchmarking |
0 commit comments