From a88d825b5a39c1a8dc7bdf58112a370698843032 Mon Sep 17 00:00:00 2001 From: Bruno Galvao Date: Mon, 3 Nov 2025 12:48:05 +0700 Subject: [PATCH 01/10] add pallet unit testing --- .ai/categories/parachains.md | 419 +++++++++++++++--- ...ntime-pallet-development-pallet-testing.md | 419 +++++++++++++++--- .ai/site-index.json | 104 ++++- llms-full.jsonl | 28 +- llms.txt | 2 +- .../pallet-development/pallet-testing.md | 419 ++++++++++++++++-- 6 files changed, 1209 insertions(+), 182 deletions(-) diff --git a/.ai/categories/parachains.md b/.ai/categories/parachains.md index b4b15609c..4164ba551 100644 --- a/.ai/categories/parachains.md +++ b/.ai/categories/parachains.md @@ -12522,136 +12522,435 @@ Your pallet is now complete with full testing and benchmarking support, ready fo --- -Page Title: Pallet Testing +Page Title: Pallet Unit Testing - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md - Canonical (HTML): https://docs.polkadot.com/parachains/customize-runtime/pallet-development/pallet-testing/ -- Summary: Learn how to efficiently test pallets in the Polkadot SDK, ensuring the reliability and security of your pallets operations. +- Summary: Learn how to write comprehensive unit tests for your custom pallets using mock runtimes, ensuring reliability and correctness before deployment. -# Pallet Testing +# Pallet Unit Testing ## Introduction -Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. The Polkadot SDK offers a set of APIs to create a test environment to simulate runtime and mock transaction execution for extrinsics and queries. +Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation. + +In this guide, you'll learn how to: + +- Structure test modules effectively +- Test dispatchable functions +- Verify storage changes +- Check event emission +- Test error conditions +- Use genesis configurations in tests + +## Prerequisites + +Before you begin, ensure you have: + +- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide +- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide +- The custom counter pallet with mock runtime in `pallets/pallet-custom` +- Basic understanding of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\_blank} + +## Understanding FRAME Testing Tools -To begin unit testing, you must first set up a mock runtime that simulates blockchain behavior, incorporating the necessary pallets. For a deeper understanding, consult the [Mock Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/){target=\_blank} guide. +FRAME provides specialized testing macros and utilities that make pallet testing more efficient: -## Writing Unit Tests +### Assertion Macros -Once the mock runtime is in place, the next step is to write unit tests that evaluate the functionality of your pallet. Unit tests allow you to test specific pallet features in isolation, ensuring that each function behaves correctly under various conditions. These tests typically reside in your pallet module's `test.rs` file. +- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds +- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation) +- **`assert_eq!`** - Standard Rust equality assertion -Unit tests in the Polkadot SDK use the Rust testing framework, and the mock runtime you've defined earlier will serve as the test environment. Below are the typical steps involved in writing unit tests for a pallet. +!!!info "`assert_noop!` Explained" + Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified. -The tests confirm that: +### System Pallet Test Helpers -- **Pallets initialize correctly**: At the start of each test, the system should initialize with block number 0, and the pallets should be in their default states. -- **Pallets modify each other's state**: The second test shows how one pallet can trigger changes in another pallet's internal state, confirming proper cross-pallet interactions. -- **State transitions between blocks are seamless**: By simulating block transitions, the tests validate that the runtime responds correctly to changes in the block number. +The [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\_blank} pallet provides useful methods for testing: -Testing pallet interactions within the runtime is critical for ensuring the blockchain behaves as expected under real-world conditions. Writing integration tests allows validation of how pallets function together, preventing issues that might arise when the system is fully assembled. +- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test +- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations +- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number -This approach provides a comprehensive view of the runtime's functionality, ensuring the blockchain is stable and reliable. +!!!warning "Events and Block Number" + Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`. -### Test Initialization +### Origin Types -Each test starts by initializing the runtime environment, typically using the `new_test_ext()` function, which sets up the mock storage and environment. +- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations +- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account +- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations) + +Learn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\_blank}. + +## Create the Tests Module + +Create a new file for your tests within the pallet directory: + +1. Navigate to your pallet directory: + + ```bash + cd pallets/pallet-custom/src + ``` + +2. Create a new file named `tests.rs`: + + ```bash + touch tests.rs + ``` + +3. Open `src/lib.rs` and add the tests module declaration after the mock module: + + ```rust + #![cfg_attr(not(feature = "std"), no_std)] + + pub use pallet::*; + + #[cfg(test)] + mod mock; + + #[cfg(test)] + mod tests; + + #[frame::pallet] + pub mod pallet { + // ... existing pallet code + } + ``` + +## Set Up the Test Module + +Open `src/tests.rs` and add the basic structure with necessary imports: + +```rust +use crate::{mock::*, Error, Event}; +use frame_support::{assert_noop, assert_ok}; +``` + +This setup imports: +- The mock runtime and test utilities from `mock.rs` +- Your pallet's `Error` and `Event` types +- FRAME's assertion macros + +## Write Your First Test + +Let's start with a simple test to verify the increment function works correctly. + +### Test Basic Increment ```rust #[test] -fn test_pallet_functionality() { +fn increment_works() { new_test_ext().execute_with(|| { - // Test logic goes here + // Given: counter starts at 0 + let alice = 1u64; + + // When: Alice increments by 5 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + // Then: counter value and user interactions are updated + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 1); }); } ``` -### Function Call Testing +Run your first test: -Call the pallet's extrinsics or functions to simulate user interaction or internal logic. Use the `assert_ok!` macro to check for successful execution and `assert_err!` to verify that errors are correctly handled. +```bash +cargo test --package pallet-custom increment_works +``` + +You should see: + +``` +running 1 test +test tests::increment_works ... ok +``` + +🎉 Congratulations! You've written and run your first pallet test. + +## Test Error Conditions + +Now let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely. + +### Test Overflow Protection ```rust #[test] -fn it_works_for_valid_input() { - new_test_ext().execute_with(|| { - // Call an extrinsic or function - assert_ok!(TemplateModule::some_function(Origin::signed(1), valid_param)); +fn increment_handles_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + // Given: counter is at maximum u32 value + let alice = 1u64; + + // When: attempting to increment + // Then: should fail with overflow error and no state change + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + Error::::Overflow + ); + + // Verify no state changes occurred + assert_eq!(crate::CounterValue::::get(), u32::MAX); + assert_eq!(crate::UserInteractions::::get(alice), 0); }); } +``` +Test overflow protection: + +```bash +cargo test --package pallet-custom increment_handles_overflow +``` + +### Test Underflow Protection + +```rust #[test] -fn it_fails_for_invalid_input() { - new_test_ext().execute_with(|| { - // Call an extrinsic with invalid input and expect an error - assert_err!( - TemplateModule::some_function(Origin::signed(1), invalid_param), - Error::::InvalidInput +fn decrement_handles_underflow() { + new_test_ext_with_counter(5).execute_with(|| { + // Given: counter is at 5 + let alice = 1u64; + + // When: attempting to decrement by more than current value + // Then: should fail with underflow error + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + Error::::Underflow ); + + // Verify no state changes occurred + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 0); }); } ``` -### Storage Testing +Verify underflow protection: + +```bash +cargo test --package pallet-custom decrement_handles_underflow +``` + +## Test Access Control -After calling a function or extrinsic in your pallet, it's essential to verify that the state changes in the pallet's storage match the expected behavior to ensure data is updated correctly based on the actions taken. +Verify that origin checks work correctly and unauthorized access is prevented. -The following example shows how to test the storage behavior before and after the function call: +### Test Root-Only Access ```rust #[test] -fn test_storage_update_on_extrinsic_call() { +fn set_counter_value_requires_root() { new_test_ext().execute_with(|| { - // Check the initial storage state (before the call) - assert_eq!(Something::::get(), None); - - // Dispatch a signed extrinsic, which modifies storage - assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42)); - - // Validate that the storage has been updated as expected (after the call) - assert_eq!(Something::::get(), Some(42)); + let alice = 1u64; + + // When: non-root user tries to set counter + // Then: should fail with BadOrigin + assert_noop!( + CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), + sp_runtime::DispatchError::BadOrigin + ); + + // But root should succeed + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); }); } +``` +Test access control: + +```bash +cargo test --package pallet-custom set_counter_value_requires_root ``` -### Event Testing +## Test Event Emission -It's also crucial to test the events that your pallet emits during execution. By default, events generated in a pallet using the [`#generate_deposit`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.generate_deposit.html){target=\_blank} macro are stored under the system's event storage key (system/events) as [`EventRecord`](https://paritytech.github.io/polkadot-sdk/master/frame_system/struct.EventRecord.html){target=\_blank} entries. These can be accessed using [`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank} or verified with specific helper methods provided by the system pallet, such as [`assert_has_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_has_event){target=\_blank} and [`assert_last_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}. +Verify that events are emitted correctly with the right data. -Here's an example of testing events in a mock runtime: +### Test Event Data ```rust #[test] -fn it_emits_events_on_success() { +fn increment_emits_event() { new_test_ext().execute_with(|| { - // Call an extrinsic or function - assert_ok!(TemplateModule::some_function(Origin::signed(1), valid_param)); + let alice = 1u64; + + // Set block number to enable events + System::set_block_number(1); + + // When: increment occurs + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + // Then: correct event is emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 5, + who: alice, + amount: 5, + } + .into(), + ); + }); +} +``` + +Run the event test: + +```bash +cargo test --package pallet-custom increment_emits_event +``` + +## Test Genesis Configuration - // Verify that the expected event was emitted - assert!(System::events().iter().any(|record| { - record.event == Event::TemplateModule(TemplateEvent::SomeEvent) - })); +Verify that genesis configuration works correctly. + +### Test Genesis Setup + +```rust +#[test] +fn genesis_config_works() { + new_test_ext_with_counter(100).execute_with(|| { + // Given: genesis sets counter to 100 + // Then: counter should start at that value + assert_eq!(crate::CounterValue::::get(), 100); + + // And: we can still interact with it + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); + assert_eq!(crate::CounterValue::::get(), 110); }); } ``` -Some key considerations are: +Test genesis configuration: -- **Block number**: Events are not emitted on the genesis block, so you need to set the block number using [`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank} to ensure events are triggered. -- **Converting events**: Use `.into()` when instantiating your pallet's event to convert it into a generic event type, as required by the system's event storage. +```bash +cargo test --package pallet-custom genesis_config_works +``` -## Where to Go Next +## Run All Tests + +Now run all your tests together: + +```bash +cargo test --package pallet-custom +``` + +You should see all tests passing: + +``` +running 6 tests +test tests::decrement_handles_underflow ... ok +test tests::genesis_config_works ... ok +test tests::increment_emits_event ... ok +test tests::increment_handles_overflow ... ok +test tests::increment_works ... ok +test tests::set_counter_value_requires_root ... ok + +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +``` + +🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! + +These six tests demonstrate the core patterns you'll use in pallet testing. As you build more complex pallets, you'll apply these same patterns to test additional functionality. + +??? code "Full Test Suite Code" + Here's the complete `tests.rs` file for quick reference: + + ```rust + use crate::{mock::*, Error, Event}; + use frame_support::{assert_noop, assert_ok}; -- Dive into the full implementation of the [`mock.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/mock.rs){target=\_blank} and [`test.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/tests.rs){target=\_blank} files in the [Solochain Template](https://github.com/paritytech/polkadot-sdk/tree/master/templates/solochain){target=_blank}. + #[test] + fn increment_works() { + new_test_ext().execute_with(|| { + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 1); + }); + } + + #[test] + fn increment_handles_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + Error::::Overflow + ); + assert_eq!(crate::CounterValue::::get(), u32::MAX); + assert_eq!(crate::UserInteractions::::get(alice), 0); + }); + } + + #[test] + fn decrement_handles_underflow() { + new_test_ext_with_counter(5).execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + Error::::Underflow + ); + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 0); + }); + } + + #[test] + fn set_counter_value_requires_root() { + new_test_ext().execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), + sp_runtime::DispatchError::BadOrigin + ); + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + }); + } + + #[test] + fn increment_emits_event() { + new_test_ext().execute_with(|| { + let alice = 1u64; + System::set_block_number(1); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + System::assert_last_event( + Event::CounterIncremented { + new_value: 5, + who: alice, + amount: 5, + } + .into(), + ); + }); + } + + #[test] + fn genesis_config_works() { + new_test_ext_with_counter(100).execute_with(|| { + assert_eq!(crate::CounterValue::::get(), 100); + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); + assert_eq!(crate::CounterValue::::get(), 110); + }); + } + ``` + +## Where to Go Next
-- Guide __Benchmarking__ +- Guide __Add Your Custom Pallet to the Runtime__ --- - Explore methods to measure the performance and execution cost of your pallet. + Your pallet is tested and ready! Learn how to integrate it into your runtime. - [:octicons-arrow-right-24: Reference](/develop/parachains/testing/benchmarking) + [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)
diff --git a/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md b/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md index b26d07b1f..95dc53989 100644 --- a/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md +++ b/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md @@ -1,133 +1,432 @@ --- -title: Pallet Testing -description: Learn how to efficiently test pallets in the Polkadot SDK, ensuring the reliability and security of your pallets operations. +title: Pallet Unit Testing +description: Learn how to write comprehensive unit tests for your custom pallets using mock runtimes, ensuring reliability and correctness before deployment. categories: Parachains url: https://docs.polkadot.com/parachains/customize-runtime/pallet-development/pallet-testing/ --- -# Pallet Testing +# Pallet Unit Testing ## Introduction -Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. The Polkadot SDK offers a set of APIs to create a test environment to simulate runtime and mock transaction execution for extrinsics and queries. +Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation. -To begin unit testing, you must first set up a mock runtime that simulates blockchain behavior, incorporating the necessary pallets. For a deeper understanding, consult the [Mock Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/){target=\_blank} guide. +In this guide, you'll learn how to: -## Writing Unit Tests +- Structure test modules effectively +- Test dispatchable functions +- Verify storage changes +- Check event emission +- Test error conditions +- Use genesis configurations in tests -Once the mock runtime is in place, the next step is to write unit tests that evaluate the functionality of your pallet. Unit tests allow you to test specific pallet features in isolation, ensuring that each function behaves correctly under various conditions. These tests typically reside in your pallet module's `test.rs` file. +## Prerequisites -Unit tests in the Polkadot SDK use the Rust testing framework, and the mock runtime you've defined earlier will serve as the test environment. Below are the typical steps involved in writing unit tests for a pallet. +Before you begin, ensure you have: -The tests confirm that: +- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide +- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide +- The custom counter pallet with mock runtime in `pallets/pallet-custom` +- Basic understanding of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\_blank} -- **Pallets initialize correctly**: At the start of each test, the system should initialize with block number 0, and the pallets should be in their default states. -- **Pallets modify each other's state**: The second test shows how one pallet can trigger changes in another pallet's internal state, confirming proper cross-pallet interactions. -- **State transitions between blocks are seamless**: By simulating block transitions, the tests validate that the runtime responds correctly to changes in the block number. +## Understanding FRAME Testing Tools -Testing pallet interactions within the runtime is critical for ensuring the blockchain behaves as expected under real-world conditions. Writing integration tests allows validation of how pallets function together, preventing issues that might arise when the system is fully assembled. +FRAME provides specialized testing macros and utilities that make pallet testing more efficient: -This approach provides a comprehensive view of the runtime's functionality, ensuring the blockchain is stable and reliable. +### Assertion Macros -### Test Initialization +- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds +- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation) +- **`assert_eq!`** - Standard Rust equality assertion -Each test starts by initializing the runtime environment, typically using the `new_test_ext()` function, which sets up the mock storage and environment. +!!!info "`assert_noop!` Explained" + Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified. + +### System Pallet Test Helpers + +The [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\_blank} pallet provides useful methods for testing: + +- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test +- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations +- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number + +!!!warning "Events and Block Number" + Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`. + +### Origin Types + +- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations +- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account +- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations) + +Learn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\_blank}. + +## Create the Tests Module + +Create a new file for your tests within the pallet directory: + +1. Navigate to your pallet directory: + + ```bash + cd pallets/pallet-custom/src + ``` + +2. Create a new file named `tests.rs`: + + ```bash + touch tests.rs + ``` + +3. Open `src/lib.rs` and add the tests module declaration after the mock module: + + ```rust + #![cfg_attr(not(feature = "std"), no_std)] + + pub use pallet::*; + + #[cfg(test)] + mod mock; + + #[cfg(test)] + mod tests; + + #[frame::pallet] + pub mod pallet { + // ... existing pallet code + } + ``` + +## Set Up the Test Module + +Open `src/tests.rs` and add the basic structure with necessary imports: + +```rust +use crate::{mock::*, Error, Event}; +use frame_support::{assert_noop, assert_ok}; +``` + +This setup imports: +- The mock runtime and test utilities from `mock.rs` +- Your pallet's `Error` and `Event` types +- FRAME's assertion macros + +## Write Your First Test + +Let's start with a simple test to verify the increment function works correctly. + +### Test Basic Increment ```rust #[test] -fn test_pallet_functionality() { +fn increment_works() { new_test_ext().execute_with(|| { - // Test logic goes here + // Given: counter starts at 0 + let alice = 1u64; + + // When: Alice increments by 5 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + // Then: counter value and user interactions are updated + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 1); }); } ``` -### Function Call Testing +Run your first test: + +```bash +cargo test --package pallet-custom increment_works +``` -Call the pallet's extrinsics or functions to simulate user interaction or internal logic. Use the `assert_ok!` macro to check for successful execution and `assert_err!` to verify that errors are correctly handled. +You should see: + +``` +running 1 test +test tests::increment_works ... ok +``` + +🎉 Congratulations! You've written and run your first pallet test. + +## Test Error Conditions + +Now let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely. + +### Test Overflow Protection ```rust #[test] -fn it_works_for_valid_input() { - new_test_ext().execute_with(|| { - // Call an extrinsic or function - assert_ok!(TemplateModule::some_function(Origin::signed(1), valid_param)); +fn increment_handles_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + // Given: counter is at maximum u32 value + let alice = 1u64; + + // When: attempting to increment + // Then: should fail with overflow error and no state change + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + Error::::Overflow + ); + + // Verify no state changes occurred + assert_eq!(crate::CounterValue::::get(), u32::MAX); + assert_eq!(crate::UserInteractions::::get(alice), 0); }); } +``` + +Test overflow protection: + +```bash +cargo test --package pallet-custom increment_handles_overflow +``` + +### Test Underflow Protection +```rust #[test] -fn it_fails_for_invalid_input() { - new_test_ext().execute_with(|| { - // Call an extrinsic with invalid input and expect an error - assert_err!( - TemplateModule::some_function(Origin::signed(1), invalid_param), - Error::::InvalidInput +fn decrement_handles_underflow() { + new_test_ext_with_counter(5).execute_with(|| { + // Given: counter is at 5 + let alice = 1u64; + + // When: attempting to decrement by more than current value + // Then: should fail with underflow error + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + Error::::Underflow ); + + // Verify no state changes occurred + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 0); }); } ``` -### Storage Testing +Verify underflow protection: + +```bash +cargo test --package pallet-custom decrement_handles_underflow +``` + +## Test Access Control -After calling a function or extrinsic in your pallet, it's essential to verify that the state changes in the pallet's storage match the expected behavior to ensure data is updated correctly based on the actions taken. +Verify that origin checks work correctly and unauthorized access is prevented. -The following example shows how to test the storage behavior before and after the function call: +### Test Root-Only Access ```rust #[test] -fn test_storage_update_on_extrinsic_call() { +fn set_counter_value_requires_root() { new_test_ext().execute_with(|| { - // Check the initial storage state (before the call) - assert_eq!(Something::::get(), None); - - // Dispatch a signed extrinsic, which modifies storage - assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42)); - - // Validate that the storage has been updated as expected (after the call) - assert_eq!(Something::::get(), Some(42)); + let alice = 1u64; + + // When: non-root user tries to set counter + // Then: should fail with BadOrigin + assert_noop!( + CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), + sp_runtime::DispatchError::BadOrigin + ); + + // But root should succeed + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); }); } +``` + +Test access control: +```bash +cargo test --package pallet-custom set_counter_value_requires_root ``` -### Event Testing +## Test Event Emission -It's also crucial to test the events that your pallet emits during execution. By default, events generated in a pallet using the [`#generate_deposit`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.generate_deposit.html){target=\_blank} macro are stored under the system's event storage key (system/events) as [`EventRecord`](https://paritytech.github.io/polkadot-sdk/master/frame_system/struct.EventRecord.html){target=\_blank} entries. These can be accessed using [`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank} or verified with specific helper methods provided by the system pallet, such as [`assert_has_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_has_event){target=\_blank} and [`assert_last_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}. +Verify that events are emitted correctly with the right data. -Here's an example of testing events in a mock runtime: +### Test Event Data ```rust #[test] -fn it_emits_events_on_success() { +fn increment_emits_event() { new_test_ext().execute_with(|| { - // Call an extrinsic or function - assert_ok!(TemplateModule::some_function(Origin::signed(1), valid_param)); + let alice = 1u64; + + // Set block number to enable events + System::set_block_number(1); + + // When: increment occurs + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + // Then: correct event is emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 5, + who: alice, + amount: 5, + } + .into(), + ); + }); +} +``` - // Verify that the expected event was emitted - assert!(System::events().iter().any(|record| { - record.event == Event::TemplateModule(TemplateEvent::SomeEvent) - })); +Run the event test: + +```bash +cargo test --package pallet-custom increment_emits_event +``` + +## Test Genesis Configuration + +Verify that genesis configuration works correctly. + +### Test Genesis Setup + +```rust +#[test] +fn genesis_config_works() { + new_test_ext_with_counter(100).execute_with(|| { + // Given: genesis sets counter to 100 + // Then: counter should start at that value + assert_eq!(crate::CounterValue::::get(), 100); + + // And: we can still interact with it + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); + assert_eq!(crate::CounterValue::::get(), 110); }); } ``` -Some key considerations are: +Test genesis configuration: -- **Block number**: Events are not emitted on the genesis block, so you need to set the block number using [`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank} to ensure events are triggered. -- **Converting events**: Use `.into()` when instantiating your pallet's event to convert it into a generic event type, as required by the system's event storage. +```bash +cargo test --package pallet-custom genesis_config_works +``` -## Where to Go Next +## Run All Tests -- Dive into the full implementation of the [`mock.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/mock.rs){target=\_blank} and [`test.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/tests.rs){target=\_blank} files in the [Solochain Template](https://github.com/paritytech/polkadot-sdk/tree/master/templates/solochain){target=_blank}. +Now run all your tests together: + +```bash +cargo test --package pallet-custom +``` + +You should see all tests passing: + +``` +running 6 tests +test tests::decrement_handles_underflow ... ok +test tests::genesis_config_works ... ok +test tests::increment_emits_event ... ok +test tests::increment_handles_overflow ... ok +test tests::increment_works ... ok +test tests::set_counter_value_requires_root ... ok + +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +``` + +🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! + +These six tests demonstrate the core patterns you'll use in pallet testing. As you build more complex pallets, you'll apply these same patterns to test additional functionality. + +??? code "Full Test Suite Code" + Here's the complete `tests.rs` file for quick reference: + + ```rust + use crate::{mock::*, Error, Event}; + use frame_support::{assert_noop, assert_ok}; + + #[test] + fn increment_works() { + new_test_ext().execute_with(|| { + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 1); + }); + } + + #[test] + fn increment_handles_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + Error::::Overflow + ); + assert_eq!(crate::CounterValue::::get(), u32::MAX); + assert_eq!(crate::UserInteractions::::get(alice), 0); + }); + } + + #[test] + fn decrement_handles_underflow() { + new_test_ext_with_counter(5).execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + Error::::Underflow + ); + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 0); + }); + } + + #[test] + fn set_counter_value_requires_root() { + new_test_ext().execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), + sp_runtime::DispatchError::BadOrigin + ); + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + }); + } + + #[test] + fn increment_emits_event() { + new_test_ext().execute_with(|| { + let alice = 1u64; + System::set_block_number(1); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + System::assert_last_event( + Event::CounterIncremented { + new_value: 5, + who: alice, + amount: 5, + } + .into(), + ); + }); + } + + #[test] + fn genesis_config_works() { + new_test_ext_with_counter(100).execute_with(|| { + assert_eq!(crate::CounterValue::::get(), 100); + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); + assert_eq!(crate::CounterValue::::get(), 110); + }); + } + ``` + +## Where to Go Next
-- Guide __Benchmarking__ +- Guide __Add Your Custom Pallet to the Runtime__ --- - Explore methods to measure the performance and execution cost of your pallet. + Your pallet is tested and ready! Learn how to integrate it into your runtime. - [:octicons-arrow-right-24: Reference](/develop/parachains/testing/benchmarking) + [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)
diff --git a/.ai/site-index.json b/.ai/site-index.json index b7fe65c81..cef1898af 100644 --- a/.ai/site-index.json +++ b/.ai/site-index.json @@ -5085,14 +5085,14 @@ }, { "id": "parachains-customize-runtime-pallet-development-pallet-testing", - "title": "Pallet Testing", + "title": "Pallet Unit Testing", "slug": "parachains-customize-runtime-pallet-development-pallet-testing", "categories": [ "Parachains" ], "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md", "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/pallet-testing/", - "preview": "Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. The Polkadot SDK offers a set of APIs to create a test environment to simulate runtime and mock transaction execution for extrinsics and queries.", + "preview": "Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation.", "outline": [ { "depth": 2, @@ -5101,28 +5101,98 @@ }, { "depth": 2, - "title": "Writing Unit Tests", - "anchor": "writing-unit-tests" + "title": "Prerequisites", + "anchor": "prerequisites" + }, + { + "depth": 2, + "title": "Understanding FRAME Testing Tools", + "anchor": "understanding-frame-testing-tools" + }, + { + "depth": 3, + "title": "Assertion Macros", + "anchor": "assertion-macros" + }, + { + "depth": 3, + "title": "System Pallet Test Helpers", + "anchor": "system-pallet-test-helpers" }, { "depth": 3, - "title": "Test Initialization", - "anchor": "test-initialization" + "title": "Origin Types", + "anchor": "origin-types" + }, + { + "depth": 2, + "title": "Create the Tests Module", + "anchor": "create-the-tests-module" + }, + { + "depth": 2, + "title": "Set Up the Test Module", + "anchor": "set-up-the-test-module" + }, + { + "depth": 2, + "title": "Write Your First Test", + "anchor": "write-your-first-test" }, { "depth": 3, - "title": "Function Call Testing", - "anchor": "function-call-testing" + "title": "Test Basic Increment", + "anchor": "test-basic-increment" + }, + { + "depth": 2, + "title": "Test Error Conditions", + "anchor": "test-error-conditions" }, { "depth": 3, - "title": "Storage Testing", - "anchor": "storage-testing" + "title": "Test Overflow Protection", + "anchor": "test-overflow-protection" }, { "depth": 3, - "title": "Event Testing", - "anchor": "event-testing" + "title": "Test Underflow Protection", + "anchor": "test-underflow-protection" + }, + { + "depth": 2, + "title": "Test Access Control", + "anchor": "test-access-control" + }, + { + "depth": 3, + "title": "Test Root-Only Access", + "anchor": "test-root-only-access" + }, + { + "depth": 2, + "title": "Test Event Emission", + "anchor": "test-event-emission" + }, + { + "depth": 3, + "title": "Test Event Data", + "anchor": "test-event-data" + }, + { + "depth": 2, + "title": "Test Genesis Configuration", + "anchor": "test-genesis-configuration" + }, + { + "depth": 3, + "title": "Test Genesis Setup", + "anchor": "test-genesis-setup" + }, + { + "depth": 2, + "title": "Run All Tests", + "anchor": "run-all-tests" }, { "depth": 2, @@ -5131,12 +5201,12 @@ } ], "stats": { - "chars": 6892, - "words": 911, - "headings": 7, - "estimated_token_count_total": 1563 + "chars": 13324, + "words": 1456, + "headings": 21, + "estimated_token_count_total": 3128 }, - "hash": "sha256:8568dfa238b9a649a4e6e60510625c2e7879b76a93187b0b8b8dccf6bc467ae6", + "hash": "sha256:a60f4cb8e7322b71786ca8f2de1b6f6605950e7d40e1bfe702b26ff301dbc004", "token_estimator": "heuristic-v1" }, { diff --git a/llms-full.jsonl b/llms-full.jsonl index 82d08baf5..794ba4014 100644 --- a/llms-full.jsonl +++ b/llms-full.jsonl @@ -603,13 +603,27 @@ {"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 3, "depth": 3, "title": "Genesis Storage", "anchor": "genesis-storage", "start_char": 2264, "end_char": 5778, "estimated_token_count": 767, "token_estimator": "heuristic-v1", "text": "### Genesis Storage\n\nThe next step is configuring the genesis storage—the initial state of your runtime. Genesis storage sets the starting conditions for the runtime, defining how pallets are configured before any blocks are produced. You can only customize the initial state only of those items that implement the [`[pallet::genesis_config]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.genesis_config.html){target=\\_blank} and [`[pallet::genesis_build]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.genesis_build.html){target=\\_blank} macros within their respective pallets.\n\nIn Polkadot SDK, you can create this storage using the [`BuildStorage`](https://paritytech.github.io/polkadot-sdk/master/sp_runtime/trait.BuildStorage.html){target=\\_blank} trait from the [`sp_runtime`](https://paritytech.github.io/polkadot-sdk/master/sp_runtime){target=\\_blank} crate. This trait is essential for building the configuration that initializes the blockchain's state. \n\nThe function `new_test_ext()` demonstrates setting up this environment. It uses `frame_system::GenesisConfig::::default()` to generate a default genesis configuration for the runtime, followed by `.build_storage()` to create the initial storage state. This storage is then converted into a format usable by the testing framework, [`sp_io::TestExternalities`](https://paritytech.github.io/polkadot-sdk/master/sp_io/type.TestExternalities.html){target=\\_blank}, allowing tests to be executed in a simulated blockchain environment.\n\nHere's the code that sets the genesis storage configuration:\n\n```rust\npub mod tests {\n use crate::*;\n use sp_runtime::BuildStorage;\n\n #[frame_support::runtime]\n mod runtime {\n #[runtime::runtime]\n #[runtime::derive(\n RuntimeCall,\n RuntimeEvent,\n RuntimeError,\n RuntimeOrigin,\n RuntimeFreezeReason,\n RuntimeHoldReason,\n RuntimeSlashReason,\n RuntimeLockId,\n RuntimeTask\n )]\n pub struct Test;\n\n #[runtime::pallet_index(0)]\n pub type System = frame_system::Pallet;\n\n // Other pallets...\n }\n\n pub fn new_test_ext() -> sp_io::TestExternalities {\n frame_system::GenesisConfig::::default()\n .build_storage()\n .unwrap()\n .into()\n }\n}\n```\n\nYou can also customize the genesis storage to set initial values for your runtime pallets. For example, you can set the initial balance for accounts like this:\n\n```rust\n// Build genesis storage according to the runtime's configuration\npub fn new_test_ext() -> sp_io::TestExternalities {\n // Define the initial balances for accounts\n let initial_balances: Vec<(AccountId32, u128)> = vec![\n (AccountId32::from([0u8; 32]), 1_000_000_000_000),\n (AccountId32::from([1u8; 32]), 2_000_000_000_000),\n ];\n\n let mut t = frame_system::GenesisConfig::::default()\n .build_storage()\n .unwrap();\n\n // Adding balances configuration to the genesis config\n pallet_balances::GenesisConfig:: {\n balances: initial_balances,\n }\n .assimilate_storage(&mut t)\n .unwrap();\n\n t.into()\n}\n```\n\nFor a more idiomatic approach, see the [Your First Pallet](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#better-test-setup){target=\\_blank} guide from the Polkadot SDK Rust documentation."} {"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 4, "depth": 3, "title": "Pallet Configuration", "anchor": "pallet-configuration", "start_char": 5778, "end_char": 6780, "estimated_token_count": 207, "token_estimator": "heuristic-v1", "text": "### Pallet Configuration\n\nEach pallet in the mocked runtime requires an associated configuration, specifying the types and values it depends on to function. These configurations often use basic or primitive types (e.g., u32, bool) instead of more complex types like structs or traits, ensuring the setup remains straightforward and manageable.\n\n```rust\n#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]\nimpl frame_system::Config for Test {\n ...\n type Index = u64;\n type BlockNumber = u64;\n type Hash = H256;\n type Hashing = BlakeTwo256;\n type AccountId = u64;\n ...\n}\n\nimpl pallet_template::Config for Test {\n\ttype RuntimeEvent = RuntimeEvent;\n\ttype WeightInfo = ();\n ...\n}\n```\n\nThe configuration should be set for each pallet existing in the mocked runtime. The simplification of types is for simplifying the testing process. For example, `AccountId` is `u64`, meaning a valid account address can be an unsigned integer:\n\n```rust\nlet alice_account: u64 = 1;\n```"} {"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 5, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6780, "end_char": 7514, "estimated_token_count": 170, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nWith the mock environment in place, developers can now test and explore how pallets interact and ensure they work seamlessly together. For further details about mocking runtimes, see the following [Polkadot SDK docs guide](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#your-first-test-runtime){target=\\_blank}.\n\n
\n\n- Guide __Pallet Testing__\n\n ---\n\n Learn how to efficiently test pallets in the Polkadot SDK, ensuring your pallet operations are reliable and secure.\n\n [:octicons-arrow-right-24: Reference](/parachains/customize-runtime/pallet-development/pallet-testing/)\n\n
"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 18, "end_char": 672, "estimated_token_count": 123, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nUnit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. The Polkadot SDK offers a set of APIs to create a test environment to simulate runtime and mock transaction execution for extrinsics and queries.\n\nTo begin unit testing, you must first set up a mock runtime that simulates blockchain behavior, incorporating the necessary pallets. For a deeper understanding, consult the [Mock Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/){target=\\_blank} guide."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 1, "depth": 2, "title": "Writing Unit Tests", "anchor": "writing-unit-tests", "start_char": 672, "end_char": 2195, "estimated_token_count": 285, "token_estimator": "heuristic-v1", "text": "## Writing Unit Tests\n\nOnce the mock runtime is in place, the next step is to write unit tests that evaluate the functionality of your pallet. Unit tests allow you to test specific pallet features in isolation, ensuring that each function behaves correctly under various conditions. These tests typically reside in your pallet module's `test.rs` file.\n\nUnit tests in the Polkadot SDK use the Rust testing framework, and the mock runtime you've defined earlier will serve as the test environment. Below are the typical steps involved in writing unit tests for a pallet.\n\nThe tests confirm that:\n\n- **Pallets initialize correctly**: At the start of each test, the system should initialize with block number 0, and the pallets should be in their default states.\n- **Pallets modify each other's state**: The second test shows how one pallet can trigger changes in another pallet's internal state, confirming proper cross-pallet interactions.\n- **State transitions between blocks are seamless**: By simulating block transitions, the tests validate that the runtime responds correctly to changes in the block number.\n\nTesting pallet interactions within the runtime is critical for ensuring the blockchain behaves as expected under real-world conditions. Writing integration tests allows validation of how pallets function together, preventing issues that might arise when the system is fully assembled.\n\nThis approach provides a comprehensive view of the runtime's functionality, ensuring the blockchain is stable and reliable."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 2, "depth": 3, "title": "Test Initialization", "anchor": "test-initialization", "start_char": 2195, "end_char": 2507, "estimated_token_count": 68, "token_estimator": "heuristic-v1", "text": "### Test Initialization\n\nEach test starts by initializing the runtime environment, typically using the `new_test_ext()` function, which sets up the mock storage and environment.\n\n```rust\n#[test]\nfn test_pallet_functionality() {\n new_test_ext().execute_with(|| {\n // Test logic goes here\n });\n}\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 3, "depth": 3, "title": "Function Call Testing", "anchor": "function-call-testing", "start_char": 2507, "end_char": 3280, "estimated_token_count": 167, "token_estimator": "heuristic-v1", "text": "### Function Call Testing\n\nCall the pallet's extrinsics or functions to simulate user interaction or internal logic. Use the `assert_ok!` macro to check for successful execution and `assert_err!` to verify that errors are correctly handled.\n\n```rust\n#[test]\nfn it_works_for_valid_input() {\n new_test_ext().execute_with(|| {\n // Call an extrinsic or function\n assert_ok!(TemplateModule::some_function(Origin::signed(1), valid_param));\n });\n}\n\n#[test]\nfn it_fails_for_invalid_input() {\n new_test_ext().execute_with(|| {\n // Call an extrinsic with invalid input and expect an error\n assert_err!(\n TemplateModule::some_function(Origin::signed(1), invalid_param),\n Error::::InvalidInput\n );\n });\n}\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 4, "depth": 3, "title": "Storage Testing", "anchor": "storage-testing", "start_char": 3280, "end_char": 4129, "estimated_token_count": 190, "token_estimator": "heuristic-v1", "text": "### Storage Testing\n\nAfter calling a function or extrinsic in your pallet, it's essential to verify that the state changes in the pallet's storage match the expected behavior to ensure data is updated correctly based on the actions taken.\n\nThe following example shows how to test the storage behavior before and after the function call:\n\n```rust\n#[test]\nfn test_storage_update_on_extrinsic_call() {\n new_test_ext().execute_with(|| {\n // Check the initial storage state (before the call)\n assert_eq!(Something::::get(), None);\n\n // Dispatch a signed extrinsic, which modifies storage\n assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42));\n\n // Validate that the storage has been updated as expected (after the call)\n assert_eq!(Something::::get(), Some(42));\n });\n}\n\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 5, "depth": 3, "title": "Event Testing", "anchor": "event-testing", "start_char": 4129, "end_char": 6150, "estimated_token_count": 519, "token_estimator": "heuristic-v1", "text": "### Event Testing\n\nIt's also crucial to test the events that your pallet emits during execution. By default, events generated in a pallet using the [`#generate_deposit`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.generate_deposit.html){target=\\_blank} macro are stored under the system's event storage key (system/events) as [`EventRecord`](https://paritytech.github.io/polkadot-sdk/master/frame_system/struct.EventRecord.html){target=\\_blank} entries. These can be accessed using [`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\\_blank} or verified with specific helper methods provided by the system pallet, such as [`assert_has_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_has_event){target=\\_blank} and [`assert_last_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\\_blank}.\n\nHere's an example of testing events in a mock runtime:\n\n```rust\n#[test]\nfn it_emits_events_on_success() {\n new_test_ext().execute_with(|| {\n // Call an extrinsic or function\n assert_ok!(TemplateModule::some_function(Origin::signed(1), valid_param));\n\n // Verify that the expected event was emitted\n assert!(System::events().iter().any(|record| {\n record.event == Event::TemplateModule(TemplateEvent::SomeEvent)\n }));\n });\n}\n```\n\nSome key considerations are:\n\n- **Block number**: Events are not emitted on the genesis block, so you need to set the block number using [`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\\_blank} to ensure events are triggered.\n- **Converting events**: Use `.into()` when instantiating your pallet's event to convert it into a generic event type, as required by the system's event storage."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 6, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6150, "end_char": 6892, "estimated_token_count": 211, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n- Dive into the full implementation of the [`mock.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/mock.rs){target=\\_blank} and [`test.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/tests.rs){target=\\_blank} files in the [Solochain Template](https://github.com/paritytech/polkadot-sdk/tree/master/templates/solochain){target=_blank}.\n\n
\n\n- Guide __Benchmarking__\n\n ---\n\n Explore methods to measure the performance and execution cost of your pallet.\n\n [:octicons-arrow-right-24: Reference](/develop/parachains/testing/benchmarking)\n\n
"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 23, "end_char": 614, "estimated_token_count": 104, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nUnit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation.\n\nIn this guide, you'll learn how to:\n\n- Structure test modules effectively\n- Test dispatchable functions\n- Verify storage changes\n- Check event emission\n- Test error conditions\n- Use genesis configurations in tests"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 614, "end_char": 1069, "estimated_token_count": 119, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have:\n\n- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide\n- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide\n- The custom counter pallet with mock runtime in `pallets/pallet-custom`\n- Basic understanding of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\\_blank}"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 2, "depth": 2, "title": "Understanding FRAME Testing Tools", "anchor": "understanding-frame-testing-tools", "start_char": 1069, "end_char": 1205, "estimated_token_count": 20, "token_estimator": "heuristic-v1", "text": "## Understanding FRAME Testing Tools\n\nFRAME provides specialized testing macros and utilities that make pallet testing more efficient:"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 3, "depth": 3, "title": "Assertion Macros", "anchor": "assertion-macros", "start_char": 1205, "end_char": 1877, "estimated_token_count": 171, "token_estimator": "heuristic-v1", "text": "### Assertion Macros\n\n- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\\_blank}** - Asserts that a dispatchable call succeeds\n- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\\_blank}** - Asserts that a call fails without changing state (no operation)\n- **`assert_eq!`** - Standard Rust equality assertion\n\n!!!info \"`assert_noop!` Explained\"\n Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 4, "depth": 3, "title": "System Pallet Test Helpers", "anchor": "system-pallet-test-helpers", "start_char": 1877, "end_char": 2873, "estimated_token_count": 276, "token_estimator": "heuristic-v1", "text": "### System Pallet Test Helpers\n\nThe [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\\_blank} pallet provides useful methods for testing:\n\n- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\\_blank}** - Returns all events emitted during the test\n- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\\_blank}** - Asserts the last event matches expectations\n- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\\_blank}** - Sets the current block number\n\n!!!warning \"Events and Block Number\"\n Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 5, "depth": 3, "title": "Origin Types", "anchor": "origin-types", "start_char": 2873, "end_char": 3661, "estimated_token_count": 227, "token_estimator": "heuristic-v1", "text": "### Origin Types\n\n- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\\_blank}** - Root/sudo origin for privileged operations\n- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\\_blank}** - Signed origin from a specific account\n- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\\_blank}** - No origin (typically fails for most operations)\n\nLearn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\\_blank}."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 6, "depth": 2, "title": "Create the Tests Module", "anchor": "create-the-tests-module", "start_char": 3661, "end_char": 4249, "estimated_token_count": 157, "token_estimator": "heuristic-v1", "text": "## Create the Tests Module\n\nCreate a new file for your tests within the pallet directory:\n\n1. Navigate to your pallet directory:\n\n ```bash\n cd pallets/pallet-custom/src\n ```\n\n2. Create a new file named `tests.rs`:\n\n ```bash\n touch tests.rs\n ```\n\n3. Open `src/lib.rs` and add the tests module declaration after the mock module:\n\n ```rust\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n\n #[frame::pallet]\n pub mod pallet {\n // ... existing pallet code\n }\n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 7, "depth": 2, "title": "Set Up the Test Module", "anchor": "set-up-the-test-module", "start_char": 4249, "end_char": 4586, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Set Up the Test Module\n\nOpen `src/tests.rs` and add the basic structure with necessary imports:\n\n```rust\nuse crate::{mock::*, Error, Event};\nuse frame_support::{assert_noop, assert_ok};\n```\n\nThis setup imports:\n- The mock runtime and test utilities from `mock.rs`\n- Your pallet's `Error` and `Event` types\n- FRAME's assertion macros"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 8, "depth": 2, "title": "Write Your First Test", "anchor": "write-your-first-test", "start_char": 4586, "end_char": 4694, "estimated_token_count": 22, "token_estimator": "heuristic-v1", "text": "## Write Your First Test\n\nLet's start with a simple test to verify the increment function works correctly."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 9, "depth": 3, "title": "Test Basic Increment", "anchor": "test-basic-increment", "start_char": 4694, "end_char": 5431, "estimated_token_count": 187, "token_estimator": "heuristic-v1", "text": "### Test Basic Increment\n\n```rust\n#[test]\nfn increment_works() {\n new_test_ext().execute_with(|| {\n // Given: counter starts at 0\n let alice = 1u64;\n \n // When: Alice increments by 5\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5));\n \n // Then: counter value and user interactions are updated\n assert_eq!(crate::CounterValue::::get(), 5);\n assert_eq!(crate::UserInteractions::::get(alice), 1);\n });\n}\n```\n\nRun your first test:\n\n```bash\ncargo test --package pallet-custom increment_works\n```\n\nYou should see:\n\n```\nrunning 1 test\ntest tests::increment_works ... ok\n```\n\n🎉 Congratulations! You've written and run your first pallet test."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 10, "depth": 2, "title": "Test Error Conditions", "anchor": "test-error-conditions", "start_char": 5431, "end_char": 5576, "estimated_token_count": 28, "token_estimator": "heuristic-v1", "text": "## Test Error Conditions\n\nNow let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 11, "depth": 3, "title": "Test Overflow Protection", "anchor": "test-overflow-protection", "start_char": 5576, "end_char": 6352, "estimated_token_count": 177, "token_estimator": "heuristic-v1", "text": "### Test Overflow Protection\n\n```rust\n#[test]\nfn increment_handles_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Given: counter is at maximum u32 value\n let alice = 1u64;\n \n // When: attempting to increment\n // Then: should fail with overflow error and no state change\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(alice), 1),\n Error::::Overflow\n );\n \n // Verify no state changes occurred\n assert_eq!(crate::CounterValue::::get(), u32::MAX);\n assert_eq!(crate::UserInteractions::::get(alice), 0);\n });\n}\n```\n\nTest overflow protection:\n\n```bash\ncargo test --package pallet-custom increment_handles_overflow\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 12, "depth": 3, "title": "Test Underflow Protection", "anchor": "test-underflow-protection", "start_char": 6352, "end_char": 7114, "estimated_token_count": 170, "token_estimator": "heuristic-v1", "text": "### Test Underflow Protection\n\n```rust\n#[test]\nfn decrement_handles_underflow() {\n new_test_ext_with_counter(5).execute_with(|| {\n // Given: counter is at 5\n let alice = 1u64;\n \n // When: attempting to decrement by more than current value\n // Then: should fail with underflow error\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(alice), 10),\n Error::::Underflow\n );\n \n // Verify no state changes occurred\n assert_eq!(crate::CounterValue::::get(), 5);\n assert_eq!(crate::UserInteractions::::get(alice), 0);\n });\n}\n```\n\nVerify underflow protection:\n\n```bash\ncargo test --package pallet-custom decrement_handles_underflow\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 13, "depth": 2, "title": "Test Access Control", "anchor": "test-access-control", "start_char": 7114, "end_char": 7218, "estimated_token_count": 17, "token_estimator": "heuristic-v1", "text": "## Test Access Control\n\nVerify that origin checks work correctly and unauthorized access is prevented."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 14, "depth": 3, "title": "Test Root-Only Access", "anchor": "test-root-only-access", "start_char": 7218, "end_char": 7933, "estimated_token_count": 156, "token_estimator": "heuristic-v1", "text": "### Test Root-Only Access\n\n```rust\n#[test]\nfn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n \n // When: non-root user tries to set counter\n // Then: should fail with BadOrigin\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n sp_runtime::DispatchError::BadOrigin\n );\n \n // But root should succeed\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n}\n```\n\nTest access control:\n\n```bash\ncargo test --package pallet-custom set_counter_value_requires_root\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 15, "depth": 2, "title": "Test Event Emission", "anchor": "test-event-emission", "start_char": 7933, "end_char": 8020, "estimated_token_count": 16, "token_estimator": "heuristic-v1", "text": "## Test Event Emission\n\nVerify that events are emitted correctly with the right data."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 16, "depth": 3, "title": "Test Event Data", "anchor": "test-event-data", "start_char": 8020, "end_char": 8724, "estimated_token_count": 141, "token_estimator": "heuristic-v1", "text": "### Test Event Data\n\n```rust\n#[test]\nfn increment_emits_event() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n \n // Set block number to enable events\n System::set_block_number(1);\n \n // When: increment occurs\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5));\n \n // Then: correct event is emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 5,\n who: alice,\n amount: 5,\n }\n .into(),\n );\n });\n}\n```\n\nRun the event test:\n\n```bash\ncargo test --package pallet-custom increment_emits_event\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 17, "depth": 2, "title": "Test Genesis Configuration", "anchor": "test-genesis-configuration", "start_char": 8724, "end_char": 8807, "estimated_token_count": 12, "token_estimator": "heuristic-v1", "text": "## Test Genesis Configuration\n\nVerify that genesis configuration works correctly."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 18, "depth": 3, "title": "Test Genesis Setup", "anchor": "test-genesis-setup", "start_char": 8807, "end_char": 9421, "estimated_token_count": 152, "token_estimator": "heuristic-v1", "text": "### Test Genesis Setup\n\n```rust\n#[test]\nfn genesis_config_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n // Given: genesis sets counter to 100\n // Then: counter should start at that value\n assert_eq!(crate::CounterValue::::get(), 100);\n \n // And: we can still interact with it\n let alice = 1u64;\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10));\n assert_eq!(crate::CounterValue::::get(), 110);\n });\n}\n```\n\nTest genesis configuration:\n\n```bash\ncargo test --package pallet-custom genesis_config_works\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 19, "depth": 2, "title": "Run All Tests", "anchor": "run-all-tests", "start_char": 9421, "end_char": 12974, "estimated_token_count": 792, "token_estimator": "heuristic-v1", "text": "## Run All Tests\n\nNow run all your tests together:\n\n```bash\ncargo test --package pallet-custom\n```\n\nYou should see all tests passing:\n\n```\nrunning 6 tests\ntest tests::decrement_handles_underflow ... ok\ntest tests::genesis_config_works ... ok\ntest tests::increment_emits_event ... ok\ntest tests::increment_handles_overflow ... ok\ntest tests::increment_works ... ok\ntest tests::set_counter_value_requires_root ... ok\n\ntest result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out\n```\n\n🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns!\n\nThese six tests demonstrate the core patterns you'll use in pallet testing. As you build more complex pallets, you'll apply these same patterns to test additional functionality.\n\n??? code \"Full Test Suite Code\"\n Here's the complete `tests.rs` file for quick reference:\n\n ```rust\n use crate::{mock::*, Error, Event};\n use frame_support::{assert_noop, assert_ok};\n\n #[test]\n fn increment_works() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5));\n assert_eq!(crate::CounterValue::::get(), 5);\n assert_eq!(crate::UserInteractions::::get(alice), 1);\n });\n }\n\n #[test]\n fn increment_handles_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n let alice = 1u64;\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(alice), 1),\n Error::::Overflow\n );\n assert_eq!(crate::CounterValue::::get(), u32::MAX);\n assert_eq!(crate::UserInteractions::::get(alice), 0);\n });\n }\n\n #[test]\n fn decrement_handles_underflow() {\n new_test_ext_with_counter(5).execute_with(|| {\n let alice = 1u64;\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(alice), 10),\n Error::::Underflow\n );\n assert_eq!(crate::CounterValue::::get(), 5);\n assert_eq!(crate::UserInteractions::::get(alice), 0);\n });\n }\n\n #[test]\n fn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n sp_runtime::DispatchError::BadOrigin\n );\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n }\n\n #[test]\n fn increment_emits_event() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n System::set_block_number(1);\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5));\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 5,\n who: alice,\n amount: 5,\n }\n .into(),\n );\n });\n }\n\n #[test]\n fn genesis_config_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n assert_eq!(crate::CounterValue::::get(), 100);\n let alice = 1u64;\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10));\n assert_eq!(crate::CounterValue::::get(), 110);\n });\n }\n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 12974, "end_char": 13324, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Add Your Custom Pallet to the Runtime__\n\n ---\n\n Your pallet is tested and ready! Learn how to integrate it into your runtime.\n\n [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)\n\n
"} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 26, "end_char": 754, "estimated_token_count": 146, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nA blockchain runtime is more than just a fixed set of rules—it's a dynamic foundation that you can shape to match your specific needs. With Polkadot SDK's [FRAME (Framework for Runtime Aggregation of Modularized Entities)](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\\_blank}, customizing your runtime is straightforward and modular. Instead of building everything from scratch, you combine pre-built pallets with your own custom logic to create a runtime suited to your blockchain's purpose.\n\nThis overview explains how runtime customization works, introduces the building blocks you'll use, and guides you through the key patterns for extending your runtime."} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 1, "depth": 2, "title": "Understanding Your Runtime", "anchor": "understanding-your-runtime", "start_char": 754, "end_char": 1532, "estimated_token_count": 158, "token_estimator": "heuristic-v1", "text": "## Understanding Your Runtime\n\nThe runtime is the core logic of your blockchain—it processes transactions, manages state, and enforces the rules that govern your network. When a transaction arrives at your blockchain, the [`frame_executive`](https://paritytech.github.io/polkadot-sdk/master/frame_executive/index.html){target=\\_blank} pallet receives it and routes it to the appropriate pallet for execution.\n\nThink of your runtime as a collection of specialized modules, each handling a different aspect of your blockchain. Need token balances? Use the Balances pallet. Want governance? Add the Governance pallet. Need something custom? Create your own pallet. By mixing and matching these modules, you build a runtime that's efficient, secure, and tailored to your use case."} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 2, "depth": 2, "title": "Runtime Architecture", "anchor": "runtime-architecture", "start_char": 1532, "end_char": 2084, "estimated_token_count": 121, "token_estimator": "heuristic-v1", "text": "## Runtime Architecture\n\nThe following diagram shows how FRAME components work together to form your runtime:\n\n![](/images/parachains/customize-runtime/index/frame-overview-01.webp)\n\nThe main components are:\n\n- **`frame_executive`**: Routes all incoming transactions to the correct pallet for execution.\n- **Pallets**: Domain-specific modules that implement your blockchain's features and business logic.\n- **`frame_system`**: Provides core runtime primitives and storage.\n- **`frame_support`**: Utilities and macros that simplify pallet development."} diff --git a/llms.txt b/llms.txt index ca4111201..eb879f057 100644 --- a/llms.txt +++ b/llms.txt @@ -103,7 +103,7 @@ Docs: Parachains - [Benchmarking FRAME Pallets](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-benchmark-pallet.md): Learn how to use FRAME's benchmarking framework to measure extrinsic execution costs and provide accurate weights for on-chain computations. - [Make a Custom Pallet](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-create-a-pallet.md): Learn how to create custom pallets using FRAME, allowing for flexible, modular, and scalable blockchain development. Follow the step-by-step guide. - [Mock Runtime for Pallet Testing](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-mock-runtime.md): Learn to create a mock environment in the Polkadot SDK for testing intra-pallet functionality and inter-pallet interactions seamlessly. -- [Pallet Testing](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md): Learn how to efficiently test pallets in the Polkadot SDK, ensuring the reliability and security of your pallets operations. +- [Pallet Unit Testing](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md): Learn how to write comprehensive unit tests for your custom pallets using mock runtimes, ensuring reliability and correctness before deployment. - [Overview of FRAME](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime.md): Learn how Polkadot SDK’s FRAME framework simplifies blockchain development with modular pallets and support libraries for efficient runtime design. - [Get Started with Parachain Development](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-get-started.md): Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. - [Opening HRMP Channels Between Parachains](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-channels-between-parachains.md): Learn how to open HRMP channels between parachains on Polkadot. Discover the step-by-step process for establishing uni- and bidirectional communication. diff --git a/parachains/customize-runtime/pallet-development/pallet-testing.md b/parachains/customize-runtime/pallet-development/pallet-testing.md index 6dc75eb5e..908c5b2e0 100644 --- a/parachains/customize-runtime/pallet-development/pallet-testing.md +++ b/parachains/customize-runtime/pallet-development/pallet-testing.md @@ -1,86 +1,431 @@ --- -title: Pallet Testing -description: Learn how to efficiently test pallets in the Polkadot SDK, ensuring the reliability and security of your pallets operations. +title: Pallet Unit Testing +description: Learn how to write comprehensive unit tests for your custom pallets using mock runtimes, ensuring reliability and correctness before deployment. categories: Parachains --- -# Pallet Testing +# Pallet Unit Testing ## Introduction -Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. The Polkadot SDK offers a set of APIs to create a test environment to simulate runtime and mock transaction execution for extrinsics and queries. +Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation. -To begin unit testing, you must first set up a mock runtime that simulates blockchain behavior, incorporating the necessary pallets. For a deeper understanding, consult the [Mock Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/){target=\_blank} guide. +In this guide, you'll learn how to: -## Writing Unit Tests +- Structure test modules effectively +- Test dispatchable functions +- Verify storage changes +- Check event emission +- Test error conditions +- Use genesis configurations in tests -Once the mock runtime is in place, the next step is to write unit tests that evaluate the functionality of your pallet. Unit tests allow you to test specific pallet features in isolation, ensuring that each function behaves correctly under various conditions. These tests typically reside in your pallet module's `test.rs` file. +## Prerequisites -Unit tests in the Polkadot SDK use the Rust testing framework, and the mock runtime you've defined earlier will serve as the test environment. Below are the typical steps involved in writing unit tests for a pallet. +Before you begin, ensure you have: -The tests confirm that: +- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide +- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide +- The custom counter pallet with mock runtime in `pallets/pallet-custom` +- Basic understanding of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\_blank} -- **Pallets initialize correctly**: At the start of each test, the system should initialize with block number 0, and the pallets should be in their default states. -- **Pallets modify each other's state**: The second test shows how one pallet can trigger changes in another pallet's internal state, confirming proper cross-pallet interactions. -- **State transitions between blocks are seamless**: By simulating block transitions, the tests validate that the runtime responds correctly to changes in the block number. +## Understanding FRAME Testing Tools -Testing pallet interactions within the runtime is critical for ensuring the blockchain behaves as expected under real-world conditions. Writing integration tests allows validation of how pallets function together, preventing issues that might arise when the system is fully assembled. +FRAME provides specialized testing macros and utilities that make pallet testing more efficient: -This approach provides a comprehensive view of the runtime's functionality, ensuring the blockchain is stable and reliable. +### Assertion Macros -### Test Initialization +- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds +- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation) +- **`assert_eq!`** - Standard Rust equality assertion -Each test starts by initializing the runtime environment, typically using the `new_test_ext()` function, which sets up the mock storage and environment. +!!!info "`assert_noop!` Explained" + Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified. + +### System Pallet Test Helpers + +The [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\_blank} pallet provides useful methods for testing: + +- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test +- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations +- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number + +!!!warning "Events and Block Number" + Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`. + +### Origin Types + +- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations +- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account +- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations) + +Learn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\_blank}. + +## Create the Tests Module + +Create a new file for your tests within the pallet directory: + +1. Navigate to your pallet directory: + + ```bash + cd pallets/pallet-custom/src + ``` + +2. Create a new file named `tests.rs`: + + ```bash + touch tests.rs + ``` + +3. Open `src/lib.rs` and add the tests module declaration after the mock module: + + ```rust + #![cfg_attr(not(feature = "std"), no_std)] + + pub use pallet::*; + + #[cfg(test)] + mod mock; + + #[cfg(test)] + mod tests; + + #[frame::pallet] + pub mod pallet { + // ... existing pallet code + } + ``` + +## Set Up the Test Module + +Open `src/tests.rs` and add the basic structure with necessary imports: ```rust ---8<-- 'code/parachains/customize-runtime/pallet-development/pallet-testing/test-initialization.rs' +use crate::{mock::*, Error, Event}; +use frame_support::{assert_noop, assert_ok}; ``` -### Function Call Testing +This setup imports: +- The mock runtime and test utilities from `mock.rs` +- Your pallet's `Error` and `Event` types +- FRAME's assertion macros + +## Write Your First Test + +Let's start with a simple test to verify the increment function works correctly. -Call the pallet's extrinsics or functions to simulate user interaction or internal logic. Use the `assert_ok!` macro to check for successful execution and `assert_err!` to verify that errors are correctly handled. +### Test Basic Increment ```rust ---8<-- 'code/parachains/customize-runtime/pallet-development/pallet-testing/function-call-testing.rs' +#[test] +fn increment_works() { + new_test_ext().execute_with(|| { + // Given: counter starts at 0 + let alice = 1u64; + + // When: Alice increments by 5 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + // Then: counter value and user interactions are updated + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 1); + }); +} ``` -### Storage Testing +Run your first test: -After calling a function or extrinsic in your pallet, it's essential to verify that the state changes in the pallet's storage match the expected behavior to ensure data is updated correctly based on the actions taken. +```bash +cargo test --package pallet-custom increment_works +``` + +You should see: -The following example shows how to test the storage behavior before and after the function call: +``` +running 1 test +test tests::increment_works ... ok +``` + +🎉 Congratulations! You've written and run your first pallet test. + +## Test Error Conditions + +Now let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely. + +### Test Overflow Protection ```rust ---8<-- 'code/parachains/customize-runtime/pallet-development/pallet-testing/storage-testing.rs' +#[test] +fn increment_handles_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + // Given: counter is at maximum u32 value + let alice = 1u64; + + // When: attempting to increment + // Then: should fail with overflow error and no state change + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + Error::::Overflow + ); + + // Verify no state changes occurred + assert_eq!(crate::CounterValue::::get(), u32::MAX); + assert_eq!(crate::UserInteractions::::get(alice), 0); + }); +} ``` -### Event Testing +Test overflow protection: -It's also crucial to test the events that your pallet emits during execution. By default, events generated in a pallet using the [`#generate_deposit`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.generate_deposit.html){target=\_blank} macro are stored under the system's event storage key (system/events) as [`EventRecord`](https://paritytech.github.io/polkadot-sdk/master/frame_system/struct.EventRecord.html){target=\_blank} entries. These can be accessed using [`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank} or verified with specific helper methods provided by the system pallet, such as [`assert_has_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_has_event){target=\_blank} and [`assert_last_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}. +```bash +cargo test --package pallet-custom increment_handles_overflow +``` -Here's an example of testing events in a mock runtime: +### Test Underflow Protection ```rust ---8<-- 'code/parachains/customize-runtime/pallet-development/pallet-testing/event-testing.rs' +#[test] +fn decrement_handles_underflow() { + new_test_ext_with_counter(5).execute_with(|| { + // Given: counter is at 5 + let alice = 1u64; + + // When: attempting to decrement by more than current value + // Then: should fail with underflow error + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + Error::::Underflow + ); + + // Verify no state changes occurred + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 0); + }); +} ``` -Some key considerations are: +Verify underflow protection: + +```bash +cargo test --package pallet-custom decrement_handles_underflow +``` -- **Block number**: Events are not emitted on the genesis block, so you need to set the block number using [`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank} to ensure events are triggered. -- **Converting events**: Use `.into()` when instantiating your pallet's event to convert it into a generic event type, as required by the system's event storage. +## Test Access Control -## Where to Go Next +Verify that origin checks work correctly and unauthorized access is prevented. -- Dive into the full implementation of the [`mock.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/mock.rs){target=\_blank} and [`test.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/tests.rs){target=\_blank} files in the [Solochain Template](https://github.com/paritytech/polkadot-sdk/tree/master/templates/solochain){target=_blank}. +### Test Root-Only Access + +```rust +#[test] +fn set_counter_value_requires_root() { + new_test_ext().execute_with(|| { + let alice = 1u64; + + // When: non-root user tries to set counter + // Then: should fail with BadOrigin + assert_noop!( + CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), + sp_runtime::DispatchError::BadOrigin + ); + + // But root should succeed + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + }); +} +``` + +Test access control: + +```bash +cargo test --package pallet-custom set_counter_value_requires_root +``` + +## Test Event Emission + +Verify that events are emitted correctly with the right data. + +### Test Event Data + +```rust +#[test] +fn increment_emits_event() { + new_test_ext().execute_with(|| { + let alice = 1u64; + + // Set block number to enable events + System::set_block_number(1); + + // When: increment occurs + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + // Then: correct event is emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 5, + who: alice, + amount: 5, + } + .into(), + ); + }); +} +``` + +Run the event test: + +```bash +cargo test --package pallet-custom increment_emits_event +``` + +## Test Genesis Configuration + +Verify that genesis configuration works correctly. + +### Test Genesis Setup + +```rust +#[test] +fn genesis_config_works() { + new_test_ext_with_counter(100).execute_with(|| { + // Given: genesis sets counter to 100 + // Then: counter should start at that value + assert_eq!(crate::CounterValue::::get(), 100); + + // And: we can still interact with it + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); + assert_eq!(crate::CounterValue::::get(), 110); + }); +} +``` + +Test genesis configuration: + +```bash +cargo test --package pallet-custom genesis_config_works +``` + +## Run All Tests + +Now run all your tests together: + +```bash +cargo test --package pallet-custom +``` + +You should see all tests passing: + +``` +running 6 tests +test tests::decrement_handles_underflow ... ok +test tests::genesis_config_works ... ok +test tests::increment_emits_event ... ok +test tests::increment_handles_overflow ... ok +test tests::increment_works ... ok +test tests::set_counter_value_requires_root ... ok + +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +``` + +🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! + +These six tests demonstrate the core patterns you'll use in pallet testing. As you build more complex pallets, you'll apply these same patterns to test additional functionality. + +??? code "Full Test Suite Code" + Here's the complete `tests.rs` file for quick reference: + + ```rust + use crate::{mock::*, Error, Event}; + use frame_support::{assert_noop, assert_ok}; + + #[test] + fn increment_works() { + new_test_ext().execute_with(|| { + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 1); + }); + } + + #[test] + fn increment_handles_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + Error::::Overflow + ); + assert_eq!(crate::CounterValue::::get(), u32::MAX); + assert_eq!(crate::UserInteractions::::get(alice), 0); + }); + } + + #[test] + fn decrement_handles_underflow() { + new_test_ext_with_counter(5).execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + Error::::Underflow + ); + assert_eq!(crate::CounterValue::::get(), 5); + assert_eq!(crate::UserInteractions::::get(alice), 0); + }); + } + + #[test] + fn set_counter_value_requires_root() { + new_test_ext().execute_with(|| { + let alice = 1u64; + assert_noop!( + CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), + sp_runtime::DispatchError::BadOrigin + ); + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + }); + } + + #[test] + fn increment_emits_event() { + new_test_ext().execute_with(|| { + let alice = 1u64; + System::set_block_number(1); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + System::assert_last_event( + Event::CounterIncremented { + new_value: 5, + who: alice, + amount: 5, + } + .into(), + ); + }); + } + + #[test] + fn genesis_config_works() { + new_test_ext_with_counter(100).execute_with(|| { + assert_eq!(crate::CounterValue::::get(), 100); + let alice = 1u64; + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); + assert_eq!(crate::CounterValue::::get(), 110); + }); + } + ``` + +## Where to Go Next
-- Guide __Benchmarking__ +- Guide __Add Your Custom Pallet to the Runtime__ --- - Explore methods to measure the performance and execution cost of your pallet. + Your pallet is tested and ready! Learn how to integrate it into your runtime. - [:octicons-arrow-right-24: Reference](/develop/parachains/testing/benchmarking) + [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/) -
\ No newline at end of file + From 0dc3b4ac1b0febce993566a4862bad6c64c2549b Mon Sep 17 00:00:00 2001 From: Bruno Galvao Date: Mon, 3 Nov 2025 13:42:21 +0700 Subject: [PATCH 02/10] add pallet testing --- .ai/categories/parachains.md | 380 +++++++++++++----- ...ntime-pallet-development-pallet-testing.md | 380 +++++++++++++----- .ai/site-index.json | 8 +- llms-full.jsonl | 28 +- .../pallet-development/pallet-testing.md | 380 +++++++++++++----- 5 files changed, 825 insertions(+), 351 deletions(-) diff --git a/.ai/categories/parachains.md b/.ai/categories/parachains.md index 4164ba551..4065583a4 100644 --- a/.ai/categories/parachains.md +++ b/.ai/categories/parachains.md @@ -12625,13 +12625,15 @@ Open `src/tests.rs` and add the basic structure with necessary imports: ```rust use crate::{mock::*, Error, Event}; -use frame_support::{assert_noop, assert_ok}; +use frame::deps::frame_support::{assert_noop, assert_ok}; +use frame::deps::sp_runtime::DispatchError; ``` This setup imports: - The mock runtime and test utilities from `mock.rs` - Your pallet's `Error` and `Event` types -- FRAME's assertion macros +- FRAME's assertion macros via `frame::deps` +- `DispatchError` for testing origin checks ## Write Your First Test @@ -12643,15 +12645,27 @@ Let's start with a simple test to verify the increment function works correctly. #[test] fn increment_works() { new_test_ext().execute_with(|| { - // Given: counter starts at 0 - let alice = 1u64; - - // When: Alice increments by 5 - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - - // Then: counter value and user interactions are updated - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 1); + // Set block number to 1 so events are registered + System::set_block_number(1); + + let account = 1u64; + + // Increment by 50 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50)); + assert_eq!(crate::CounterValue::::get(), 50); + + // Check event was emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 50, + who: account, + amount: 50, + } + .into(), + ); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); }); } ``` @@ -12679,21 +12693,13 @@ Now let's test that our pallet correctly handles errors. Error testing is crucia ```rust #[test] -fn increment_handles_overflow() { +fn increment_fails_on_overflow() { new_test_ext_with_counter(u32::MAX).execute_with(|| { - // Given: counter is at maximum u32 value - let alice = 1u64; - - // When: attempting to increment - // Then: should fail with overflow error and no state change + // Attempt to increment when at max u32 should fail assert_noop!( - CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + CustomPallet::increment(RuntimeOrigin::signed(1), 1), Error::::Overflow ); - - // Verify no state changes occurred - assert_eq!(crate::CounterValue::::get(), u32::MAX); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } ``` @@ -12701,28 +12707,20 @@ fn increment_handles_overflow() { Test overflow protection: ```bash -cargo test --package pallet-custom increment_handles_overflow +cargo test --package pallet-custom increment_fails_on_overflow ``` ### Test Underflow Protection ```rust #[test] -fn decrement_handles_underflow() { - new_test_ext_with_counter(5).execute_with(|| { - // Given: counter is at 5 - let alice = 1u64; - - // When: attempting to decrement by more than current value - // Then: should fail with underflow error +fn decrement_fails_on_underflow() { + new_test_ext_with_counter(10).execute_with(|| { + // Attempt to decrement below zero should fail assert_noop!( - CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + CustomPallet::decrement(RuntimeOrigin::signed(1), 11), Error::::Underflow ); - - // Verify no state changes occurred - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } ``` @@ -12730,7 +12728,7 @@ fn decrement_handles_underflow() { Verify underflow protection: ```bash -cargo test --package pallet-custom decrement_handles_underflow +cargo test --package pallet-custom decrement_fails_on_underflow ``` ## Test Access Control @@ -12744,14 +12742,14 @@ Verify that origin checks work correctly and unauthorized access is prevented. fn set_counter_value_requires_root() { new_test_ext().execute_with(|| { let alice = 1u64; - + // When: non-root user tries to set counter // Then: should fail with BadOrigin assert_noop!( CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), - sp_runtime::DispatchError::BadOrigin + DispatchError::BadOrigin ); - + // But root should succeed assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); assert_eq!(crate::CounterValue::::get(), 100); @@ -12771,27 +12769,26 @@ Verify that events are emitted correctly with the right data. ### Test Event Data +The `increment_works` test (shown earlier) already demonstrates event testing by: +1. Setting the block number to 1 to enable event emission +2. Calling the dispatchable function +3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data + +This pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function: + ```rust #[test] -fn increment_emits_event() { +fn set_counter_value_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - - // Set block number to enable events + // Set block number to 1 so events are registered System::set_block_number(1); - - // When: increment occurs - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - - // Then: correct event is emitted - System::assert_last_event( - Event::CounterIncremented { - new_value: 5, - who: alice, - amount: 5, - } - .into(), - ); + + // Set counter to 100 + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + + // Check event was emitted + System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into()); }); } ``` @@ -12799,7 +12796,7 @@ fn increment_emits_event() { Run the event test: ```bash -cargo test --package pallet-custom increment_emits_event +cargo test --package pallet-custom set_counter_value_works ``` ## Test Genesis Configuration @@ -12811,15 +12808,13 @@ Verify that genesis configuration works correctly. ```rust #[test] fn genesis_config_works() { - new_test_ext_with_counter(100).execute_with(|| { - // Given: genesis sets counter to 100 - // Then: counter should start at that value - assert_eq!(crate::CounterValue::::get(), 100); - - // And: we can still interact with it - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); - assert_eq!(crate::CounterValue::::get(), 110); + new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| { + // Check initial counter value + assert_eq!(crate::CounterValue::::get(), 42); + + // Check initial user interactions + assert_eq!(crate::UserInteractions::::get(1), 5); + assert_eq!(crate::UserInteractions::::get(2), 10); }); } ``` @@ -12841,101 +12836,264 @@ cargo test --package pallet-custom You should see all tests passing: ``` -running 6 tests -test tests::decrement_handles_underflow ... ok +running 15 tests +test mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok +test mock::test_genesis_config_builds ... ok +test tests::decrement_fails_on_underflow ... ok +test tests::decrement_tracks_multiple_interactions ... ok +test tests::decrement_works ... ok +test tests::different_users_tracked_separately ... ok test tests::genesis_config_works ... ok -test tests::increment_emits_event ... ok -test tests::increment_handles_overflow ... ok +test tests::increment_fails_on_overflow ... ok +test tests::increment_respects_max_value ... ok +test tests::increment_tracks_multiple_interactions ... ok test tests::increment_works ... ok +test tests::mixed_increment_and_decrement_works ... ok test tests::set_counter_value_requires_root ... ok +test tests::set_counter_value_respects_max_value ... ok +test tests::set_counter_value_works ... ok -test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ``` +!!!note "Mock Runtime Tests" + You'll notice 2 additional tests from the `mock` module: + + - `mock::__construct_runtime_integrity_test::runtime_integrity_tests` - Auto-generated test that validates runtime construction + - `mock::test_genesis_config_builds` - Validates that genesis configuration builds correctly + + These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid. + 🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! -These six tests demonstrate the core patterns you'll use in pallet testing. As you build more complex pallets, you'll apply these same patterns to test additional functionality. +These tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality. ??? code "Full Test Suite Code" Here's the complete `tests.rs` file for quick reference: ```rust use crate::{mock::*, Error, Event}; - use frame_support::{assert_noop, assert_ok}; + use frame::deps::frame_support::{assert_noop, assert_ok}; + use frame::deps::sp_runtime::DispatchError; #[test] - fn increment_works() { + fn set_counter_value_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 1); + // Set block number to 1 so events are registered + System::set_block_number(1); + + // Set counter to 100 + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + + // Check event was emitted + System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into()); }); } #[test] - fn increment_handles_overflow() { - new_test_ext_with_counter(u32::MAX).execute_with(|| { - let alice = 1u64; + fn set_counter_value_requires_root() { + new_test_ext().execute_with(|| { + // Attempt to set counter with non-root origin should fail assert_noop!( - CustomPallet::increment(RuntimeOrigin::signed(alice), 1), - Error::::Overflow + CustomPallet::set_counter_value(RuntimeOrigin::signed(1), 100), + DispatchError::BadOrigin ); - assert_eq!(crate::CounterValue::::get(), u32::MAX); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } #[test] - fn decrement_handles_underflow() { - new_test_ext_with_counter(5).execute_with(|| { - let alice = 1u64; + fn set_counter_value_respects_max_value() { + new_test_ext().execute_with(|| { + // Attempt to set counter above max value (1000) should fail assert_noop!( - CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), - Error::::Underflow + CustomPallet::set_counter_value(RuntimeOrigin::root(), 1001), + Error::::CounterMaxValueExceeded ); - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 0); + + // Setting to exactly max value should work + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 1000)); + assert_eq!(crate::CounterValue::::get(), 1000); }); } #[test] - fn set_counter_value_requires_root() { + fn increment_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - assert_noop!( - CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), - sp_runtime::DispatchError::BadOrigin + // Set block number to 1 so events are registered + System::set_block_number(1); + + let account = 1u64; + + // Increment by 50 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50)); + assert_eq!(crate::CounterValue::::get(), 50); + + // Check event was emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 50, + who: account, + amount: 50, + } + .into(), ); - assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); - assert_eq!(crate::CounterValue::::get(), 100); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); }); } #[test] - fn increment_emits_event() { + fn increment_tracks_multiple_interactions() { new_test_ext().execute_with(|| { - let alice = 1u64; + let account = 1u64; + + // Increment multiple times + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 20)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 30)); + + // Check counter value + assert_eq!(crate::CounterValue::::get(), 60); + + // Check user interactions were tracked (should be 3) + assert_eq!(crate::UserInteractions::::get(account), 3); + }); + } + + #[test] + fn increment_fails_on_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + // Attempt to increment when at max u32 should fail + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(1), 1), + Error::::Overflow + ); + }); + } + + #[test] + fn increment_respects_max_value() { + new_test_ext_with_counter(950).execute_with(|| { + // Incrementing past max value (1000) should fail + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(1), 51), + Error::::CounterMaxValueExceeded + ); + + // Incrementing to exactly max value should work + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(1), 50)); + assert_eq!(crate::CounterValue::::get(), 1000); + }); + } + + #[test] + fn decrement_works() { + new_test_ext_with_counter(100).execute_with(|| { + // Set block number to 1 so events are registered System::set_block_number(1); - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + let account = 2u64; + + // Decrement by 30 + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 30)); + assert_eq!(crate::CounterValue::::get(), 70); + + // Check event was emitted System::assert_last_event( - Event::CounterIncremented { - new_value: 5, - who: alice, - amount: 5, + Event::CounterDecremented { + new_value: 70, + who: account, + amount: 30, } .into(), ); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); + }); + } + + #[test] + fn decrement_fails_on_underflow() { + new_test_ext_with_counter(10).execute_with(|| { + // Attempt to decrement below zero should fail + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(1), 11), + Error::::Underflow + ); }); } #[test] - fn genesis_config_works() { + fn decrement_tracks_multiple_interactions() { new_test_ext_with_counter(100).execute_with(|| { - assert_eq!(crate::CounterValue::::get(), 100); - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); - assert_eq!(crate::CounterValue::::get(), 110); + let account = 3u64; + + // Decrement multiple times + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 10)); + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 20)); + + // Check counter value + assert_eq!(crate::CounterValue::::get(), 70); + + // Check user interactions were tracked (should be 2) + assert_eq!(crate::UserInteractions::::get(account), 2); + }); + } + + #[test] + fn mixed_increment_and_decrement_works() { + new_test_ext_with_counter(50).execute_with(|| { + let account = 4u64; + + // Mix of increment and decrement + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 25)); + assert_eq!(crate::CounterValue::::get(), 75); + + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 15)); + assert_eq!(crate::CounterValue::::get(), 60); + + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10)); + assert_eq!(crate::CounterValue::::get(), 70); + + // Check user interactions were tracked (should be 3) + assert_eq!(crate::UserInteractions::::get(account), 3); + }); + } + + #[test] + fn different_users_tracked_separately() { + new_test_ext().execute_with(|| { + let account1 = 1u64; + let account2 = 2u64; + + // User 1 increments + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10)); + + // User 2 decrements + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account2), 5)); + + // Check counter value (10 + 10 - 5 = 15) + assert_eq!(crate::CounterValue::::get(), 15); + + // Check user interactions are tracked separately + assert_eq!(crate::UserInteractions::::get(account1), 2); + assert_eq!(crate::UserInteractions::::get(account2), 1); + }); + } + + #[test] + fn genesis_config_works() { + new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| { + // Check initial counter value + assert_eq!(crate::CounterValue::::get(), 42); + + // Check initial user interactions + assert_eq!(crate::UserInteractions::::get(1), 5); + assert_eq!(crate::UserInteractions::::get(2), 10); }); } ``` diff --git a/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md b/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md index 95dc53989..ecbf5ebc1 100644 --- a/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md +++ b/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md @@ -102,13 +102,15 @@ Open `src/tests.rs` and add the basic structure with necessary imports: ```rust use crate::{mock::*, Error, Event}; -use frame_support::{assert_noop, assert_ok}; +use frame::deps::frame_support::{assert_noop, assert_ok}; +use frame::deps::sp_runtime::DispatchError; ``` This setup imports: - The mock runtime and test utilities from `mock.rs` - Your pallet's `Error` and `Event` types -- FRAME's assertion macros +- FRAME's assertion macros via `frame::deps` +- `DispatchError` for testing origin checks ## Write Your First Test @@ -120,15 +122,27 @@ Let's start with a simple test to verify the increment function works correctly. #[test] fn increment_works() { new_test_ext().execute_with(|| { - // Given: counter starts at 0 - let alice = 1u64; - - // When: Alice increments by 5 - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - - // Then: counter value and user interactions are updated - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 1); + // Set block number to 1 so events are registered + System::set_block_number(1); + + let account = 1u64; + + // Increment by 50 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50)); + assert_eq!(crate::CounterValue::::get(), 50); + + // Check event was emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 50, + who: account, + amount: 50, + } + .into(), + ); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); }); } ``` @@ -156,21 +170,13 @@ Now let's test that our pallet correctly handles errors. Error testing is crucia ```rust #[test] -fn increment_handles_overflow() { +fn increment_fails_on_overflow() { new_test_ext_with_counter(u32::MAX).execute_with(|| { - // Given: counter is at maximum u32 value - let alice = 1u64; - - // When: attempting to increment - // Then: should fail with overflow error and no state change + // Attempt to increment when at max u32 should fail assert_noop!( - CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + CustomPallet::increment(RuntimeOrigin::signed(1), 1), Error::::Overflow ); - - // Verify no state changes occurred - assert_eq!(crate::CounterValue::::get(), u32::MAX); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } ``` @@ -178,28 +184,20 @@ fn increment_handles_overflow() { Test overflow protection: ```bash -cargo test --package pallet-custom increment_handles_overflow +cargo test --package pallet-custom increment_fails_on_overflow ``` ### Test Underflow Protection ```rust #[test] -fn decrement_handles_underflow() { - new_test_ext_with_counter(5).execute_with(|| { - // Given: counter is at 5 - let alice = 1u64; - - // When: attempting to decrement by more than current value - // Then: should fail with underflow error +fn decrement_fails_on_underflow() { + new_test_ext_with_counter(10).execute_with(|| { + // Attempt to decrement below zero should fail assert_noop!( - CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + CustomPallet::decrement(RuntimeOrigin::signed(1), 11), Error::::Underflow ); - - // Verify no state changes occurred - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } ``` @@ -207,7 +205,7 @@ fn decrement_handles_underflow() { Verify underflow protection: ```bash -cargo test --package pallet-custom decrement_handles_underflow +cargo test --package pallet-custom decrement_fails_on_underflow ``` ## Test Access Control @@ -221,14 +219,14 @@ Verify that origin checks work correctly and unauthorized access is prevented. fn set_counter_value_requires_root() { new_test_ext().execute_with(|| { let alice = 1u64; - + // When: non-root user tries to set counter // Then: should fail with BadOrigin assert_noop!( CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), - sp_runtime::DispatchError::BadOrigin + DispatchError::BadOrigin ); - + // But root should succeed assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); assert_eq!(crate::CounterValue::::get(), 100); @@ -248,27 +246,26 @@ Verify that events are emitted correctly with the right data. ### Test Event Data +The `increment_works` test (shown earlier) already demonstrates event testing by: +1. Setting the block number to 1 to enable event emission +2. Calling the dispatchable function +3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data + +This pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function: + ```rust #[test] -fn increment_emits_event() { +fn set_counter_value_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - - // Set block number to enable events + // Set block number to 1 so events are registered System::set_block_number(1); - - // When: increment occurs - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - - // Then: correct event is emitted - System::assert_last_event( - Event::CounterIncremented { - new_value: 5, - who: alice, - amount: 5, - } - .into(), - ); + + // Set counter to 100 + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + + // Check event was emitted + System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into()); }); } ``` @@ -276,7 +273,7 @@ fn increment_emits_event() { Run the event test: ```bash -cargo test --package pallet-custom increment_emits_event +cargo test --package pallet-custom set_counter_value_works ``` ## Test Genesis Configuration @@ -288,15 +285,13 @@ Verify that genesis configuration works correctly. ```rust #[test] fn genesis_config_works() { - new_test_ext_with_counter(100).execute_with(|| { - // Given: genesis sets counter to 100 - // Then: counter should start at that value - assert_eq!(crate::CounterValue::::get(), 100); - - // And: we can still interact with it - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); - assert_eq!(crate::CounterValue::::get(), 110); + new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| { + // Check initial counter value + assert_eq!(crate::CounterValue::::get(), 42); + + // Check initial user interactions + assert_eq!(crate::UserInteractions::::get(1), 5); + assert_eq!(crate::UserInteractions::::get(2), 10); }); } ``` @@ -318,101 +313,264 @@ cargo test --package pallet-custom You should see all tests passing: ``` -running 6 tests -test tests::decrement_handles_underflow ... ok +running 15 tests +test mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok +test mock::test_genesis_config_builds ... ok +test tests::decrement_fails_on_underflow ... ok +test tests::decrement_tracks_multiple_interactions ... ok +test tests::decrement_works ... ok +test tests::different_users_tracked_separately ... ok test tests::genesis_config_works ... ok -test tests::increment_emits_event ... ok -test tests::increment_handles_overflow ... ok +test tests::increment_fails_on_overflow ... ok +test tests::increment_respects_max_value ... ok +test tests::increment_tracks_multiple_interactions ... ok test tests::increment_works ... ok +test tests::mixed_increment_and_decrement_works ... ok test tests::set_counter_value_requires_root ... ok +test tests::set_counter_value_respects_max_value ... ok +test tests::set_counter_value_works ... ok -test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ``` +!!!note "Mock Runtime Tests" + You'll notice 2 additional tests from the `mock` module: + + - `mock::__construct_runtime_integrity_test::runtime_integrity_tests` - Auto-generated test that validates runtime construction + - `mock::test_genesis_config_builds` - Validates that genesis configuration builds correctly + + These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid. + 🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! -These six tests demonstrate the core patterns you'll use in pallet testing. As you build more complex pallets, you'll apply these same patterns to test additional functionality. +These tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality. ??? code "Full Test Suite Code" Here's the complete `tests.rs` file for quick reference: ```rust use crate::{mock::*, Error, Event}; - use frame_support::{assert_noop, assert_ok}; + use frame::deps::frame_support::{assert_noop, assert_ok}; + use frame::deps::sp_runtime::DispatchError; #[test] - fn increment_works() { + fn set_counter_value_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 1); + // Set block number to 1 so events are registered + System::set_block_number(1); + + // Set counter to 100 + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + + // Check event was emitted + System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into()); }); } #[test] - fn increment_handles_overflow() { - new_test_ext_with_counter(u32::MAX).execute_with(|| { - let alice = 1u64; + fn set_counter_value_requires_root() { + new_test_ext().execute_with(|| { + // Attempt to set counter with non-root origin should fail assert_noop!( - CustomPallet::increment(RuntimeOrigin::signed(alice), 1), - Error::::Overflow + CustomPallet::set_counter_value(RuntimeOrigin::signed(1), 100), + DispatchError::BadOrigin ); - assert_eq!(crate::CounterValue::::get(), u32::MAX); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } #[test] - fn decrement_handles_underflow() { - new_test_ext_with_counter(5).execute_with(|| { - let alice = 1u64; + fn set_counter_value_respects_max_value() { + new_test_ext().execute_with(|| { + // Attempt to set counter above max value (1000) should fail assert_noop!( - CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), - Error::::Underflow + CustomPallet::set_counter_value(RuntimeOrigin::root(), 1001), + Error::::CounterMaxValueExceeded ); - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 0); + + // Setting to exactly max value should work + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 1000)); + assert_eq!(crate::CounterValue::::get(), 1000); }); } #[test] - fn set_counter_value_requires_root() { + fn increment_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - assert_noop!( - CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), - sp_runtime::DispatchError::BadOrigin + // Set block number to 1 so events are registered + System::set_block_number(1); + + let account = 1u64; + + // Increment by 50 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50)); + assert_eq!(crate::CounterValue::::get(), 50); + + // Check event was emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 50, + who: account, + amount: 50, + } + .into(), ); - assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); - assert_eq!(crate::CounterValue::::get(), 100); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); }); } #[test] - fn increment_emits_event() { + fn increment_tracks_multiple_interactions() { new_test_ext().execute_with(|| { - let alice = 1u64; + let account = 1u64; + + // Increment multiple times + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 20)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 30)); + + // Check counter value + assert_eq!(crate::CounterValue::::get(), 60); + + // Check user interactions were tracked (should be 3) + assert_eq!(crate::UserInteractions::::get(account), 3); + }); + } + + #[test] + fn increment_fails_on_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + // Attempt to increment when at max u32 should fail + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(1), 1), + Error::::Overflow + ); + }); + } + + #[test] + fn increment_respects_max_value() { + new_test_ext_with_counter(950).execute_with(|| { + // Incrementing past max value (1000) should fail + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(1), 51), + Error::::CounterMaxValueExceeded + ); + + // Incrementing to exactly max value should work + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(1), 50)); + assert_eq!(crate::CounterValue::::get(), 1000); + }); + } + + #[test] + fn decrement_works() { + new_test_ext_with_counter(100).execute_with(|| { + // Set block number to 1 so events are registered System::set_block_number(1); - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + let account = 2u64; + + // Decrement by 30 + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 30)); + assert_eq!(crate::CounterValue::::get(), 70); + + // Check event was emitted System::assert_last_event( - Event::CounterIncremented { - new_value: 5, - who: alice, - amount: 5, + Event::CounterDecremented { + new_value: 70, + who: account, + amount: 30, } .into(), ); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); }); } #[test] - fn genesis_config_works() { + fn decrement_fails_on_underflow() { + new_test_ext_with_counter(10).execute_with(|| { + // Attempt to decrement below zero should fail + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(1), 11), + Error::::Underflow + ); + }); + } + + #[test] + fn decrement_tracks_multiple_interactions() { new_test_ext_with_counter(100).execute_with(|| { - assert_eq!(crate::CounterValue::::get(), 100); - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); - assert_eq!(crate::CounterValue::::get(), 110); + let account = 3u64; + + // Decrement multiple times + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 10)); + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 20)); + + // Check counter value + assert_eq!(crate::CounterValue::::get(), 70); + + // Check user interactions were tracked (should be 2) + assert_eq!(crate::UserInteractions::::get(account), 2); + }); + } + + #[test] + fn mixed_increment_and_decrement_works() { + new_test_ext_with_counter(50).execute_with(|| { + let account = 4u64; + + // Mix of increment and decrement + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 25)); + assert_eq!(crate::CounterValue::::get(), 75); + + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 15)); + assert_eq!(crate::CounterValue::::get(), 60); + + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10)); + assert_eq!(crate::CounterValue::::get(), 70); + + // Check user interactions were tracked (should be 3) + assert_eq!(crate::UserInteractions::::get(account), 3); + }); + } + + #[test] + fn different_users_tracked_separately() { + new_test_ext().execute_with(|| { + let account1 = 1u64; + let account2 = 2u64; + + // User 1 increments + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10)); + + // User 2 decrements + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account2), 5)); + + // Check counter value (10 + 10 - 5 = 15) + assert_eq!(crate::CounterValue::::get(), 15); + + // Check user interactions are tracked separately + assert_eq!(crate::UserInteractions::::get(account1), 2); + assert_eq!(crate::UserInteractions::::get(account2), 1); + }); + } + + #[test] + fn genesis_config_works() { + new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| { + // Check initial counter value + assert_eq!(crate::CounterValue::::get(), 42); + + // Check initial user interactions + assert_eq!(crate::UserInteractions::::get(1), 5); + assert_eq!(crate::UserInteractions::::get(2), 10); }); } ``` diff --git a/.ai/site-index.json b/.ai/site-index.json index cef1898af..c233e6f8a 100644 --- a/.ai/site-index.json +++ b/.ai/site-index.json @@ -5201,12 +5201,12 @@ } ], "stats": { - "chars": 13324, - "words": 1456, + "chars": 19551, + "words": 2005, "headings": 21, - "estimated_token_count_total": 3128 + "estimated_token_count_total": 4375 }, - "hash": "sha256:a60f4cb8e7322b71786ca8f2de1b6f6605950e7d40e1bfe702b26ff301dbc004", + "hash": "sha256:bf3908c112578ce4811bb0a4742af45ecbdd24acd0c3380f6b763b70e855fca5", "token_estimator": "heuristic-v1" }, { diff --git a/llms-full.jsonl b/llms-full.jsonl index 794ba4014..bef900658 100644 --- a/llms-full.jsonl +++ b/llms-full.jsonl @@ -610,20 +610,20 @@ {"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 4, "depth": 3, "title": "System Pallet Test Helpers", "anchor": "system-pallet-test-helpers", "start_char": 1877, "end_char": 2873, "estimated_token_count": 276, "token_estimator": "heuristic-v1", "text": "### System Pallet Test Helpers\n\nThe [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\\_blank} pallet provides useful methods for testing:\n\n- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\\_blank}** - Returns all events emitted during the test\n- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\\_blank}** - Asserts the last event matches expectations\n- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\\_blank}** - Sets the current block number\n\n!!!warning \"Events and Block Number\"\n Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`."} {"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 5, "depth": 3, "title": "Origin Types", "anchor": "origin-types", "start_char": 2873, "end_char": 3661, "estimated_token_count": 227, "token_estimator": "heuristic-v1", "text": "### Origin Types\n\n- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\\_blank}** - Root/sudo origin for privileged operations\n- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\\_blank}** - Signed origin from a specific account\n- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\\_blank}** - No origin (typically fails for most operations)\n\nLearn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\\_blank}."} {"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 6, "depth": 2, "title": "Create the Tests Module", "anchor": "create-the-tests-module", "start_char": 3661, "end_char": 4249, "estimated_token_count": 157, "token_estimator": "heuristic-v1", "text": "## Create the Tests Module\n\nCreate a new file for your tests within the pallet directory:\n\n1. Navigate to your pallet directory:\n\n ```bash\n cd pallets/pallet-custom/src\n ```\n\n2. Create a new file named `tests.rs`:\n\n ```bash\n touch tests.rs\n ```\n\n3. Open `src/lib.rs` and add the tests module declaration after the mock module:\n\n ```rust\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n\n #[frame::pallet]\n pub mod pallet {\n // ... existing pallet code\n }\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 7, "depth": 2, "title": "Set Up the Test Module", "anchor": "set-up-the-test-module", "start_char": 4249, "end_char": 4586, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Set Up the Test Module\n\nOpen `src/tests.rs` and add the basic structure with necessary imports:\n\n```rust\nuse crate::{mock::*, Error, Event};\nuse frame_support::{assert_noop, assert_ok};\n```\n\nThis setup imports:\n- The mock runtime and test utilities from `mock.rs`\n- Your pallet's `Error` and `Event` types\n- FRAME's assertion macros"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 8, "depth": 2, "title": "Write Your First Test", "anchor": "write-your-first-test", "start_char": 4586, "end_char": 4694, "estimated_token_count": 22, "token_estimator": "heuristic-v1", "text": "## Write Your First Test\n\nLet's start with a simple test to verify the increment function works correctly."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 9, "depth": 3, "title": "Test Basic Increment", "anchor": "test-basic-increment", "start_char": 4694, "end_char": 5431, "estimated_token_count": 187, "token_estimator": "heuristic-v1", "text": "### Test Basic Increment\n\n```rust\n#[test]\nfn increment_works() {\n new_test_ext().execute_with(|| {\n // Given: counter starts at 0\n let alice = 1u64;\n \n // When: Alice increments by 5\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5));\n \n // Then: counter value and user interactions are updated\n assert_eq!(crate::CounterValue::::get(), 5);\n assert_eq!(crate::UserInteractions::::get(alice), 1);\n });\n}\n```\n\nRun your first test:\n\n```bash\ncargo test --package pallet-custom increment_works\n```\n\nYou should see:\n\n```\nrunning 1 test\ntest tests::increment_works ... ok\n```\n\n🎉 Congratulations! You've written and run your first pallet test."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 10, "depth": 2, "title": "Test Error Conditions", "anchor": "test-error-conditions", "start_char": 5431, "end_char": 5576, "estimated_token_count": 28, "token_estimator": "heuristic-v1", "text": "## Test Error Conditions\n\nNow let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 11, "depth": 3, "title": "Test Overflow Protection", "anchor": "test-overflow-protection", "start_char": 5576, "end_char": 6352, "estimated_token_count": 177, "token_estimator": "heuristic-v1", "text": "### Test Overflow Protection\n\n```rust\n#[test]\nfn increment_handles_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Given: counter is at maximum u32 value\n let alice = 1u64;\n \n // When: attempting to increment\n // Then: should fail with overflow error and no state change\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(alice), 1),\n Error::::Overflow\n );\n \n // Verify no state changes occurred\n assert_eq!(crate::CounterValue::::get(), u32::MAX);\n assert_eq!(crate::UserInteractions::::get(alice), 0);\n });\n}\n```\n\nTest overflow protection:\n\n```bash\ncargo test --package pallet-custom increment_handles_overflow\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 12, "depth": 3, "title": "Test Underflow Protection", "anchor": "test-underflow-protection", "start_char": 6352, "end_char": 7114, "estimated_token_count": 170, "token_estimator": "heuristic-v1", "text": "### Test Underflow Protection\n\n```rust\n#[test]\nfn decrement_handles_underflow() {\n new_test_ext_with_counter(5).execute_with(|| {\n // Given: counter is at 5\n let alice = 1u64;\n \n // When: attempting to decrement by more than current value\n // Then: should fail with underflow error\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(alice), 10),\n Error::::Underflow\n );\n \n // Verify no state changes occurred\n assert_eq!(crate::CounterValue::::get(), 5);\n assert_eq!(crate::UserInteractions::::get(alice), 0);\n });\n}\n```\n\nVerify underflow protection:\n\n```bash\ncargo test --package pallet-custom decrement_handles_underflow\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 13, "depth": 2, "title": "Test Access Control", "anchor": "test-access-control", "start_char": 7114, "end_char": 7218, "estimated_token_count": 17, "token_estimator": "heuristic-v1", "text": "## Test Access Control\n\nVerify that origin checks work correctly and unauthorized access is prevented."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 14, "depth": 3, "title": "Test Root-Only Access", "anchor": "test-root-only-access", "start_char": 7218, "end_char": 7933, "estimated_token_count": 156, "token_estimator": "heuristic-v1", "text": "### Test Root-Only Access\n\n```rust\n#[test]\nfn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n \n // When: non-root user tries to set counter\n // Then: should fail with BadOrigin\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n sp_runtime::DispatchError::BadOrigin\n );\n \n // But root should succeed\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n}\n```\n\nTest access control:\n\n```bash\ncargo test --package pallet-custom set_counter_value_requires_root\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 15, "depth": 2, "title": "Test Event Emission", "anchor": "test-event-emission", "start_char": 7933, "end_char": 8020, "estimated_token_count": 16, "token_estimator": "heuristic-v1", "text": "## Test Event Emission\n\nVerify that events are emitted correctly with the right data."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 16, "depth": 3, "title": "Test Event Data", "anchor": "test-event-data", "start_char": 8020, "end_char": 8724, "estimated_token_count": 141, "token_estimator": "heuristic-v1", "text": "### Test Event Data\n\n```rust\n#[test]\nfn increment_emits_event() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n \n // Set block number to enable events\n System::set_block_number(1);\n \n // When: increment occurs\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5));\n \n // Then: correct event is emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 5,\n who: alice,\n amount: 5,\n }\n .into(),\n );\n });\n}\n```\n\nRun the event test:\n\n```bash\ncargo test --package pallet-custom increment_emits_event\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 17, "depth": 2, "title": "Test Genesis Configuration", "anchor": "test-genesis-configuration", "start_char": 8724, "end_char": 8807, "estimated_token_count": 12, "token_estimator": "heuristic-v1", "text": "## Test Genesis Configuration\n\nVerify that genesis configuration works correctly."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 18, "depth": 3, "title": "Test Genesis Setup", "anchor": "test-genesis-setup", "start_char": 8807, "end_char": 9421, "estimated_token_count": 152, "token_estimator": "heuristic-v1", "text": "### Test Genesis Setup\n\n```rust\n#[test]\nfn genesis_config_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n // Given: genesis sets counter to 100\n // Then: counter should start at that value\n assert_eq!(crate::CounterValue::::get(), 100);\n \n // And: we can still interact with it\n let alice = 1u64;\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10));\n assert_eq!(crate::CounterValue::::get(), 110);\n });\n}\n```\n\nTest genesis configuration:\n\n```bash\ncargo test --package pallet-custom genesis_config_works\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 19, "depth": 2, "title": "Run All Tests", "anchor": "run-all-tests", "start_char": 9421, "end_char": 12974, "estimated_token_count": 792, "token_estimator": "heuristic-v1", "text": "## Run All Tests\n\nNow run all your tests together:\n\n```bash\ncargo test --package pallet-custom\n```\n\nYou should see all tests passing:\n\n```\nrunning 6 tests\ntest tests::decrement_handles_underflow ... ok\ntest tests::genesis_config_works ... ok\ntest tests::increment_emits_event ... ok\ntest tests::increment_handles_overflow ... ok\ntest tests::increment_works ... ok\ntest tests::set_counter_value_requires_root ... ok\n\ntest result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out\n```\n\n🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns!\n\nThese six tests demonstrate the core patterns you'll use in pallet testing. As you build more complex pallets, you'll apply these same patterns to test additional functionality.\n\n??? code \"Full Test Suite Code\"\n Here's the complete `tests.rs` file for quick reference:\n\n ```rust\n use crate::{mock::*, Error, Event};\n use frame_support::{assert_noop, assert_ok};\n\n #[test]\n fn increment_works() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5));\n assert_eq!(crate::CounterValue::::get(), 5);\n assert_eq!(crate::UserInteractions::::get(alice), 1);\n });\n }\n\n #[test]\n fn increment_handles_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n let alice = 1u64;\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(alice), 1),\n Error::::Overflow\n );\n assert_eq!(crate::CounterValue::::get(), u32::MAX);\n assert_eq!(crate::UserInteractions::::get(alice), 0);\n });\n }\n\n #[test]\n fn decrement_handles_underflow() {\n new_test_ext_with_counter(5).execute_with(|| {\n let alice = 1u64;\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(alice), 10),\n Error::::Underflow\n );\n assert_eq!(crate::CounterValue::::get(), 5);\n assert_eq!(crate::UserInteractions::::get(alice), 0);\n });\n }\n\n #[test]\n fn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n sp_runtime::DispatchError::BadOrigin\n );\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n }\n\n #[test]\n fn increment_emits_event() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n System::set_block_number(1);\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5));\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 5,\n who: alice,\n amount: 5,\n }\n .into(),\n );\n });\n }\n\n #[test]\n fn genesis_config_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n assert_eq!(crate::CounterValue::::get(), 100);\n let alice = 1u64;\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10));\n assert_eq!(crate::CounterValue::::get(), 110);\n });\n }\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 12974, "end_char": 13324, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Add Your Custom Pallet to the Runtime__\n\n ---\n\n Your pallet is tested and ready! Learn how to integrate it into your runtime.\n\n [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)\n\n
"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 7, "depth": 2, "title": "Set Up the Test Module", "anchor": "set-up-the-test-module", "start_char": 4249, "end_char": 4705, "estimated_token_count": 125, "token_estimator": "heuristic-v1", "text": "## Set Up the Test Module\n\nOpen `src/tests.rs` and add the basic structure with necessary imports:\n\n```rust\nuse crate::{mock::*, Error, Event};\nuse frame::deps::frame_support::{assert_noop, assert_ok};\nuse frame::deps::sp_runtime::DispatchError;\n```\n\nThis setup imports:\n- The mock runtime and test utilities from `mock.rs`\n- Your pallet's `Error` and `Event` types\n- FRAME's assertion macros via `frame::deps`\n- `DispatchError` for testing origin checks"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 8, "depth": 2, "title": "Write Your First Test", "anchor": "write-your-first-test", "start_char": 4705, "end_char": 4813, "estimated_token_count": 22, "token_estimator": "heuristic-v1", "text": "## Write Your First Test\n\nLet's start with a simple test to verify the increment function works correctly."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 9, "depth": 3, "title": "Test Basic Increment", "anchor": "test-basic-increment", "start_char": 4813, "end_char": 5817, "estimated_token_count": 227, "token_estimator": "heuristic-v1", "text": "### Test Basic Increment\n\n```rust\n#[test]\nfn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n}\n```\n\nRun your first test:\n\n```bash\ncargo test --package pallet-custom increment_works\n```\n\nYou should see:\n\n```\nrunning 1 test\ntest tests::increment_works ... ok\n```\n\n🎉 Congratulations! You've written and run your first pallet test."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 10, "depth": 2, "title": "Test Error Conditions", "anchor": "test-error-conditions", "start_char": 5817, "end_char": 5962, "estimated_token_count": 28, "token_estimator": "heuristic-v1", "text": "## Test Error Conditions\n\nNow let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 11, "depth": 3, "title": "Test Overflow Protection", "anchor": "test-overflow-protection", "start_char": 5962, "end_char": 6414, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "### Test Overflow Protection\n\n```rust\n#[test]\nfn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n}\n```\n\nTest overflow protection:\n\n```bash\ncargo test --package pallet-custom increment_fails_on_overflow\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 12, "depth": 3, "title": "Test Underflow Protection", "anchor": "test-underflow-protection", "start_char": 6414, "end_char": 6863, "estimated_token_count": 95, "token_estimator": "heuristic-v1", "text": "### Test Underflow Protection\n\n```rust\n#[test]\nfn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n}\n```\n\nVerify underflow protection:\n\n```bash\ncargo test --package pallet-custom decrement_fails_on_underflow\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 13, "depth": 2, "title": "Test Access Control", "anchor": "test-access-control", "start_char": 6863, "end_char": 6967, "estimated_token_count": 17, "token_estimator": "heuristic-v1", "text": "## Test Access Control\n\nVerify that origin checks work correctly and unauthorized access is prevented."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 14, "depth": 3, "title": "Test Root-Only Access", "anchor": "test-root-only-access", "start_char": 6967, "end_char": 7654, "estimated_token_count": 153, "token_estimator": "heuristic-v1", "text": "### Test Root-Only Access\n\n```rust\n#[test]\nfn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n\n // When: non-root user tries to set counter\n // Then: should fail with BadOrigin\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n DispatchError::BadOrigin\n );\n\n // But root should succeed\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n}\n```\n\nTest access control:\n\n```bash\ncargo test --package pallet-custom set_counter_value_requires_root\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 15, "depth": 2, "title": "Test Event Emission", "anchor": "test-event-emission", "start_char": 7654, "end_char": 7741, "estimated_token_count": 16, "token_estimator": "heuristic-v1", "text": "## Test Event Emission\n\nVerify that events are emitted correctly with the right data."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 16, "depth": 3, "title": "Test Event Data", "anchor": "test-event-data", "start_char": 7741, "end_char": 8758, "estimated_token_count": 226, "token_estimator": "heuristic-v1", "text": "### Test Event Data\n\nThe `increment_works` test (shown earlier) already demonstrates event testing by:\n1. Setting the block number to 1 to enable event emission\n2. Calling the dispatchable function\n3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data\n\nThis pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function:\n\n```rust\n#[test]\nfn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n}\n```\n\nRun the event test:\n\n```bash\ncargo test --package pallet-custom set_counter_value_works\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 17, "depth": 2, "title": "Test Genesis Configuration", "anchor": "test-genesis-configuration", "start_char": 8758, "end_char": 8841, "estimated_token_count": 12, "token_estimator": "heuristic-v1", "text": "## Test Genesis Configuration\n\nVerify that genesis configuration works correctly."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 18, "depth": 3, "title": "Test Genesis Setup", "anchor": "test-genesis-setup", "start_char": 8841, "end_char": 9374, "estimated_token_count": 149, "token_estimator": "heuristic-v1", "text": "### Test Genesis Setup\n\n```rust\n#[test]\nfn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n}\n```\n\nTest genesis configuration:\n\n```bash\ncargo test --package pallet-custom genesis_config_works\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 19, "depth": 2, "title": "Run All Tests", "anchor": "run-all-tests", "start_char": 9374, "end_char": 19201, "estimated_token_count": 2039, "token_estimator": "heuristic-v1", "text": "## Run All Tests\n\nNow run all your tests together:\n\n```bash\ncargo test --package pallet-custom\n```\n\nYou should see all tests passing:\n\n```\nrunning 15 tests\ntest mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok\ntest mock::test_genesis_config_builds ... ok\ntest tests::decrement_fails_on_underflow ... ok\ntest tests::decrement_tracks_multiple_interactions ... ok\ntest tests::decrement_works ... ok\ntest tests::different_users_tracked_separately ... ok\ntest tests::genesis_config_works ... ok\ntest tests::increment_fails_on_overflow ... ok\ntest tests::increment_respects_max_value ... ok\ntest tests::increment_tracks_multiple_interactions ... ok\ntest tests::increment_works ... ok\ntest tests::mixed_increment_and_decrement_works ... ok\ntest tests::set_counter_value_requires_root ... ok\ntest tests::set_counter_value_respects_max_value ... ok\ntest tests::set_counter_value_works ... ok\n\ntest result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out\n```\n\n!!!note \"Mock Runtime Tests\"\n You'll notice 2 additional tests from the `mock` module:\n\n - `mock::__construct_runtime_integrity_test::runtime_integrity_tests` - Auto-generated test that validates runtime construction\n - `mock::test_genesis_config_builds` - Validates that genesis configuration builds correctly\n\n These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid.\n\n🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns!\n\nThese tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality.\n\n??? code \"Full Test Suite Code\"\n Here's the complete `tests.rs` file for quick reference:\n\n ```rust\n use crate::{mock::*, Error, Event};\n use frame::deps::frame_support::{assert_noop, assert_ok};\n use frame::deps::sp_runtime::DispatchError;\n\n #[test]\n fn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n }\n\n #[test]\n fn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter with non-root origin should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(1), 100),\n DispatchError::BadOrigin\n );\n });\n }\n\n #[test]\n fn set_counter_value_respects_max_value() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter above max value (1000) should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::root(), 1001),\n Error::::CounterMaxValueExceeded\n );\n\n // Setting to exactly max value should work\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 1000));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn increment_tracks_multiple_interactions() {\n new_test_ext().execute_with(|| {\n let account = 1u64;\n\n // Increment multiple times\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 20));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 30));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 60);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n }\n\n #[test]\n fn increment_respects_max_value() {\n new_test_ext_with_counter(950).execute_with(|| {\n // Incrementing past max value (1000) should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 51),\n Error::::CounterMaxValueExceeded\n );\n\n // Incrementing to exactly max value should work\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(1), 50));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn decrement_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 2u64;\n\n // Decrement by 30\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 30));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterDecremented {\n new_value: 70,\n who: account,\n amount: 30,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n }\n\n #[test]\n fn decrement_tracks_multiple_interactions() {\n new_test_ext_with_counter(100).execute_with(|| {\n let account = 3u64;\n\n // Decrement multiple times\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 20));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 2)\n assert_eq!(crate::UserInteractions::::get(account), 2);\n });\n }\n\n #[test]\n fn mixed_increment_and_decrement_works() {\n new_test_ext_with_counter(50).execute_with(|| {\n let account = 4u64;\n\n // Mix of increment and decrement\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 25));\n assert_eq!(crate::CounterValue::::get(), 75);\n\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 15));\n assert_eq!(crate::CounterValue::::get(), 60);\n\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn different_users_tracked_separately() {\n new_test_ext().execute_with(|| {\n let account1 = 1u64;\n let account2 = 2u64;\n\n // User 1 increments\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n\n // User 2 decrements\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account2), 5));\n\n // Check counter value (10 + 10 - 5 = 15)\n assert_eq!(crate::CounterValue::::get(), 15);\n\n // Check user interactions are tracked separately\n assert_eq!(crate::UserInteractions::::get(account1), 2);\n assert_eq!(crate::UserInteractions::::get(account2), 1);\n });\n }\n\n #[test]\n fn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n }\n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 19201, "end_char": 19551, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Add Your Custom Pallet to the Runtime__\n\n ---\n\n Your pallet is tested and ready! Learn how to integrate it into your runtime.\n\n [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)\n\n
"} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 26, "end_char": 754, "estimated_token_count": 146, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nA blockchain runtime is more than just a fixed set of rules—it's a dynamic foundation that you can shape to match your specific needs. With Polkadot SDK's [FRAME (Framework for Runtime Aggregation of Modularized Entities)](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\\_blank}, customizing your runtime is straightforward and modular. Instead of building everything from scratch, you combine pre-built pallets with your own custom logic to create a runtime suited to your blockchain's purpose.\n\nThis overview explains how runtime customization works, introduces the building blocks you'll use, and guides you through the key patterns for extending your runtime."} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 1, "depth": 2, "title": "Understanding Your Runtime", "anchor": "understanding-your-runtime", "start_char": 754, "end_char": 1532, "estimated_token_count": 158, "token_estimator": "heuristic-v1", "text": "## Understanding Your Runtime\n\nThe runtime is the core logic of your blockchain—it processes transactions, manages state, and enforces the rules that govern your network. When a transaction arrives at your blockchain, the [`frame_executive`](https://paritytech.github.io/polkadot-sdk/master/frame_executive/index.html){target=\\_blank} pallet receives it and routes it to the appropriate pallet for execution.\n\nThink of your runtime as a collection of specialized modules, each handling a different aspect of your blockchain. Need token balances? Use the Balances pallet. Want governance? Add the Governance pallet. Need something custom? Create your own pallet. By mixing and matching these modules, you build a runtime that's efficient, secure, and tailored to your use case."} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 2, "depth": 2, "title": "Runtime Architecture", "anchor": "runtime-architecture", "start_char": 1532, "end_char": 2084, "estimated_token_count": 121, "token_estimator": "heuristic-v1", "text": "## Runtime Architecture\n\nThe following diagram shows how FRAME components work together to form your runtime:\n\n![](/images/parachains/customize-runtime/index/frame-overview-01.webp)\n\nThe main components are:\n\n- **`frame_executive`**: Routes all incoming transactions to the correct pallet for execution.\n- **Pallets**: Domain-specific modules that implement your blockchain's features and business logic.\n- **`frame_system`**: Provides core runtime primitives and storage.\n- **`frame_support`**: Utilities and macros that simplify pallet development."} diff --git a/parachains/customize-runtime/pallet-development/pallet-testing.md b/parachains/customize-runtime/pallet-development/pallet-testing.md index 908c5b2e0..c9780a55e 100644 --- a/parachains/customize-runtime/pallet-development/pallet-testing.md +++ b/parachains/customize-runtime/pallet-development/pallet-testing.md @@ -101,13 +101,15 @@ Open `src/tests.rs` and add the basic structure with necessary imports: ```rust use crate::{mock::*, Error, Event}; -use frame_support::{assert_noop, assert_ok}; +use frame::deps::frame_support::{assert_noop, assert_ok}; +use frame::deps::sp_runtime::DispatchError; ``` This setup imports: - The mock runtime and test utilities from `mock.rs` - Your pallet's `Error` and `Event` types -- FRAME's assertion macros +- FRAME's assertion macros via `frame::deps` +- `DispatchError` for testing origin checks ## Write Your First Test @@ -119,15 +121,27 @@ Let's start with a simple test to verify the increment function works correctly. #[test] fn increment_works() { new_test_ext().execute_with(|| { - // Given: counter starts at 0 - let alice = 1u64; - - // When: Alice increments by 5 - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - - // Then: counter value and user interactions are updated - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 1); + // Set block number to 1 so events are registered + System::set_block_number(1); + + let account = 1u64; + + // Increment by 50 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50)); + assert_eq!(crate::CounterValue::::get(), 50); + + // Check event was emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 50, + who: account, + amount: 50, + } + .into(), + ); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); }); } ``` @@ -155,21 +169,13 @@ Now let's test that our pallet correctly handles errors. Error testing is crucia ```rust #[test] -fn increment_handles_overflow() { +fn increment_fails_on_overflow() { new_test_ext_with_counter(u32::MAX).execute_with(|| { - // Given: counter is at maximum u32 value - let alice = 1u64; - - // When: attempting to increment - // Then: should fail with overflow error and no state change + // Attempt to increment when at max u32 should fail assert_noop!( - CustomPallet::increment(RuntimeOrigin::signed(alice), 1), + CustomPallet::increment(RuntimeOrigin::signed(1), 1), Error::::Overflow ); - - // Verify no state changes occurred - assert_eq!(crate::CounterValue::::get(), u32::MAX); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } ``` @@ -177,28 +183,20 @@ fn increment_handles_overflow() { Test overflow protection: ```bash -cargo test --package pallet-custom increment_handles_overflow +cargo test --package pallet-custom increment_fails_on_overflow ``` ### Test Underflow Protection ```rust #[test] -fn decrement_handles_underflow() { - new_test_ext_with_counter(5).execute_with(|| { - // Given: counter is at 5 - let alice = 1u64; - - // When: attempting to decrement by more than current value - // Then: should fail with underflow error +fn decrement_fails_on_underflow() { + new_test_ext_with_counter(10).execute_with(|| { + // Attempt to decrement below zero should fail assert_noop!( - CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), + CustomPallet::decrement(RuntimeOrigin::signed(1), 11), Error::::Underflow ); - - // Verify no state changes occurred - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } ``` @@ -206,7 +204,7 @@ fn decrement_handles_underflow() { Verify underflow protection: ```bash -cargo test --package pallet-custom decrement_handles_underflow +cargo test --package pallet-custom decrement_fails_on_underflow ``` ## Test Access Control @@ -220,14 +218,14 @@ Verify that origin checks work correctly and unauthorized access is prevented. fn set_counter_value_requires_root() { new_test_ext().execute_with(|| { let alice = 1u64; - + // When: non-root user tries to set counter // Then: should fail with BadOrigin assert_noop!( CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), - sp_runtime::DispatchError::BadOrigin + DispatchError::BadOrigin ); - + // But root should succeed assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); assert_eq!(crate::CounterValue::::get(), 100); @@ -247,27 +245,26 @@ Verify that events are emitted correctly with the right data. ### Test Event Data +The `increment_works` test (shown earlier) already demonstrates event testing by: +1. Setting the block number to 1 to enable event emission +2. Calling the dispatchable function +3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data + +This pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function: + ```rust #[test] -fn increment_emits_event() { +fn set_counter_value_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - - // Set block number to enable events + // Set block number to 1 so events are registered System::set_block_number(1); - - // When: increment occurs - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - - // Then: correct event is emitted - System::assert_last_event( - Event::CounterIncremented { - new_value: 5, - who: alice, - amount: 5, - } - .into(), - ); + + // Set counter to 100 + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + + // Check event was emitted + System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into()); }); } ``` @@ -275,7 +272,7 @@ fn increment_emits_event() { Run the event test: ```bash -cargo test --package pallet-custom increment_emits_event +cargo test --package pallet-custom set_counter_value_works ``` ## Test Genesis Configuration @@ -287,15 +284,13 @@ Verify that genesis configuration works correctly. ```rust #[test] fn genesis_config_works() { - new_test_ext_with_counter(100).execute_with(|| { - // Given: genesis sets counter to 100 - // Then: counter should start at that value - assert_eq!(crate::CounterValue::::get(), 100); - - // And: we can still interact with it - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); - assert_eq!(crate::CounterValue::::get(), 110); + new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| { + // Check initial counter value + assert_eq!(crate::CounterValue::::get(), 42); + + // Check initial user interactions + assert_eq!(crate::UserInteractions::::get(1), 5); + assert_eq!(crate::UserInteractions::::get(2), 10); }); } ``` @@ -317,101 +312,264 @@ cargo test --package pallet-custom You should see all tests passing: ``` -running 6 tests -test tests::decrement_handles_underflow ... ok +running 15 tests +test mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok +test mock::test_genesis_config_builds ... ok +test tests::decrement_fails_on_underflow ... ok +test tests::decrement_tracks_multiple_interactions ... ok +test tests::decrement_works ... ok +test tests::different_users_tracked_separately ... ok test tests::genesis_config_works ... ok -test tests::increment_emits_event ... ok -test tests::increment_handles_overflow ... ok +test tests::increment_fails_on_overflow ... ok +test tests::increment_respects_max_value ... ok +test tests::increment_tracks_multiple_interactions ... ok test tests::increment_works ... ok +test tests::mixed_increment_and_decrement_works ... ok test tests::set_counter_value_requires_root ... ok +test tests::set_counter_value_respects_max_value ... ok +test tests::set_counter_value_works ... ok -test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ``` +!!!note "Mock Runtime Tests" + You'll notice 2 additional tests from the `mock` module: + + - `mock::__construct_runtime_integrity_test::runtime_integrity_tests` - Auto-generated test that validates runtime construction + - `mock::test_genesis_config_builds` - Validates that genesis configuration builds correctly + + These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid. + 🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! -These six tests demonstrate the core patterns you'll use in pallet testing. As you build more complex pallets, you'll apply these same patterns to test additional functionality. +These tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality. ??? code "Full Test Suite Code" Here's the complete `tests.rs` file for quick reference: ```rust use crate::{mock::*, Error, Event}; - use frame_support::{assert_noop, assert_ok}; + use frame::deps::frame_support::{assert_noop, assert_ok}; + use frame::deps::sp_runtime::DispatchError; #[test] - fn increment_works() { + fn set_counter_value_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 1); + // Set block number to 1 so events are registered + System::set_block_number(1); + + // Set counter to 100 + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); + assert_eq!(crate::CounterValue::::get(), 100); + + // Check event was emitted + System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into()); }); } #[test] - fn increment_handles_overflow() { - new_test_ext_with_counter(u32::MAX).execute_with(|| { - let alice = 1u64; + fn set_counter_value_requires_root() { + new_test_ext().execute_with(|| { + // Attempt to set counter with non-root origin should fail assert_noop!( - CustomPallet::increment(RuntimeOrigin::signed(alice), 1), - Error::::Overflow + CustomPallet::set_counter_value(RuntimeOrigin::signed(1), 100), + DispatchError::BadOrigin ); - assert_eq!(crate::CounterValue::::get(), u32::MAX); - assert_eq!(crate::UserInteractions::::get(alice), 0); }); } #[test] - fn decrement_handles_underflow() { - new_test_ext_with_counter(5).execute_with(|| { - let alice = 1u64; + fn set_counter_value_respects_max_value() { + new_test_ext().execute_with(|| { + // Attempt to set counter above max value (1000) should fail assert_noop!( - CustomPallet::decrement(RuntimeOrigin::signed(alice), 10), - Error::::Underflow + CustomPallet::set_counter_value(RuntimeOrigin::root(), 1001), + Error::::CounterMaxValueExceeded ); - assert_eq!(crate::CounterValue::::get(), 5); - assert_eq!(crate::UserInteractions::::get(alice), 0); + + // Setting to exactly max value should work + assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 1000)); + assert_eq!(crate::CounterValue::::get(), 1000); }); } #[test] - fn set_counter_value_requires_root() { + fn increment_works() { new_test_ext().execute_with(|| { - let alice = 1u64; - assert_noop!( - CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100), - sp_runtime::DispatchError::BadOrigin + // Set block number to 1 so events are registered + System::set_block_number(1); + + let account = 1u64; + + // Increment by 50 + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50)); + assert_eq!(crate::CounterValue::::get(), 50); + + // Check event was emitted + System::assert_last_event( + Event::CounterIncremented { + new_value: 50, + who: account, + amount: 50, + } + .into(), ); - assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100)); - assert_eq!(crate::CounterValue::::get(), 100); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); }); } #[test] - fn increment_emits_event() { + fn increment_tracks_multiple_interactions() { new_test_ext().execute_with(|| { - let alice = 1u64; + let account = 1u64; + + // Increment multiple times + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 20)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 30)); + + // Check counter value + assert_eq!(crate::CounterValue::::get(), 60); + + // Check user interactions were tracked (should be 3) + assert_eq!(crate::UserInteractions::::get(account), 3); + }); + } + + #[test] + fn increment_fails_on_overflow() { + new_test_ext_with_counter(u32::MAX).execute_with(|| { + // Attempt to increment when at max u32 should fail + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(1), 1), + Error::::Overflow + ); + }); + } + + #[test] + fn increment_respects_max_value() { + new_test_ext_with_counter(950).execute_with(|| { + // Incrementing past max value (1000) should fail + assert_noop!( + CustomPallet::increment(RuntimeOrigin::signed(1), 51), + Error::::CounterMaxValueExceeded + ); + + // Incrementing to exactly max value should work + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(1), 50)); + assert_eq!(crate::CounterValue::::get(), 1000); + }); + } + + #[test] + fn decrement_works() { + new_test_ext_with_counter(100).execute_with(|| { + // Set block number to 1 so events are registered System::set_block_number(1); - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 5)); + + let account = 2u64; + + // Decrement by 30 + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 30)); + assert_eq!(crate::CounterValue::::get(), 70); + + // Check event was emitted System::assert_last_event( - Event::CounterIncremented { - new_value: 5, - who: alice, - amount: 5, + Event::CounterDecremented { + new_value: 70, + who: account, + amount: 30, } .into(), ); + + // Check user interactions were tracked + assert_eq!(crate::UserInteractions::::get(account), 1); }); } #[test] - fn genesis_config_works() { + fn decrement_fails_on_underflow() { + new_test_ext_with_counter(10).execute_with(|| { + // Attempt to decrement below zero should fail + assert_noop!( + CustomPallet::decrement(RuntimeOrigin::signed(1), 11), + Error::::Underflow + ); + }); + } + + #[test] + fn decrement_tracks_multiple_interactions() { new_test_ext_with_counter(100).execute_with(|| { - assert_eq!(crate::CounterValue::::get(), 100); - let alice = 1u64; - assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(alice), 10)); - assert_eq!(crate::CounterValue::::get(), 110); + let account = 3u64; + + // Decrement multiple times + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 10)); + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 20)); + + // Check counter value + assert_eq!(crate::CounterValue::::get(), 70); + + // Check user interactions were tracked (should be 2) + assert_eq!(crate::UserInteractions::::get(account), 2); + }); + } + + #[test] + fn mixed_increment_and_decrement_works() { + new_test_ext_with_counter(50).execute_with(|| { + let account = 4u64; + + // Mix of increment and decrement + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 25)); + assert_eq!(crate::CounterValue::::get(), 75); + + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 15)); + assert_eq!(crate::CounterValue::::get(), 60); + + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10)); + assert_eq!(crate::CounterValue::::get(), 70); + + // Check user interactions were tracked (should be 3) + assert_eq!(crate::UserInteractions::::get(account), 3); + }); + } + + #[test] + fn different_users_tracked_separately() { + new_test_ext().execute_with(|| { + let account1 = 1u64; + let account2 = 2u64; + + // User 1 increments + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10)); + assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10)); + + // User 2 decrements + assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account2), 5)); + + // Check counter value (10 + 10 - 5 = 15) + assert_eq!(crate::CounterValue::::get(), 15); + + // Check user interactions are tracked separately + assert_eq!(crate::UserInteractions::::get(account1), 2); + assert_eq!(crate::UserInteractions::::get(account2), 1); + }); + } + + #[test] + fn genesis_config_works() { + new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| { + // Check initial counter value + assert_eq!(crate::CounterValue::::get(), 42); + + // Check initial user interactions + assert_eq!(crate::UserInteractions::::get(1), 5); + assert_eq!(crate::UserInteractions::::get(2), 10); }); } ``` From c7a2f4e022da858ab8c6185ff1a091fa8726292c Mon Sep 17 00:00:00 2001 From: Bruno Galvao Date: Wed, 12 Nov 2025 09:36:37 +0700 Subject: [PATCH 03/10] Adding a pallet is included in the create a pallet page --- .../add-pallet-to-runtime/Cargo.toml | 102 ------ .../add-pallet-to-runtime/build.rs | 17 - .../add-pallet-to-runtime/src/apis.rs | 308 ---------------- .../add-pallet-to-runtime/src/benchmarks.rs | 37 -- .../add-pallet-to-runtime/src/configs/mod.rs | 344 ------------------ .../src/configs/xcm_config.rs | 216 ----------- .../src/genesis_config_presets.rs | 134 ------- .../add-pallet-to-runtime/src/lib.rs | 331 ----------------- .../src/weights/block_weights.rs | 57 --- .../src/weights/extrinsic_weights.rs | 57 --- .../add-pallet-to-runtime/src/weights/mod.rs | 27 -- .../src/weights/paritydb_weights.rs | 67 ---- .../src/weights/rocksdb_weights.rs | 67 ---- .../add-pallet-to-runtime.md | 170 --------- 14 files changed, 1934 deletions(-) delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/Cargo.toml delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/build.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/apis.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/benchmarks.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/mod.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/xcm_config.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/genesis_config_presets.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/lib.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/block_weights.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/extrinsic_weights.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/mod.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/paritydb_weights.rs delete mode 100644 .snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/rocksdb_weights.rs delete mode 100644 parachains/customize-runtime/pallet-development/add-pallet-to-runtime.md diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/Cargo.toml b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/Cargo.toml deleted file mode 100644 index de0b6da9e..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/Cargo.toml +++ /dev/null @@ -1,102 +0,0 @@ -[package] -name = "parachain-template-runtime" -description = "A parachain runtime template built with Substrate and Cumulus, part of Polkadot Sdk." -version = "0.1.0" -license = "Unlicense" -authors.workspace = true -homepage.workspace = true -repository.workspace = true -edition.workspace = true -publish = false - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[build-dependencies] -docify = { workspace = true } -substrate-wasm-builder = { optional = true, workspace = true, default-features = true } - -[dependencies] -codec = { features = ["derive"], workspace = true } -cumulus-pallet-parachain-system.workspace = true -docify = { workspace = true } -hex-literal = { optional = true, workspace = true, default-features = true } -log = { workspace = true } -pallet-parachain-template = { path = "../pallets/template", default-features = false } -polkadot-sdk = { workspace = true, features = [ - "pallet-utility", - "cumulus-pallet-aura-ext", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-weight-reclaim", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-aura", - "cumulus-primitives-core", - "cumulus-primitives-utility", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-message-queue", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-xcm", - "parachains-common", - "polkadot-parachain-primitives", - "polkadot-runtime-common", - "runtime", - "staging-parachain-info", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", -], default-features = false } -scale-info = { features = ["derive"], workspace = true } -serde_json = { workspace = true, default-features = false, features = [ - "alloc", -] } -smallvec = { workspace = true, default-features = true } - -custom-pallet = { path = "../pallets/custom-pallet", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "cumulus-pallet-parachain-system/std", - "log/std", - "pallet-parachain-template/std", - "polkadot-sdk/std", - "scale-info/std", - "serde_json/std", - "substrate-wasm-builder", - "custom-pallet/std", -] - -runtime-benchmarks = [ - "cumulus-pallet-parachain-system/runtime-benchmarks", - "hex-literal", - "pallet-parachain-template/runtime-benchmarks", - "polkadot-sdk/runtime-benchmarks", -] - -try-runtime = [ - "cumulus-pallet-parachain-system/try-runtime", - "pallet-parachain-template/try-runtime", - "polkadot-sdk/try-runtime", -] - -# Enable the metadata hash generation. -# -# This is hidden behind a feature because it increases the compile time. -# The wasm binary needs to be compiled twice, once to fetch the metadata, -# generate the metadata hash and then a second time with the -# `RUNTIME_METADATA_HASH` environment variable set for the `CheckMetadataHash` -# extension. -metadata-hash = ["substrate-wasm-builder/metadata-hash"] - -# A convenience feature for enabling things when doing a build -# for an on-chain release. -on-chain-release-build = ["metadata-hash"] diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/build.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/build.rs deleted file mode 100644 index 83200815b..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -#[cfg(all(feature = "std", feature = "metadata-hash"))] -#[docify::export(template_enable_metadata_hash)] -fn main() { - substrate_wasm_builder::WasmBuilder::init_with_defaults() - .enable_metadata_hash("UNIT", 12) - .build(); -} - -#[cfg(all(feature = "std", not(feature = "metadata-hash")))] -fn main() { - substrate_wasm_builder::WasmBuilder::build_using_defaults(); -} - -/// The wasm builder is deactivated when compiling -/// this crate for wasm to speed up the compilation. -#[cfg(not(feature = "std"))] -fn main() {} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/apis.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/apis.rs deleted file mode 100644 index d01d678be..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/apis.rs +++ /dev/null @@ -1,308 +0,0 @@ -// This is free and unencumbered software released into the public domain. -// -// Anyone is free to copy, modify, publish, use, compile, sell, or -// distribute this software, either in source code form or as a compiled -// binary, for any purpose, commercial or non-commercial, and by any -// means. -// -// In jurisdictions that recognize copyright laws, the author or authors -// of this software dedicate any and all copyright interest in the -// software to the public domain. We make this dedication for the benefit -// of the public at large and to the detriment of our heirs and -// successors. We intend this dedication to be an overt act of -// relinquishment in perpetuity of all present and future rights to this -// software under copyright law. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// -// For more information, please refer to - -// External crates imports -use alloc::vec::Vec; - -use polkadot_sdk::*; - -use frame_support::{ - genesis_builder_helper::{build_state, get_preset}, - weights::Weight, -}; -use pallet_aura::Authorities; -use sp_api::impl_runtime_apis; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_runtime::{ - traits::Block as BlockT, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, -}; -use sp_version::RuntimeVersion; - -// Local module imports -use super::{ - AccountId, Balance, Block, ConsensusHook, Executive, InherentDataExt, Nonce, ParachainSystem, - Runtime, RuntimeCall, RuntimeGenesisConfig, SessionKeys, System, TransactionPayment, - SLOT_DURATION, VERSION, -}; - -// we move some impls outside so we can easily use them with `docify`. -impl Runtime { - #[docify::export] - fn impl_slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION) - } - - #[docify::export] - fn impl_can_build_upon( - included_hash: ::Hash, - slot: cumulus_primitives_aura::Slot, - ) -> bool { - ConsensusHook::can_build_upon(included_hash, slot) - } -} - -impl_runtime_apis! { - impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - Runtime::impl_slot_duration() - } - - fn authorities() -> Vec { - Authorities::::get().into_inner() - } - } - - impl cumulus_primitives_aura::AuraUnincludedSegmentApi for Runtime { - fn can_build_upon( - included_hash: ::Hash, - slot: cumulus_primitives_aura::Slot, - ) -> bool { - Runtime::impl_can_build_upon(included_hash, slot) - } - } - - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block) - } - - fn initialize_block(header: &::Header) -> sp_runtime::ExtrinsicInclusionMode { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - - fn metadata_at_version(version: u32) -> Option { - Runtime::metadata_at_version(version) - } - - fn metadata_versions() -> Vec { - Runtime::metadata_versions() - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, KeyTypeId)>> { - SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Nonce { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { - fn query_info( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - fn query_fee_details( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment::FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi - for Runtime - { - fn query_call_info( - call: RuntimeCall, - len: u32, - ) -> pallet_transaction_payment::RuntimeDispatchInfo { - TransactionPayment::query_call_info(call, len) - } - fn query_call_fee_details( - call: RuntimeCall, - len: u32, - ) -> pallet_transaction_payment::FeeDetails { - TransactionPayment::query_call_fee_details(call, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl cumulus_primitives_core::CollectCollationInfo for Runtime { - fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { - ParachainSystem::collect_collation_info(header) - } - } - - #[cfg(feature = "try-runtime")] - impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { - use super::configs::RuntimeBlockWeights; - - let weight = Executive::try_runtime_upgrade(checks).unwrap(); - (weight, RuntimeBlockWeights::get().max_block) - } - - fn execute_block( - block: Block, - state_root_check: bool, - signature_check: bool, - select: frame_try_runtime::TryStateSelect, - ) -> Weight { - // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to - // have a backtrace here. - Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap() - } - } - - #[cfg(feature = "runtime-benchmarks")] - impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> ( - Vec, - Vec, - ) { - use frame_benchmarking::{Benchmarking, BenchmarkList}; - use polkadot_sdk::frame_support::traits::StorageInfoTrait; - use frame_system_benchmarking::Pallet as SystemBench; - use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - use super::*; - - let mut list = Vec::::new(); - list_benchmarks!(list, extra); - - let storage_info = AllPalletsWithSystem::storage_info(); - (list, storage_info) - } - - fn dispatch_benchmark( - config: frame_benchmarking::BenchmarkConfig - ) -> Result, alloc::string::String> { - use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch}; - use super::*; - - use frame_system_benchmarking::Pallet as SystemBench; - impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &Vec) -> Result<(), BenchmarkError> { - ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); - Ok(()) - } - - fn verify_set_code() { - System::assert_last_event(cumulus_pallet_parachain_system::Event::::ValidationFunctionStored.into()); - } - } - - use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - impl cumulus_pallet_session_benchmarking::Config for Runtime {} - - use polkadot_sdk::frame_support::traits::WhitelistedStorageKeys; - let whitelist = AllPalletsWithSystem::whitelisted_storage_keys(); - - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - add_benchmarks!(params, batches); - - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok(batches) - } - } - - impl sp_genesis_builder::GenesisBuilder for Runtime { - fn build_state(config: Vec) -> sp_genesis_builder::Result { - build_state::(config) - } - - fn get_preset(id: &Option) -> Option> { - get_preset::(id, crate::genesis_config_presets::get_preset) - } - - fn preset_names() -> Vec { - crate::genesis_config_presets::preset_names() - } - } -} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/benchmarks.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/benchmarks.rs deleted file mode 100644 index 179187b05..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/benchmarks.rs +++ /dev/null @@ -1,37 +0,0 @@ -// This is free and unencumbered software released into the public domain. -// -// Anyone is free to copy, modify, publish, use, compile, sell, or -// distribute this software, either in source code form or as a compiled -// binary, for any purpose, commercial or non-commercial, and by any -// means. -// -// In jurisdictions that recognize copyright laws, the author or authors -// of this software dedicate any and all copyright interest in the -// software to the public domain. We make this dedication for the benefit -// of the public at large and to the detriment of our heirs and -// successors. We intend this dedication to be an overt act of -// relinquishment in perpetuity of all present and future rights to this -// software under copyright law. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// -// For more information, please refer to - -polkadot_sdk::frame_benchmarking::define_benchmarks!( - [frame_system, SystemBench::] - [pallet_balances, Balances] - [pallet_session, SessionBench::] - [pallet_timestamp, Timestamp] - [pallet_message_queue, MessageQueue] - [pallet_sudo, Sudo] - [pallet_collator_selection, CollatorSelection] - [cumulus_pallet_parachain_system, ParachainSystem] - [cumulus_pallet_xcmp_queue, XcmpQueue] - [custom_pallet, CustomPallet] -); diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/mod.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/mod.rs deleted file mode 100644 index 035d1c75b..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/mod.rs +++ /dev/null @@ -1,344 +0,0 @@ -// This is free and unencumbered software released into the public domain. -// -// Anyone is free to copy, modify, publish, use, compile, sell, or -// distribute this software, either in source code form or as a compiled -// binary, for any purpose, commercial or non-commercial, and by any -// means. -// -// In jurisdictions that recognize copyright laws, the author or authors -// of this software dedicate any and all copyright interest in the -// software to the public domain. We make this dedication for the benefit -// of the public at large and to the detriment of our heirs and -// successors. We intend this dedication to be an overt act of -// relinquishment in perpetuity of all present and future rights to this -// software under copyright law. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// -// For more information, please refer to - -mod xcm_config; - -use polkadot_sdk::{staging_parachain_info as parachain_info, staging_xcm as xcm, *}; -#[cfg(not(feature = "runtime-benchmarks"))] -use polkadot_sdk::{staging_xcm_builder as xcm_builder, staging_xcm_executor as xcm_executor}; - -// Substrate and Polkadot dependencies -use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; -use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; -use frame_support::{ - derive_impl, - dispatch::DispatchClass, - parameter_types, - traits::{ - ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, TransformOrigin, VariantCountOf, - }, - weights::{ConstantMultiplier, Weight}, - PalletId, -}; -use frame_system::{ - limits::{BlockLength, BlockWeights}, - EnsureRoot, -}; -use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; -use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; -use polkadot_runtime_common::{ - xcm_sender::NoPriceForMessageDelivery, BlockHashCount, SlowAdjustingFeeUpdate, -}; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_runtime::Perbill; -use sp_version::RuntimeVersion; -use xcm::latest::prelude::BodyId; - -// Local module imports -use super::OriginCaller; -use super::{ - weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, - AccountId, Aura, Balance, Balances, Block, BlockNumber, CollatorSelection, ConsensusHook, Hash, - MessageQueue, Nonce, PalletInfo, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, - RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Session, SessionKeys, - System, WeightToFee, XcmpQueue, AVERAGE_ON_INITIALIZE_RATIO, EXISTENTIAL_DEPOSIT, HOURS, - MAXIMUM_BLOCK_WEIGHT, MICRO_UNIT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, VERSION, -}; -use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin}; - -parameter_types! { - pub const Version: RuntimeVersion = VERSION; - - // This part is copied from Substrate's `bin/node/runtime/src/lib.rs`. - // The `RuntimeBlockLength` and `RuntimeBlockWeights` exist here because the - // `DeletionWeightLimit` and `DeletionQueueDepth` depend on those to parameterize - // the lazy contract deletion. - pub RuntimeBlockLength: BlockLength = - BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() - .base_block(BlockExecutionWeight::get()) - .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = ExtrinsicBaseWeight::get(); - }) - .for_class(DispatchClass::Normal, |weights| { - weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); - }) - .for_class(DispatchClass::Operational, |weights| { - weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); - // Operational transactions have some extra reserved space, so that they - // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. - weights.reserved = Some( - MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT - ); - }) - .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) - .build_or_panic(); - pub const SS58Prefix: u16 = 42; -} - -/// The default types are being injected by [`derive_impl`](`frame_support::derive_impl`) from -/// [`ParaChainDefaultConfig`](`struct@frame_system::config_preludes::ParaChainDefaultConfig`), -/// but overridden as needed. -#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)] -impl frame_system::Config for Runtime { - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; - /// The index type for storing how many extrinsics an account has signed. - type Nonce = Nonce; - /// The type for hashing blocks and tries. - type Hash = Hash; - /// The block type. - type Block = Block; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). - type BlockHashCount = BlockHashCount; - /// Runtime version. - type Version = Version; - /// The data to be stored in an account. - type AccountData = pallet_balances::AccountData; - /// The weight of database operations that the runtime can invoke. - type DbWeight = RocksDbWeight; - /// Block & extrinsics weights: base values and limits. - type BlockWeights = RuntimeBlockWeights; - /// The maximum length of a block (in bytes). - type BlockLength = RuntimeBlockLength; - /// This is used as an identifier of the chain. 42 is the generic substrate prefix. - type SS58Prefix = SS58Prefix; - /// The action to take on a Runtime Upgrade - type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -/// Configure the pallet weight reclaim tx. -impl cumulus_pallet_weight_reclaim::Config for Runtime { - type WeightInfo = (); -} - -impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the unix epoch. - type Moment = u64; - type OnTimestampSet = Aura; - type MinimumPeriod = ConstU64<0>; - type WeightInfo = (); -} - -impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type EventHandler = (CollatorSelection,); -} - -parameter_types! { - pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT; -} - -impl pallet_balances::Config for Runtime { - type MaxLocks = ConstU32<50>; - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; - type MaxReserves = ConstU32<50>; - type ReserveIdentifier = [u8; 8]; - type RuntimeHoldReason = RuntimeHoldReason; - type RuntimeFreezeReason = RuntimeFreezeReason; - type FreezeIdentifier = RuntimeFreezeReason; - type MaxFreezes = VariantCountOf; - type DoneSlashHandler = (); -} - -parameter_types! { - /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 10 * MICRO_UNIT; -} - -impl pallet_transaction_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter; - type WeightToFee = WeightToFee; - type LengthToFee = ConstantMultiplier; - type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; - type OperationalFeeMultiplier = ConstU8<5>; - type WeightInfo = (); -} - -impl pallet_sudo::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type WeightInfo = (); -} - -parameter_types! { - pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); - pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); - pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; -} - -impl cumulus_pallet_parachain_system::Config for Runtime { - type WeightInfo = (); - type RuntimeEvent = RuntimeEvent; - type OnSystemEvent = (); - type SelfParaId = parachain_info::Pallet; - type OutboundXcmpMessageSource = XcmpQueue; - type DmpQueue = frame_support::traits::EnqueueWithOrigin; - type ReservedDmpWeight = ReservedDmpWeight; - type XcmpMessageHandler = XcmpQueue; - type ReservedXcmpWeight = ReservedXcmpWeight; - type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases; - type ConsensusHook = ConsensusHook; - type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector; -} - -impl parachain_info::Config for Runtime {} - -parameter_types! { - pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block; -} - -impl pallet_message_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); - #[cfg(feature = "runtime-benchmarks")] - type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor< - cumulus_primitives_core::AggregateMessageOrigin, - >; - #[cfg(not(feature = "runtime-benchmarks"))] - type MessageProcessor = xcm_builder::ProcessXcmMessage< - AggregateMessageOrigin, - xcm_executor::XcmExecutor, - RuntimeCall, - >; - type Size = u32; - // The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin: - type QueueChangeHandler = NarrowOriginToSibling; - type QueuePausedQuery = NarrowOriginToSibling; - type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>; - type MaxStale = sp_core::ConstU32<8>; - type ServiceWeight = MessageQueueServiceWeight; - type IdleMaxServiceWeight = (); -} - -impl cumulus_pallet_aura_ext::Config for Runtime {} - -impl cumulus_pallet_xcmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ChannelInfo = ParachainSystem; - type VersionWrapper = (); - // Enqueue XCMP messages from siblings for later processing. - type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = sp_core::ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; - type ControllerOrigin = EnsureRoot; - type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type WeightInfo = (); - type PriceForSiblingDelivery = NoPriceForMessageDelivery; -} - -parameter_types! { - pub const Period: u32 = 6 * HOURS; - pub const Offset: u32 = 0; -} - -impl pallet_session::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ValidatorId = ::AccountId; - // we don't have stash and controller, thus we don't need the convert as well. - type ValidatorIdOf = pallet_collator_selection::IdentityCollator; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = CollatorSelection; - // Essentially just Aura, but let's be pedantic. - type SessionHandler = ::KeyTypeIdProviders; - type Keys = SessionKeys; - type DisablingStrategy = (); - type WeightInfo = (); -} - -#[docify::export(aura_config)] -impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; - type DisabledValidators = (); - type MaxAuthorities = ConstU32<100_000>; - type AllowMultipleBlocksPerSlot = ConstBool; - type SlotDuration = ConstU64; -} - -parameter_types! { - pub const PotId: PalletId = PalletId(*b"PotStake"); - pub const SessionLength: BlockNumber = 6 * HOURS; - // StakingAdmin pluralistic body. - pub const StakingAdminBodyId: BodyId = BodyId::Defense; -} - -/// We allow root and the StakingAdmin to execute privileged collator selection operations. -pub type CollatorSelectionUpdateOrigin = EitherOfDiverse< - EnsureRoot, - EnsureXcm>, ->; - -impl pallet_collator_selection::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type UpdateOrigin = CollatorSelectionUpdateOrigin; - type PotId = PotId; - type MaxCandidates = ConstU32<100>; - type MinEligibleCollators = ConstU32<4>; - type MaxInvulnerables = ConstU32<20>; - // should be a multiple of session or things will get inconsistent - type KickThreshold = Period; - type ValidatorId = ::AccountId; - type ValidatorIdOf = pallet_collator_selection::IdentityCollator; - type ValidatorRegistration = Session; - type WeightInfo = (); -} - -/// Configure the pallet template in pallets/template. -impl pallet_parachain_template::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_parachain_template::weights::SubstrateWeight; -} - -// Configure utility pallet. -impl pallet_utility::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type PalletsOrigin = OriginCaller; - type WeightInfo = pallet_utility::weights::SubstrateWeight; -} - -// Define counter max value runtime constant. -parameter_types! { - pub const CounterMaxValue: u32 = 500; -} - -// Configure custom pallet. -impl custom_pallet::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type CounterMaxValue = CounterMaxValue; - type WeightInfo = custom_pallet::weights::SubstrateWeight; -} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/xcm_config.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/xcm_config.rs deleted file mode 100644 index 85a513ac8..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/xcm_config.rs +++ /dev/null @@ -1,216 +0,0 @@ -use crate::{ - AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, - Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, -}; - -use polkadot_sdk::{ - staging_xcm as xcm, staging_xcm_builder as xcm_builder, staging_xcm_executor as xcm_executor, *, -}; - -use frame_support::{ - parameter_types, - traits::{ConstU32, Contains, Everything, Nothing}, - weights::Weight, -}; -use frame_system::EnsureRoot; -use pallet_xcm::XcmPassthrough; -use polkadot_parachain_primitives::primitives::Sibling; -use polkadot_runtime_common::impls::ToAuthor; -use polkadot_sdk::{ - polkadot_sdk_frame::traits::Disabled, - staging_xcm_builder::{DenyRecursively, DenyThenTry}, -}; -use xcm::latest::prelude::*; -use xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, - DenyReserveTransferToRelayChain, EnsureXcmOrigin, FixedWeightBounds, - FrameTransactionalProcessor, FungibleAdapter, IsConcrete, NativeAsset, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, -}; -use xcm_executor::XcmExecutor; - -parameter_types! { - pub const RelayLocation: Location = Location::parent(); - pub const RelayNetwork: Option = None; - pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - // For the real deployment, it is recommended to set `RelayNetwork` according to the relay chain - // and prepend `UniversalLocation` with `GlobalConsensus(RelayNetwork::get())`. - pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into(); -} - -/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used -/// when determining ownership of accounts for asset transacting and when attempting to use XCM -/// `Transact` in order to determine the dispatch Origin. -pub type LocationToAccountId = ( - // The parent (Relay-chain) origin converts to the parent `AccountId`. - ParentIsPreset, - // Sibling parachain origins convert to AccountId via the `ParaId::into`. - SiblingParachainConvertsVia, - // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, -); - -/// Means for transacting assets on this chain. -pub type LocalAssetTransactor = FungibleAdapter< - // Use this currency: - Balances, - // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, - // Do a simple punn to convert an AccountId32 Location into a native chain account ID: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We don't track any teleports. - (), ->; - -/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, -/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can -/// biases the kind of local `Origin` it will become. -pub type XcmOriginToTransactDispatchOrigin = ( - // Sovereign account converter; this attempts to derive an `AccountId` from the origin location - // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for - // foreign chains who want to have a local sovereign account on this chain which they control. - SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when - // recognized. - RelayChainAsNative, - // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognized. - SiblingParachainAsNative, - // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `RuntimeOrigin::Signed` origin of the same 32-byte value. - SignedAccountId32AsNative, - // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. - XcmPassthrough, -); - -parameter_types! { - // One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate. - pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); - pub const MaxInstructions: u32 = 100; - pub const MaxAssetsIntoHolding: u32 = 64; -} - -pub struct ParentOrParentsExecutivePlurality; -impl Contains for ParentOrParentsExecutivePlurality { - fn contains(location: &Location) -> bool { - matches!( - location.unpack(), - (1, []) - | ( - 1, - [Plurality { - id: BodyId::Executive, - .. - }] - ) - ) - } -} - -pub type Barrier = TrailingSetTopicAsId< - DenyThenTry< - DenyRecursively, - ( - TakeWeightCredit, - WithComputedOrigin< - ( - AllowTopLevelPaidExecutionFrom, - AllowExplicitUnpaidExecutionFrom, - // ^^^ Parent and its exec plurality get free execution - ), - UniversalLocation, - ConstU32<8>, - >, - ), - >, ->; - -pub struct XcmConfig; -impl xcm_executor::Config for XcmConfig { - type RuntimeCall = RuntimeCall; - type XcmSender = XcmRouter; - type XcmEventEmitter = PolkadotXcm; - // How to withdraw and deposit an asset. - type AssetTransactor = LocalAssetTransactor; - type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = NativeAsset; - type IsTeleporter = (); // Teleporting is disabled. - type UniversalLocation = UniversalLocation; - type Barrier = Barrier; - type Weigher = FixedWeightBounds; - type Trader = - UsingComponents>; - type ResponseHandler = PolkadotXcm; - type AssetTrap = PolkadotXcm; - type AssetClaims = PolkadotXcm; - type SubscriptionService = PolkadotXcm; - type PalletInstancesInfo = AllPalletsWithSystem; - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); - type FeeManager = (); - type MessageExporter = (); - type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; - type SafeCallFilter = Everything; - type Aliasers = Nothing; - type TransactionalProcessor = FrameTransactionalProcessor; - type HrmpNewChannelOpenRequestHandler = (); - type HrmpChannelAcceptedHandler = (); - type HrmpChannelClosingHandler = (); - type XcmRecorder = PolkadotXcm; -} - -/// Converts a local signed origin into an XCM location. Forms the basis for local origins -/// sending/executing XCMs. -pub type LocalOriginToLocation = SignedToAccountId32; - -/// The means for routing XCM messages which are not for local execution into the right message -/// queues. -pub type XcmRouter = WithUniqueTopic<( - // Two routers - use UMP to communicate with the relay chain: - cumulus_primitives_utility::ParentAsUmp, - // ..and XCMP to communicate with the sibling chains. - XcmpQueue, -)>; - -impl pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SendXcmOrigin = EnsureXcmOrigin; - type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; - type XcmExecuteFilter = Nothing; - // ^ Disable dispatchable execute on the XCM pallet. - // Needs to be `Everything` for local testing. - type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Nothing; - type Weigher = FixedWeightBounds; - type UniversalLocation = UniversalLocation; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - // ^ Override for AdvertisedXcmVersion default - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = LocationToAccountId; - type MaxLockers = ConstU32<8>; - type WeightInfo = pallet_xcm::TestWeightInfo; - type AdminOrigin = EnsureRoot; - type MaxRemoteLockConsumers = ConstU32<0>; - type RemoteLockConsumerIdentifier = (); - // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. - type AuthorizedAliasConsideration = Disabled; -} - -impl cumulus_pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; -} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/genesis_config_presets.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/genesis_config_presets.rs deleted file mode 100644 index a17fa8c91..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/genesis_config_presets.rs +++ /dev/null @@ -1,134 +0,0 @@ -use crate::{ - AccountId, BalancesConfig, CollatorSelectionConfig, ParachainInfoConfig, PolkadotXcmConfig, - RuntimeGenesisConfig, SessionConfig, SessionKeys, SudoConfig, EXISTENTIAL_DEPOSIT, -}; - -use alloc::{vec, vec::Vec}; - -use polkadot_sdk::{staging_xcm as xcm, *}; - -use cumulus_primitives_core::ParaId; -use frame_support::build_struct_json_patch; -use parachains_common::AuraId; -use serde_json::Value; -use sp_genesis_builder::PresetId; -use sp_keyring::Sr25519Keyring; - -/// The default XCM version to set in genesis config. -const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; -/// Parachain id used for genesis config presets of parachain template. -#[docify::export_content] -pub const PARACHAIN_ID: u32 = 1000; - -/// Generate the session keys from individual elements. -/// -/// The input must be a tuple of individual keys (a single arg for now since we have just one key). -pub fn template_session_keys(keys: AuraId) -> SessionKeys { - SessionKeys { aura: keys } -} - -fn testnet_genesis( - invulnerables: Vec<(AccountId, AuraId)>, - endowed_accounts: Vec, - root: AccountId, - id: ParaId, -) -> Value { - build_struct_json_patch!(RuntimeGenesisConfig { - balances: BalancesConfig { - balances: endowed_accounts - .iter() - .cloned() - .map(|k| (k, 1u128 << 60)) - .collect::>(), - }, - parachain_info: ParachainInfoConfig { parachain_id: id }, - collator_selection: CollatorSelectionConfig { - invulnerables: invulnerables - .iter() - .cloned() - .map(|(acc, _)| acc) - .collect::>(), - candidacy_bond: EXISTENTIAL_DEPOSIT * 16, - }, - session: SessionConfig { - keys: invulnerables - .into_iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc, // validator id - template_session_keys(aura), // session keys - ) - }) - .collect::>(), - }, - polkadot_xcm: PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION) - }, - sudo: SudoConfig { key: Some(root) }, - }) -} - -fn local_testnet_genesis() -> Value { - testnet_genesis( - // initial collators. - vec![ - ( - Sr25519Keyring::Alice.to_account_id(), - Sr25519Keyring::Alice.public().into(), - ), - ( - Sr25519Keyring::Bob.to_account_id(), - Sr25519Keyring::Bob.public().into(), - ), - ], - Sr25519Keyring::well_known() - .map(|k| k.to_account_id()) - .collect(), - Sr25519Keyring::Alice.to_account_id(), - PARACHAIN_ID.into(), - ) -} - -fn development_config_genesis() -> Value { - testnet_genesis( - // initial collators. - vec![ - ( - Sr25519Keyring::Alice.to_account_id(), - Sr25519Keyring::Alice.public().into(), - ), - ( - Sr25519Keyring::Bob.to_account_id(), - Sr25519Keyring::Bob.public().into(), - ), - ], - Sr25519Keyring::well_known() - .map(|k| k.to_account_id()) - .collect(), - Sr25519Keyring::Alice.to_account_id(), - PARACHAIN_ID.into(), - ) -} - -/// Provides the JSON representation of predefined genesis config for given `id`. -pub fn get_preset(id: &PresetId) -> Option> { - let patch = match id.as_ref() { - sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => local_testnet_genesis(), - sp_genesis_builder::DEV_RUNTIME_PRESET => development_config_genesis(), - _ => return None, - }; - Some( - serde_json::to_string(&patch) - .expect("serialization to json is expected to work. qed.") - .into_bytes(), - ) -} - -/// List of supported presets. -pub fn preset_names() -> Vec { - vec![ - PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET), - PresetId::from(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET), - ] -} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/lib.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/lib.rs deleted file mode 100644 index 0d943404e..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/lib.rs +++ /dev/null @@ -1,331 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] -// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. -#![recursion_limit = "256"] - -// Make the WASM binary available. -#[cfg(feature = "std")] -include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); - -pub mod apis; -#[cfg(feature = "runtime-benchmarks")] -mod benchmarks; -pub mod configs; -mod genesis_config_presets; -mod weights; - -extern crate alloc; -use alloc::vec::Vec; -use smallvec::smallvec; - -use polkadot_sdk::{staging_parachain_info as parachain_info, *}; - -use sp_runtime::{ - generic, impl_opaque_keys, - traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiSignature, -}; - -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; - -use frame_support::weights::{ - constants::WEIGHT_REF_TIME_PER_SECOND, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, - WeightToFeePolynomial, -}; -pub use genesis_config_presets::PARACHAIN_ID; -pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -pub use sp_runtime::{MultiAddress, Perbill, Permill}; - -use weights::ExtrinsicBaseWeight; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - -/// Balance of an account. -pub type Balance = u128; - -/// Index of a transaction in the chain. -pub type Nonce = u32; - -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; - -/// An index to a block. -pub type BlockNumber = u32; - -/// The address format for describing accounts. -pub type Address = MultiAddress; - -/// Block header type as expected by this runtime. -pub type Header = generic::Header; - -/// Block type as expected by this runtime. -pub type Block = generic::Block; - -/// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; - -/// BlockId type as expected by this runtime. -pub type BlockId = generic::BlockId; - -/// The extension to the basic transaction logic. -#[docify::export(template_signed_extra)] -pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim< - Runtime, - ( - frame_system::CheckNonZeroSender, - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, - frame_metadata_hash_extension::CheckMetadataHash, - ), ->; - -/// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic; - -/// All migrations of the runtime, aside from the ones declared in the pallets. -/// -/// This can be a tuple of types, each implementing `OnRuntimeUpgrade`. -#[allow(unused_parens)] -type Migrations = (); - -/// Executive: handles dispatch to the various modules. -pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, - Migrations, ->; - -/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the -/// node's balance type. -/// -/// This should typically create a mapping between the following ranges: -/// - `[0, MAXIMUM_BLOCK_WEIGHT]` -/// - `[Balance::min, Balance::max]` -/// -/// Yet, it can be used for any other sort of change to weight-fee. Some examples being: -/// - Setting it to `0` will essentially disable the weight fee. -/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. -pub struct WeightToFee; -impl WeightToFeePolynomial for WeightToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - // in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1 MILLI_UNIT: - // in our template, we map to 1/10 of that, or 1/10 MILLI_UNIT - let p = MILLI_UNIT / 10; - let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); - smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), - coeff_integer: p / q, - }] - } -} - -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. -pub mod opaque { - use super::*; - pub use polkadot_sdk::sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - use polkadot_sdk::sp_runtime::{ - generic, - traits::{BlakeTwo256, Hash as HashT}, - }; - - /// Opaque block header type. - pub type Header = generic::Header; - /// Opaque block type. - pub type Block = generic::Block; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId; - /// Opaque block hash type. - pub type Hash = ::Output; -} - -impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - } -} - -#[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: alloc::borrow::Cow::Borrowed("parachain-template-runtime"), - impl_name: alloc::borrow::Cow::Borrowed("parachain-template-runtime"), - authoring_version: 1, - spec_version: 1, - impl_version: 0, - apis: apis::RUNTIME_API_VERSIONS, - transaction_version: 1, - system_version: 1, -}; - -#[docify::export] -mod block_times { - /// This determines the average expected block time that we are targeting. Blocks will be - /// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by - /// `pallet_timestamp` which is in turn picked up by `pallet_aura` to implement `fn - /// slot_duration()`. - /// - /// Change this to adjust the block time. - pub const MILLI_SECS_PER_BLOCK: u64 = 6000; - - // NOTE: Currently it is not possible to change the slot duration after the chain has started. - // Attempting to do so will brick block production. - pub const SLOT_DURATION: u64 = MILLI_SECS_PER_BLOCK; -} -pub use block_times::*; - -// Time is measured by number of blocks. -pub const MINUTES: BlockNumber = 60_000 / (MILLI_SECS_PER_BLOCK as BlockNumber); -pub const HOURS: BlockNumber = MINUTES * 60; -pub const DAYS: BlockNumber = HOURS * 24; - -// Unit = the base number of indivisible units for balances -pub const UNIT: Balance = 1_000_000_000_000; -pub const MILLI_UNIT: Balance = 1_000_000_000; -pub const MICRO_UNIT: Balance = 1_000_000; - -/// The existential deposit. Set to 1/10 of the Connected Relay Chain. -pub const EXISTENTIAL_DEPOSIT: Balance = MILLI_UNIT; - -/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is -/// used to limit the maximal weight of a single extrinsic. -const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); - -/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by -/// `Operational` extrinsics. -const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); - -#[docify::export(max_block_weight)] -/// We allow for 2 seconds of compute with a 6 second average block time. -const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( - WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), - cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64, -); - -#[docify::export] -mod async_backing_params { - /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included - /// into the relay chain. - pub(crate) const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3; - /// How many parachain blocks are processed by the relay chain per parent. Limits the - /// number of blocks authored per slot. - pub(crate) const BLOCK_PROCESSING_VELOCITY: u32 = 1; - /// Relay chain slot duration, in milliseconds. - pub(crate) const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; -} -pub(crate) use async_backing_params::*; - -#[docify::export] -/// Aura consensus hook -type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook< - Runtime, - RELAY_CHAIN_SLOT_DURATION_MILLIS, - BLOCK_PROCESSING_VELOCITY, - UNINCLUDED_SEGMENT_CAPACITY, ->; - -/// The version information used to identify this runtime when compiled natively. -#[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { - runtime_version: VERSION, - can_author_with: Default::default(), - } -} - -// Create the runtime by composing the FRAME pallets that were previously configured. -#[frame_support::runtime] -mod runtime { - #[runtime::runtime] - #[runtime::derive( - RuntimeCall, - RuntimeEvent, - RuntimeError, - RuntimeOrigin, - RuntimeFreezeReason, - RuntimeHoldReason, - RuntimeSlashReason, - RuntimeLockId, - RuntimeTask, - RuntimeViewFunction - )] - pub struct Runtime; - - #[runtime::pallet_index(0)] - pub type System = frame_system; - #[runtime::pallet_index(1)] - pub type ParachainSystem = cumulus_pallet_parachain_system; - #[runtime::pallet_index(2)] - pub type Timestamp = pallet_timestamp; - #[runtime::pallet_index(3)] - pub type ParachainInfo = parachain_info; - #[runtime::pallet_index(4)] - pub type WeightReclaim = cumulus_pallet_weight_reclaim; - - // Monetary stuff. - #[runtime::pallet_index(10)] - pub type Balances = pallet_balances; - #[runtime::pallet_index(11)] - pub type TransactionPayment = pallet_transaction_payment; - - // Governance - #[runtime::pallet_index(15)] - pub type Sudo = pallet_sudo; - - // Collator support. The order of these 4 are important and shall not change. - #[runtime::pallet_index(20)] - pub type Authorship = pallet_authorship; - #[runtime::pallet_index(21)] - pub type CollatorSelection = pallet_collator_selection; - #[runtime::pallet_index(22)] - pub type Session = pallet_session; - #[runtime::pallet_index(23)] - pub type Aura = pallet_aura; - #[runtime::pallet_index(24)] - pub type AuraExt = cumulus_pallet_aura_ext; - - // XCM helpers. - #[runtime::pallet_index(30)] - pub type XcmpQueue = cumulus_pallet_xcmp_queue; - #[runtime::pallet_index(31)] - pub type PolkadotXcm = pallet_xcm; - #[runtime::pallet_index(32)] - pub type CumulusXcm = cumulus_pallet_xcm; - #[runtime::pallet_index(33)] - pub type MessageQueue = pallet_message_queue; - - // Template - #[runtime::pallet_index(50)] - pub type TemplatePallet = pallet_parachain_template; - - #[runtime::pallet_index(51)] - pub type Utility = pallet_utility; - - #[runtime::pallet_index(52)] - pub type CustomPallet = custom_pallet; -} - -#[docify::export(register_validate_block)] -cumulus_pallet_parachain_system::register_validate_block! { - Runtime = Runtime, - BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, -} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/block_weights.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/block_weights.rs deleted file mode 100644 index d38703407..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/block_weights.rs +++ /dev/null @@ -1,57 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub mod constants { - use polkadot_sdk::*; - - use frame_support::{ - parameter_types, - weights::{constants, Weight}, - }; - - parameter_types! { - /// Importing a block with 0 Extrinsics. - pub const BlockExecutionWeight: Weight = - Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000), 0); - } - - #[cfg(test)] - mod test_weights { - use polkadot_sdk::*; - - use frame_support::weights::constants; - - /// Checks that the weight exists and is sane. - // NOTE: If this test fails but you are sure that the generated values are fine, - // you can delete it. - #[test] - fn sane() { - let w = super::constants::BlockExecutionWeight::get(); - - // At least 100 µs. - assert!( - w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS, - "Weight should be at least 100 µs." - ); - // At most 50 ms. - assert!( - w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, - "Weight should be at most 50 ms." - ); - } - } -} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/extrinsic_weights.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/extrinsic_weights.rs deleted file mode 100644 index 685a20af6..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/extrinsic_weights.rs +++ /dev/null @@ -1,57 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub mod constants { - use polkadot_sdk::*; - - use frame_support::{ - parameter_types, - weights::{constants, Weight}, - }; - - parameter_types! { - /// Executing a NO-OP `System::remarks` Extrinsic. - pub const ExtrinsicBaseWeight: Weight = - Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000), 0); - } - - #[cfg(test)] - mod test_weights { - use polkadot_sdk::*; - - use frame_support::weights::constants; - - /// Checks that the weight exists and is sane. - // NOTE: If this test fails but you are sure that the generated values are fine, - // you can delete it. - #[test] - fn sane() { - let w = super::constants::ExtrinsicBaseWeight::get(); - - // At least 10 µs. - assert!( - w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, - "Weight should be at least 10 µs." - ); - // At most 1 ms. - assert!( - w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, - "Weight should be at most 1 ms." - ); - } - } -} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/mod.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/mod.rs deleted file mode 100644 index b473d49e2..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Expose the auto generated weight files. - -pub mod block_weights; -pub mod extrinsic_weights; -pub mod paritydb_weights; -pub mod rocksdb_weights; - -pub use block_weights::constants::BlockExecutionWeight; -pub use extrinsic_weights::constants::ExtrinsicBaseWeight; -pub use rocksdb_weights::constants::RocksDbWeight; diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/paritydb_weights.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/paritydb_weights.rs deleted file mode 100644 index d97a2752b..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/paritydb_weights.rs +++ /dev/null @@ -1,67 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub mod constants { - use polkadot_sdk::*; - - use frame_support::{ - parameter_types, - weights::{constants, RuntimeDbWeight}, - }; - - parameter_types! { - /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights - /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, - write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, - }; - } - - #[cfg(test)] - mod test_db_weights { - use polkadot_sdk::*; - - use super::constants::ParityDbWeight as W; - use frame_support::weights::constants; - - /// Checks that all weights exist and have sane values. - // NOTE: If this test fails but you are sure that the generated values are fine, - // you can delete it. - #[test] - fn sane() { - // At least 1 µs. - assert!( - W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, - "Read weight should be at least 1 µs." - ); - assert!( - W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, - "Write weight should be at least 1 µs." - ); - // At most 1 ms. - assert!( - W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, - "Read weight should be at most 1 ms." - ); - assert!( - W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, - "Write weight should be at most 1 ms." - ); - } - } -} diff --git a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/rocksdb_weights.rs b/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/rocksdb_weights.rs deleted file mode 100644 index 2c7c73107..000000000 --- a/.snippets/code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/weights/rocksdb_weights.rs +++ /dev/null @@ -1,67 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub mod constants { - use polkadot_sdk::*; - - use frame_support::{ - parameter_types, - weights::{constants, RuntimeDbWeight}, - }; - - parameter_types! { - /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout - /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, - write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, - }; - } - - #[cfg(test)] - mod test_db_weights { - use polkadot_sdk::*; - - use super::constants::RocksDbWeight as W; - use frame_support::weights::constants; - - /// Checks that all weights exist and have sane values. - // NOTE: If this test fails but you are sure that the generated values are fine, - // you can delete it. - #[test] - fn sane() { - // At least 1 µs. - assert!( - W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, - "Read weight should be at least 1 µs." - ); - assert!( - W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, - "Write weight should be at least 1 µs." - ); - // At most 1 ms. - assert!( - W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, - "Read weight should be at most 1 ms." - ); - assert!( - W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, - "Write weight should be at most 1 ms." - ); - } - } -} diff --git a/parachains/customize-runtime/pallet-development/add-pallet-to-runtime.md b/parachains/customize-runtime/pallet-development/add-pallet-to-runtime.md deleted file mode 100644 index 3aa7939c6..000000000 --- a/parachains/customize-runtime/pallet-development/add-pallet-to-runtime.md +++ /dev/null @@ -1,170 +0,0 @@ ---- -title: Add Pallets to the Runtime -description: Add pallets to your runtime for custom functionality. Learn to configure and integrate pallets in Polkadot SDK-based blockchains. -tutorial_badge: Beginner -categories: Basics, Parachains ---- - -# Add Pallets to the Runtime - -## Introduction - -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. - -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. - -## Add the Pallets as Dependencies - -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: - -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: - - ```toml hl_lines="4" title="runtime/Cargo.toml" - --8<-- 'https://raw.githubusercontent.com/papermoonio/zero-to-hero-tutorial/refs/heads/v0.0.4-complete-tutorial/runtime/Cargo.toml:19:19' - ... - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/Cargo.toml:26:27' - ... - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/Cargo.toml:55:55' - ``` - -2. In the same `[dependencies]` section, add the custom pallet that you built from scratch with the following line: - - ```toml hl_lines="3" title="Cargo.toml" - --8<-- 'https://raw.githubusercontent.com/papermoonio/zero-to-hero-tutorial/refs/heads/v0.0.4-complete-tutorial/runtime/Cargo.toml:19:19' - ... - --8<-- 'https://raw.githubusercontent.com/papermoonio/zero-to-hero-tutorial/refs/heads/v0.0.4-complete-tutorial/runtime/Cargo.toml:30:30' - ``` - -3. In the `[features]` section, add the custom pallet to the `std` feature list: - - ```toml hl_lines="5" title="Cargo.toml" - --8<-- 'https://raw.githubusercontent.com/papermoonio/zero-to-hero-tutorial/refs/heads/v0.0.4-complete-tutorial/runtime/Cargo.toml:32:34' - ... - --8<-- 'https://raw.githubusercontent.com/papermoonio/zero-to-hero-tutorial/refs/heads/v0.0.4-complete-tutorial/runtime/Cargo.toml:43:43' - ... - ] - ``` - -3. Save the changes and close the `Cargo.toml` file. - - Once you have saved your file, it should look like the following: - - ???- code "runtime/Cargo.toml" - - ```rust title="runtime/Cargo.toml" - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/Cargo.toml' - ``` - -Update your root parachain template's `Cargo.toml` file to include your custom pallet as a dependency. Follow these steps: - -1. Open the `./Cargo.toml` file and locate the `[workspace]` section. - - Make sure the `custom-pallet` is a member of the workspace: - - ```toml hl_lines="4" title="Cargo.toml" - --8<-- 'https://raw.githubusercontent.com/papermoonio/zero-to-hero-tutorial/refs/heads/v0.0.4-complete-tutorial/Cargo.toml:8:14' - ``` - -???- code "./Cargo.toml" - - ```rust title="./Cargo.toml" - --8<-- 'https://raw.githubusercontent.com/papermoonio/zero-to-hero-tutorial/refs/heads/v0.0.4-complete-tutorial/Cargo.toml' - ``` - - -### Update the Runtime Configuration - -Configure the pallets by implementing their `Config` trait and update the runtime macro to include the new pallets: - -1. Add the `OriginCaller` import: - - ```rust title="mod.rs" hl_lines="8" - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/mod.rs:59:60' - ... - ``` - -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: - - ```rust title="mod.rs" hl_lines="8-25" - ... - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/mod.rs:320:332' - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/configs/mod.rs:334:342' - } - ``` - -3. Locate the `#[frame_support::runtime]` macro in the `runtime/src/lib.rs` file and add the pallets: - - ```rust hl_lines="9-14" title="lib.rs" - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/lib.rs:256:259' - ... - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/lib.rs:270:271' - - --8<-- 'code/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/src/lib.rs:320:324' - } - ``` - -## Recompile the Runtime - -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): - -```bash -cargo build --release -``` - -This command ensures the runtime compiles without errors, validates the pallet configurations, and prepares the build for subsequent testing or deployment. - -## Run Your Chain Locally - -Launch your parachain locally and start producing blocks: - -!!!tip - 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. - -1. Create a new chain specification file with the updated runtime: - - ```bash - chain-spec-builder create -t development \ - --relay-chain paseo \ - --para-id 1000 \ - --runtime ./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm \ - named-preset development - ``` - -2. Start the omni node with the generated chain specification: - - ```bash - polkadot-omni-node --chain ./chain_spec.json --dev - ``` - -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: - - - Utility pallet - - ![](/images/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/add-pallets-to-runtime-01.webp) - - - - Custom pallet - - ![](/images/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/add-pallets-to-runtime-02.webp) - -## Where to Go Next - -
- -- Tutorial __Deploy on Paseo TestNet__ - - --- - - Deploy your Polkadot SDK blockchain on Paseo! Follow this step-by-step guide for a seamless journey to a successful TestNet deployment. - - [:octicons-arrow-right-24: Get Started](/tutorials/polkadot-sdk/parachains/zero-to-hero/deploy-to-testnet/) - -- Tutorial __Pallet Benchmarking (Optional)__ - - --- - - Discover how to measure extrinsic costs and assign precise weights to optimize your pallet for accurate fees and runtime performance. - - [:octicons-arrow-right-24: Get Started](/tutorials/polkadot-sdk/parachains/zero-to-hero/pallet-benchmarking/) - -
From aef21f14952dfa6f13b287439fe359f5364a9fff Mon Sep 17 00:00:00 2001 From: Bruno Galvao Date: Wed, 12 Nov 2025 09:43:33 +0700 Subject: [PATCH 04/10] 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 --- .../pallet-development/pallet-testing.md | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/parachains/customize-runtime/pallet-development/pallet-testing.md b/parachains/customize-runtime/pallet-development/pallet-testing.md index c9780a55e..2f909cbd5 100644 --- a/parachains/customize-runtime/pallet-development/pallet-testing.md +++ b/parachains/customize-runtime/pallet-development/pallet-testing.md @@ -34,9 +34,9 @@ FRAME provides specialized testing macros and utilities that make pallet testing ### Assertion Macros -- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds -- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation) -- **`assert_eq!`** - Standard Rust equality assertion +- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds. +- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation). +- **`assert_eq!`** - Standard Rust equality assertion. !!!info "`assert_noop!` Explained" Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified. @@ -45,18 +45,18 @@ FRAME provides specialized testing macros and utilities that make pallet testing The [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\_blank} pallet provides useful methods for testing: -- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test -- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations -- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number +- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test. +- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations. +- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number. -!!!warning "Events and Block Number" +!!!info "Events and Block Number" Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`. ### Origin Types -- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations -- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account -- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations) +- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations. +- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account. +- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations). Learn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\_blank}. @@ -78,7 +78,7 @@ Create a new file for your tests within the pallet directory: 3. Open `src/lib.rs` and add the tests module declaration after the mock module: - ```rust + ```rust title="src/lib.rs" #![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; @@ -117,6 +117,8 @@ Let's start with a simple test to verify the increment function works correctly. ### Test Basic Increment +Test that the increment function increases counter value and emits events. + ```rust #[test] fn increment_works() { @@ -167,6 +169,8 @@ Now let's test that our pallet correctly handles errors. Error testing is crucia ### Test Overflow Protection +Test that incrementing at u32::MAX fails with Overflow error. + ```rust #[test] fn increment_fails_on_overflow() { @@ -188,6 +192,8 @@ cargo test --package pallet-custom increment_fails_on_overflow ### Test Underflow Protection +Test that decrementing below zero fails with Underflow error. + ```rust #[test] fn decrement_fails_on_underflow() { @@ -213,6 +219,8 @@ Verify that origin checks work correctly and unauthorized access is prevented. ### Test Root-Only Access +Test that set_counter_value requires root origin and rejects signed origins. + ```rust #[test] fn set_counter_value_requires_root() { @@ -252,6 +260,8 @@ The `increment_works` test (shown earlier) already demonstrates event testing by This pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function: +Test that set_counter_value updates storage and emits correct event. + ```rust #[test] fn set_counter_value_works() { @@ -281,6 +291,8 @@ Verify that genesis configuration works correctly. ### Test Genesis Setup +Test that genesis configuration correctly initializes counter and user interactions. + ```rust #[test] fn genesis_config_works() { From 14e698b7d40086d663f930bc56870a3d6dbbbadf Mon Sep 17 00:00:00 2001 From: Bruno Galvao Date: Wed, 12 Nov 2025 09:49:03 +0700 Subject: [PATCH 05/10] 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 --- .ai/categories/parachains.md | 60 ++++++++++--------- ...ntime-pallet-development-pallet-testing.md | 42 +++++++++---- ...chains-zero-to-hero-pallet-benchmarking.md | 18 +----- .ai/site-index.json | 16 ++--- llms-full.jsonl | 46 +++++++------- .../pallet-development/pallet-testing.md | 8 +++ 6 files changed, 103 insertions(+), 87 deletions(-) diff --git a/.ai/categories/parachains.md b/.ai/categories/parachains.md index 4065583a4..4eac1106e 100644 --- a/.ai/categories/parachains.md +++ b/.ai/categories/parachains.md @@ -12235,18 +12235,7 @@ Follow these steps to prepare your environment for pallet benchmarking: 1. Register your pallet in `runtime/src/benchmarks.rs`: ```rust hl_lines="11" title="benchmarks.rs" - polkadot_sdk::frame_benchmarking::define_benchmarks!( - [frame_system, SystemBench::] - [pallet_balances, Balances] - [pallet_session, SessionBench::] - [pallet_timestamp, Timestamp] - [pallet_message_queue, MessageQueue] - [pallet_sudo, Sudo] - [pallet_collator_selection, CollatorSelection] - [cumulus_pallet_parachain_system, ParachainSystem] - [cumulus_pallet_xcmp_queue, XcmpQueue] - [custom_pallet, CustomPallet] - ); + ``` 2. Enable runtime benchmarking for your pallet in `runtime/Cargo.toml`: @@ -12496,11 +12485,6 @@ Finally, configure the actual weight values in your production runtime. In `runt ```rust hl_lines="5" title="mod.rs" -// Define counter max value runtime constant. -parameter_types! { - pub const CounterMaxValue: u32 = 500; -} - ``` Your pallet is now complete with full testing and benchmarking support, ready for production use. @@ -12558,9 +12542,9 @@ FRAME provides specialized testing macros and utilities that make pallet testing ### Assertion Macros -- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds -- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation) -- **`assert_eq!`** - Standard Rust equality assertion +- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds. +- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation). +- **`assert_eq!`** - Standard Rust equality assertion. !!!info "`assert_noop!` Explained" Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified. @@ -12569,18 +12553,18 @@ FRAME provides specialized testing macros and utilities that make pallet testing The [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\_blank} pallet provides useful methods for testing: -- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test -- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations -- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number +- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test. +- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations. +- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number. -!!!warning "Events and Block Number" +!!!info "Events and Block Number" Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`. ### Origin Types -- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations -- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account -- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations) +- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations. +- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account. +- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations). Learn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\_blank}. @@ -12602,7 +12586,7 @@ Create a new file for your tests within the pallet directory: 3. Open `src/lib.rs` and add the tests module declaration after the mock module: - ```rust + ```rust title="src/lib.rs" #![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; @@ -12630,17 +12614,27 @@ use frame::deps::sp_runtime::DispatchError; ``` This setup imports: + - The mock runtime and test utilities from `mock.rs` - Your pallet's `Error` and `Event` types - FRAME's assertion macros via `frame::deps` - `DispatchError` for testing origin checks +???+ code "Complete Pallet Code Reference" + Here's the complete pallet code that you'll be testing throughout this guide: + + ```rust + + ``` + ## Write Your First Test Let's start with a simple test to verify the increment function works correctly. ### Test Basic Increment +Test that the increment function increases counter value and emits events. + ```rust #[test] fn increment_works() { @@ -12691,6 +12685,8 @@ Now let's test that our pallet correctly handles errors. Error testing is crucia ### Test Overflow Protection +Test that incrementing at u32::MAX fails with Overflow error. + ```rust #[test] fn increment_fails_on_overflow() { @@ -12712,6 +12708,8 @@ cargo test --package pallet-custom increment_fails_on_overflow ### Test Underflow Protection +Test that decrementing below zero fails with Underflow error. + ```rust #[test] fn decrement_fails_on_underflow() { @@ -12737,6 +12735,8 @@ Verify that origin checks work correctly and unauthorized access is prevented. ### Test Root-Only Access +Test that set_counter_value requires root origin and rejects signed origins. + ```rust #[test] fn set_counter_value_requires_root() { @@ -12776,6 +12776,8 @@ The `increment_works` test (shown earlier) already demonstrates event testing by This pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function: +Test that set_counter_value updates storage and emits correct event. + ```rust #[test] fn set_counter_value_works() { @@ -12805,6 +12807,8 @@ Verify that genesis configuration works correctly. ### Test Genesis Setup +Test that genesis configuration correctly initializes counter and user interactions. + ```rust #[test] fn genesis_config_works() { diff --git a/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md b/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md index ecbf5ebc1..329c62040 100644 --- a/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md +++ b/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md @@ -35,9 +35,9 @@ FRAME provides specialized testing macros and utilities that make pallet testing ### Assertion Macros -- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds -- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation) -- **`assert_eq!`** - Standard Rust equality assertion +- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds. +- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation). +- **`assert_eq!`** - Standard Rust equality assertion. !!!info "`assert_noop!` Explained" Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified. @@ -46,18 +46,18 @@ FRAME provides specialized testing macros and utilities that make pallet testing The [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\_blank} pallet provides useful methods for testing: -- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test -- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations -- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number +- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\_blank}** - Returns all events emitted during the test. +- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\_blank}** - Asserts the last event matches expectations. +- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\_blank}** - Sets the current block number. -!!!warning "Events and Block Number" +!!!info "Events and Block Number" Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`. ### Origin Types -- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations -- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account -- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations) +- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\_blank}** - Root/sudo origin for privileged operations. +- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\_blank}** - Signed origin from a specific account. +- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\_blank}** - No origin (typically fails for most operations). Learn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\_blank}. @@ -79,7 +79,7 @@ Create a new file for your tests within the pallet directory: 3. Open `src/lib.rs` and add the tests module declaration after the mock module: - ```rust + ```rust title="src/lib.rs" #![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; @@ -107,17 +107,27 @@ use frame::deps::sp_runtime::DispatchError; ``` This setup imports: + - The mock runtime and test utilities from `mock.rs` - Your pallet's `Error` and `Event` types - FRAME's assertion macros via `frame::deps` - `DispatchError` for testing origin checks +???+ code "Complete Pallet Code Reference" + Here's the complete pallet code that you'll be testing throughout this guide: + + ```rust + + ``` + ## Write Your First Test Let's start with a simple test to verify the increment function works correctly. ### Test Basic Increment +Test that the increment function increases counter value and emits events. + ```rust #[test] fn increment_works() { @@ -168,6 +178,8 @@ Now let's test that our pallet correctly handles errors. Error testing is crucia ### Test Overflow Protection +Test that incrementing at u32::MAX fails with Overflow error. + ```rust #[test] fn increment_fails_on_overflow() { @@ -189,6 +201,8 @@ cargo test --package pallet-custom increment_fails_on_overflow ### Test Underflow Protection +Test that decrementing below zero fails with Underflow error. + ```rust #[test] fn decrement_fails_on_underflow() { @@ -214,6 +228,8 @@ Verify that origin checks work correctly and unauthorized access is prevented. ### Test Root-Only Access +Test that set_counter_value requires root origin and rejects signed origins. + ```rust #[test] fn set_counter_value_requires_root() { @@ -253,6 +269,8 @@ The `increment_works` test (shown earlier) already demonstrates event testing by This pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function: +Test that set_counter_value updates storage and emits correct event. + ```rust #[test] fn set_counter_value_works() { @@ -282,6 +300,8 @@ Verify that genesis configuration works correctly. ### Test Genesis Setup +Test that genesis configuration correctly initializes counter and user interactions. + ```rust #[test] fn genesis_config_works() { diff --git a/.ai/pages/tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking.md b/.ai/pages/tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking.md index a025d4c47..c68c49bda 100644 --- a/.ai/pages/tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking.md +++ b/.ai/pages/tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking.md @@ -46,18 +46,7 @@ Follow these steps to prepare your environment for pallet benchmarking: 1. Register your pallet in `runtime/src/benchmarks.rs`: ```rust hl_lines="11" title="benchmarks.rs" - polkadot_sdk::frame_benchmarking::define_benchmarks!( - [frame_system, SystemBench::] - [pallet_balances, Balances] - [pallet_session, SessionBench::] - [pallet_timestamp, Timestamp] - [pallet_message_queue, MessageQueue] - [pallet_sudo, Sudo] - [pallet_collator_selection, CollatorSelection] - [cumulus_pallet_parachain_system, ParachainSystem] - [cumulus_pallet_xcmp_queue, XcmpQueue] - [custom_pallet, CustomPallet] - ); + ``` 2. Enable runtime benchmarking for your pallet in `runtime/Cargo.toml`: @@ -307,11 +296,6 @@ Finally, configure the actual weight values in your production runtime. In `runt ```rust hl_lines="5" title="mod.rs" -// Define counter max value runtime constant. -parameter_types! { - pub const CounterMaxValue: u32 = 500; -} - ``` Your pallet is now complete with full testing and benchmarking support, ready for production use. diff --git a/.ai/site-index.json b/.ai/site-index.json index c233e6f8a..78f11ae23 100644 --- a/.ai/site-index.json +++ b/.ai/site-index.json @@ -5201,12 +5201,12 @@ } ], "stats": { - "chars": 19551, - "words": 2005, + "chars": 20165, + "words": 2088, "headings": 21, - "estimated_token_count_total": 4375 + "estimated_token_count_total": 4495 }, - "hash": "sha256:bf3908c112578ce4811bb0a4742af45ecbdd24acd0c3380f6b763b70e855fca5", + "hash": "sha256:d61a71c863db6badccac283198b01add19703bb69706666c7a43c4ce18c98601", "token_estimator": "heuristic-v1" }, { @@ -12703,12 +12703,12 @@ } ], "stats": { - "chars": 12857, - "words": 1539, + "chars": 12200, + "words": 1502, "headings": 6, - "estimated_token_count_total": 2929 + "estimated_token_count_total": 2837 }, - "hash": "sha256:df60044893f48dd7f37a11de275a16bf32adb31317ed70a789fd7fac64150e1a", + "hash": "sha256:ad43951deac53a539a3d8a2317500aec351aa7e85f3cc49b386aa30baf6bcc09", "token_estimator": "heuristic-v1" }, { diff --git a/llms-full.jsonl b/llms-full.jsonl index bef900658..088a4d6bc 100644 --- a/llms-full.jsonl +++ b/llms-full.jsonl @@ -606,24 +606,24 @@ {"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 23, "end_char": 614, "estimated_token_count": 104, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nUnit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation.\n\nIn this guide, you'll learn how to:\n\n- Structure test modules effectively\n- Test dispatchable functions\n- Verify storage changes\n- Check event emission\n- Test error conditions\n- Use genesis configurations in tests"} {"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 614, "end_char": 1069, "estimated_token_count": 119, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have:\n\n- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide\n- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide\n- The custom counter pallet with mock runtime in `pallets/pallet-custom`\n- Basic understanding of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\\_blank}"} {"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 2, "depth": 2, "title": "Understanding FRAME Testing Tools", "anchor": "understanding-frame-testing-tools", "start_char": 1069, "end_char": 1205, "estimated_token_count": 20, "token_estimator": "heuristic-v1", "text": "## Understanding FRAME Testing Tools\n\nFRAME provides specialized testing macros and utilities that make pallet testing more efficient:"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 3, "depth": 3, "title": "Assertion Macros", "anchor": "assertion-macros", "start_char": 1205, "end_char": 1877, "estimated_token_count": 171, "token_estimator": "heuristic-v1", "text": "### Assertion Macros\n\n- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\\_blank}** - Asserts that a dispatchable call succeeds\n- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\\_blank}** - Asserts that a call fails without changing state (no operation)\n- **`assert_eq!`** - Standard Rust equality assertion\n\n!!!info \"`assert_noop!` Explained\"\n Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 4, "depth": 3, "title": "System Pallet Test Helpers", "anchor": "system-pallet-test-helpers", "start_char": 1877, "end_char": 2873, "estimated_token_count": 276, "token_estimator": "heuristic-v1", "text": "### System Pallet Test Helpers\n\nThe [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\\_blank} pallet provides useful methods for testing:\n\n- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\\_blank}** - Returns all events emitted during the test\n- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\\_blank}** - Asserts the last event matches expectations\n- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\\_blank}** - Sets the current block number\n\n!!!warning \"Events and Block Number\"\n Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 5, "depth": 3, "title": "Origin Types", "anchor": "origin-types", "start_char": 2873, "end_char": 3661, "estimated_token_count": 227, "token_estimator": "heuristic-v1", "text": "### Origin Types\n\n- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\\_blank}** - Root/sudo origin for privileged operations\n- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\\_blank}** - Signed origin from a specific account\n- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\\_blank}** - No origin (typically fails for most operations)\n\nLearn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\\_blank}."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 6, "depth": 2, "title": "Create the Tests Module", "anchor": "create-the-tests-module", "start_char": 3661, "end_char": 4249, "estimated_token_count": 157, "token_estimator": "heuristic-v1", "text": "## Create the Tests Module\n\nCreate a new file for your tests within the pallet directory:\n\n1. Navigate to your pallet directory:\n\n ```bash\n cd pallets/pallet-custom/src\n ```\n\n2. Create a new file named `tests.rs`:\n\n ```bash\n touch tests.rs\n ```\n\n3. Open `src/lib.rs` and add the tests module declaration after the mock module:\n\n ```rust\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n\n #[frame::pallet]\n pub mod pallet {\n // ... existing pallet code\n }\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 7, "depth": 2, "title": "Set Up the Test Module", "anchor": "set-up-the-test-module", "start_char": 4249, "end_char": 4705, "estimated_token_count": 125, "token_estimator": "heuristic-v1", "text": "## Set Up the Test Module\n\nOpen `src/tests.rs` and add the basic structure with necessary imports:\n\n```rust\nuse crate::{mock::*, Error, Event};\nuse frame::deps::frame_support::{assert_noop, assert_ok};\nuse frame::deps::sp_runtime::DispatchError;\n```\n\nThis setup imports:\n- The mock runtime and test utilities from `mock.rs`\n- Your pallet's `Error` and `Event` types\n- FRAME's assertion macros via `frame::deps`\n- `DispatchError` for testing origin checks"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 8, "depth": 2, "title": "Write Your First Test", "anchor": "write-your-first-test", "start_char": 4705, "end_char": 4813, "estimated_token_count": 22, "token_estimator": "heuristic-v1", "text": "## Write Your First Test\n\nLet's start with a simple test to verify the increment function works correctly."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 9, "depth": 3, "title": "Test Basic Increment", "anchor": "test-basic-increment", "start_char": 4813, "end_char": 5817, "estimated_token_count": 227, "token_estimator": "heuristic-v1", "text": "### Test Basic Increment\n\n```rust\n#[test]\nfn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n}\n```\n\nRun your first test:\n\n```bash\ncargo test --package pallet-custom increment_works\n```\n\nYou should see:\n\n```\nrunning 1 test\ntest tests::increment_works ... ok\n```\n\n🎉 Congratulations! You've written and run your first pallet test."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 10, "depth": 2, "title": "Test Error Conditions", "anchor": "test-error-conditions", "start_char": 5817, "end_char": 5962, "estimated_token_count": 28, "token_estimator": "heuristic-v1", "text": "## Test Error Conditions\n\nNow let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 11, "depth": 3, "title": "Test Overflow Protection", "anchor": "test-overflow-protection", "start_char": 5962, "end_char": 6414, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "### Test Overflow Protection\n\n```rust\n#[test]\nfn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n}\n```\n\nTest overflow protection:\n\n```bash\ncargo test --package pallet-custom increment_fails_on_overflow\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 12, "depth": 3, "title": "Test Underflow Protection", "anchor": "test-underflow-protection", "start_char": 6414, "end_char": 6863, "estimated_token_count": 95, "token_estimator": "heuristic-v1", "text": "### Test Underflow Protection\n\n```rust\n#[test]\nfn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n}\n```\n\nVerify underflow protection:\n\n```bash\ncargo test --package pallet-custom decrement_fails_on_underflow\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 13, "depth": 2, "title": "Test Access Control", "anchor": "test-access-control", "start_char": 6863, "end_char": 6967, "estimated_token_count": 17, "token_estimator": "heuristic-v1", "text": "## Test Access Control\n\nVerify that origin checks work correctly and unauthorized access is prevented."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 14, "depth": 3, "title": "Test Root-Only Access", "anchor": "test-root-only-access", "start_char": 6967, "end_char": 7654, "estimated_token_count": 153, "token_estimator": "heuristic-v1", "text": "### Test Root-Only Access\n\n```rust\n#[test]\nfn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n\n // When: non-root user tries to set counter\n // Then: should fail with BadOrigin\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n DispatchError::BadOrigin\n );\n\n // But root should succeed\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n}\n```\n\nTest access control:\n\n```bash\ncargo test --package pallet-custom set_counter_value_requires_root\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 15, "depth": 2, "title": "Test Event Emission", "anchor": "test-event-emission", "start_char": 7654, "end_char": 7741, "estimated_token_count": 16, "token_estimator": "heuristic-v1", "text": "## Test Event Emission\n\nVerify that events are emitted correctly with the right data."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 16, "depth": 3, "title": "Test Event Data", "anchor": "test-event-data", "start_char": 7741, "end_char": 8758, "estimated_token_count": 226, "token_estimator": "heuristic-v1", "text": "### Test Event Data\n\nThe `increment_works` test (shown earlier) already demonstrates event testing by:\n1. Setting the block number to 1 to enable event emission\n2. Calling the dispatchable function\n3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data\n\nThis pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function:\n\n```rust\n#[test]\nfn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n}\n```\n\nRun the event test:\n\n```bash\ncargo test --package pallet-custom set_counter_value_works\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 17, "depth": 2, "title": "Test Genesis Configuration", "anchor": "test-genesis-configuration", "start_char": 8758, "end_char": 8841, "estimated_token_count": 12, "token_estimator": "heuristic-v1", "text": "## Test Genesis Configuration\n\nVerify that genesis configuration works correctly."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 18, "depth": 3, "title": "Test Genesis Setup", "anchor": "test-genesis-setup", "start_char": 8841, "end_char": 9374, "estimated_token_count": 149, "token_estimator": "heuristic-v1", "text": "### Test Genesis Setup\n\n```rust\n#[test]\nfn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n}\n```\n\nTest genesis configuration:\n\n```bash\ncargo test --package pallet-custom genesis_config_works\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 19, "depth": 2, "title": "Run All Tests", "anchor": "run-all-tests", "start_char": 9374, "end_char": 19201, "estimated_token_count": 2039, "token_estimator": "heuristic-v1", "text": "## Run All Tests\n\nNow run all your tests together:\n\n```bash\ncargo test --package pallet-custom\n```\n\nYou should see all tests passing:\n\n```\nrunning 15 tests\ntest mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok\ntest mock::test_genesis_config_builds ... ok\ntest tests::decrement_fails_on_underflow ... ok\ntest tests::decrement_tracks_multiple_interactions ... ok\ntest tests::decrement_works ... ok\ntest tests::different_users_tracked_separately ... ok\ntest tests::genesis_config_works ... ok\ntest tests::increment_fails_on_overflow ... ok\ntest tests::increment_respects_max_value ... ok\ntest tests::increment_tracks_multiple_interactions ... ok\ntest tests::increment_works ... ok\ntest tests::mixed_increment_and_decrement_works ... ok\ntest tests::set_counter_value_requires_root ... ok\ntest tests::set_counter_value_respects_max_value ... ok\ntest tests::set_counter_value_works ... ok\n\ntest result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out\n```\n\n!!!note \"Mock Runtime Tests\"\n You'll notice 2 additional tests from the `mock` module:\n\n - `mock::__construct_runtime_integrity_test::runtime_integrity_tests` - Auto-generated test that validates runtime construction\n - `mock::test_genesis_config_builds` - Validates that genesis configuration builds correctly\n\n These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid.\n\n🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns!\n\nThese tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality.\n\n??? code \"Full Test Suite Code\"\n Here's the complete `tests.rs` file for quick reference:\n\n ```rust\n use crate::{mock::*, Error, Event};\n use frame::deps::frame_support::{assert_noop, assert_ok};\n use frame::deps::sp_runtime::DispatchError;\n\n #[test]\n fn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n }\n\n #[test]\n fn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter with non-root origin should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(1), 100),\n DispatchError::BadOrigin\n );\n });\n }\n\n #[test]\n fn set_counter_value_respects_max_value() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter above max value (1000) should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::root(), 1001),\n Error::::CounterMaxValueExceeded\n );\n\n // Setting to exactly max value should work\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 1000));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn increment_tracks_multiple_interactions() {\n new_test_ext().execute_with(|| {\n let account = 1u64;\n\n // Increment multiple times\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 20));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 30));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 60);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n }\n\n #[test]\n fn increment_respects_max_value() {\n new_test_ext_with_counter(950).execute_with(|| {\n // Incrementing past max value (1000) should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 51),\n Error::::CounterMaxValueExceeded\n );\n\n // Incrementing to exactly max value should work\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(1), 50));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn decrement_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 2u64;\n\n // Decrement by 30\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 30));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterDecremented {\n new_value: 70,\n who: account,\n amount: 30,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n }\n\n #[test]\n fn decrement_tracks_multiple_interactions() {\n new_test_ext_with_counter(100).execute_with(|| {\n let account = 3u64;\n\n // Decrement multiple times\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 20));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 2)\n assert_eq!(crate::UserInteractions::::get(account), 2);\n });\n }\n\n #[test]\n fn mixed_increment_and_decrement_works() {\n new_test_ext_with_counter(50).execute_with(|| {\n let account = 4u64;\n\n // Mix of increment and decrement\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 25));\n assert_eq!(crate::CounterValue::::get(), 75);\n\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 15));\n assert_eq!(crate::CounterValue::::get(), 60);\n\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn different_users_tracked_separately() {\n new_test_ext().execute_with(|| {\n let account1 = 1u64;\n let account2 = 2u64;\n\n // User 1 increments\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n\n // User 2 decrements\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account2), 5));\n\n // Check counter value (10 + 10 - 5 = 15)\n assert_eq!(crate::CounterValue::::get(), 15);\n\n // Check user interactions are tracked separately\n assert_eq!(crate::UserInteractions::::get(account1), 2);\n assert_eq!(crate::UserInteractions::::get(account2), 1);\n });\n }\n\n #[test]\n fn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n }\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 19201, "end_char": 19551, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Add Your Custom Pallet to the Runtime__\n\n ---\n\n Your pallet is tested and ready! Learn how to integrate it into your runtime.\n\n [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)\n\n
"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 3, "depth": 3, "title": "Assertion Macros", "anchor": "assertion-macros", "start_char": 1205, "end_char": 1880, "estimated_token_count": 174, "token_estimator": "heuristic-v1", "text": "### Assertion Macros\n\n- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\\_blank}** - Asserts that a dispatchable call succeeds.\n- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\\_blank}** - Asserts that a call fails without changing state (no operation).\n- **`assert_eq!`** - Standard Rust equality assertion.\n\n!!!info \"`assert_noop!` Explained\"\n Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 4, "depth": 3, "title": "System Pallet Test Helpers", "anchor": "system-pallet-test-helpers", "start_char": 1880, "end_char": 2876, "estimated_token_count": 279, "token_estimator": "heuristic-v1", "text": "### System Pallet Test Helpers\n\nThe [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\\_blank} pallet provides useful methods for testing:\n\n- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\\_blank}** - Returns all events emitted during the test.\n- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\\_blank}** - Asserts the last event matches expectations.\n- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\\_blank}** - Sets the current block number.\n\n!!!info \"Events and Block Number\"\n Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 5, "depth": 3, "title": "Origin Types", "anchor": "origin-types", "start_char": 2876, "end_char": 3667, "estimated_token_count": 230, "token_estimator": "heuristic-v1", "text": "### Origin Types\n\n- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\\_blank}** - Root/sudo origin for privileged operations.\n- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\\_blank}** - Signed origin from a specific account.\n- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\\_blank}** - No origin (typically fails for most operations).\n\nLearn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\\_blank}."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 6, "depth": 2, "title": "Create the Tests Module", "anchor": "create-the-tests-module", "start_char": 3667, "end_char": 4274, "estimated_token_count": 166, "token_estimator": "heuristic-v1", "text": "## Create the Tests Module\n\nCreate a new file for your tests within the pallet directory:\n\n1. Navigate to your pallet directory:\n\n ```bash\n cd pallets/pallet-custom/src\n ```\n\n2. Create a new file named `tests.rs`:\n\n ```bash\n touch tests.rs\n ```\n\n3. Open `src/lib.rs` and add the tests module declaration after the mock module:\n\n ```rust title=\"src/lib.rs\"\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n\n #[frame::pallet]\n pub mod pallet {\n // ... existing pallet code\n }\n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 7, "depth": 2, "title": "Set Up the Test Module", "anchor": "set-up-the-test-module", "start_char": 4274, "end_char": 4883, "estimated_token_count": 160, "token_estimator": "heuristic-v1", "text": "## Set Up the Test Module\n\nOpen `src/tests.rs` and add the basic structure with necessary imports:\n\n```rust\nuse crate::{mock::*, Error, Event};\nuse frame::deps::frame_support::{assert_noop, assert_ok};\nuse frame::deps::sp_runtime::DispatchError;\n```\n\nThis setup imports:\n\n- The mock runtime and test utilities from `mock.rs`\n- Your pallet's `Error` and `Event` types\n- FRAME's assertion macros via `frame::deps`\n- `DispatchError` for testing origin checks\n\n???+ code \"Complete Pallet Code Reference\"\n Here's the complete pallet code that you'll be testing throughout this guide:\n\n ```rust\n \n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 8, "depth": 2, "title": "Write Your First Test", "anchor": "write-your-first-test", "start_char": 4883, "end_char": 4991, "estimated_token_count": 22, "token_estimator": "heuristic-v1", "text": "## Write Your First Test\n\nLet's start with a simple test to verify the increment function works correctly."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 9, "depth": 3, "title": "Test Basic Increment", "anchor": "test-basic-increment", "start_char": 4991, "end_char": 6071, "estimated_token_count": 239, "token_estimator": "heuristic-v1", "text": "### Test Basic Increment\n\nTest that the increment function increases counter value and emits events.\n\n```rust\n#[test]\nfn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n}\n```\n\nRun your first test:\n\n```bash\ncargo test --package pallet-custom increment_works\n```\n\nYou should see:\n\n```\nrunning 1 test\ntest tests::increment_works ... ok\n```\n\n🎉 Congratulations! You've written and run your first pallet test."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 10, "depth": 2, "title": "Test Error Conditions", "anchor": "test-error-conditions", "start_char": 6071, "end_char": 6216, "estimated_token_count": 28, "token_estimator": "heuristic-v1", "text": "## Test Error Conditions\n\nNow let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 11, "depth": 3, "title": "Test Overflow Protection", "anchor": "test-overflow-protection", "start_char": 6216, "end_char": 6731, "estimated_token_count": 113, "token_estimator": "heuristic-v1", "text": "### Test Overflow Protection\n\nTest that incrementing at u32::MAX fails with Overflow error.\n\n```rust\n#[test]\nfn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n}\n```\n\nTest overflow protection:\n\n```bash\ncargo test --package pallet-custom increment_fails_on_overflow\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 12, "depth": 3, "title": "Test Underflow Protection", "anchor": "test-underflow-protection", "start_char": 6731, "end_char": 7243, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "### Test Underflow Protection\n\nTest that decrementing below zero fails with Underflow error.\n\n```rust\n#[test]\nfn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n}\n```\n\nVerify underflow protection:\n\n```bash\ncargo test --package pallet-custom decrement_fails_on_underflow\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 13, "depth": 2, "title": "Test Access Control", "anchor": "test-access-control", "start_char": 7243, "end_char": 7347, "estimated_token_count": 17, "token_estimator": "heuristic-v1", "text": "## Test Access Control\n\nVerify that origin checks work correctly and unauthorized access is prevented."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 14, "depth": 3, "title": "Test Root-Only Access", "anchor": "test-root-only-access", "start_char": 7347, "end_char": 8112, "estimated_token_count": 164, "token_estimator": "heuristic-v1", "text": "### Test Root-Only Access\n\nTest that set_counter_value requires root origin and rejects signed origins.\n\n```rust\n#[test]\nfn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n\n // When: non-root user tries to set counter\n // Then: should fail with BadOrigin\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n DispatchError::BadOrigin\n );\n\n // But root should succeed\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n}\n```\n\nTest access control:\n\n```bash\ncargo test --package pallet-custom set_counter_value_requires_root\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 15, "depth": 2, "title": "Test Event Emission", "anchor": "test-event-emission", "start_char": 8112, "end_char": 8199, "estimated_token_count": 16, "token_estimator": "heuristic-v1", "text": "## Test Event Emission\n\nVerify that events are emitted correctly with the right data."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 16, "depth": 3, "title": "Test Event Data", "anchor": "test-event-data", "start_char": 8199, "end_char": 9286, "estimated_token_count": 236, "token_estimator": "heuristic-v1", "text": "### Test Event Data\n\nThe `increment_works` test (shown earlier) already demonstrates event testing by:\n1. Setting the block number to 1 to enable event emission\n2. Calling the dispatchable function\n3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data\n\nThis pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function:\n\nTest that set_counter_value updates storage and emits correct event.\n\n```rust\n#[test]\nfn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n}\n```\n\nRun the event test:\n\n```bash\ncargo test --package pallet-custom set_counter_value_works\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 17, "depth": 2, "title": "Test Genesis Configuration", "anchor": "test-genesis-configuration", "start_char": 9286, "end_char": 9369, "estimated_token_count": 12, "token_estimator": "heuristic-v1", "text": "## Test Genesis Configuration\n\nVerify that genesis configuration works correctly."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 18, "depth": 3, "title": "Test Genesis Setup", "anchor": "test-genesis-setup", "start_char": 9369, "end_char": 9988, "estimated_token_count": 160, "token_estimator": "heuristic-v1", "text": "### Test Genesis Setup\n\nTest that genesis configuration correctly initializes counter and user interactions.\n\n```rust\n#[test]\nfn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n}\n```\n\nTest genesis configuration:\n\n```bash\ncargo test --package pallet-custom genesis_config_works\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 19, "depth": 2, "title": "Run All Tests", "anchor": "run-all-tests", "start_char": 9988, "end_char": 19815, "estimated_token_count": 2039, "token_estimator": "heuristic-v1", "text": "## Run All Tests\n\nNow run all your tests together:\n\n```bash\ncargo test --package pallet-custom\n```\n\nYou should see all tests passing:\n\n```\nrunning 15 tests\ntest mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok\ntest mock::test_genesis_config_builds ... ok\ntest tests::decrement_fails_on_underflow ... ok\ntest tests::decrement_tracks_multiple_interactions ... ok\ntest tests::decrement_works ... ok\ntest tests::different_users_tracked_separately ... ok\ntest tests::genesis_config_works ... ok\ntest tests::increment_fails_on_overflow ... ok\ntest tests::increment_respects_max_value ... ok\ntest tests::increment_tracks_multiple_interactions ... ok\ntest tests::increment_works ... ok\ntest tests::mixed_increment_and_decrement_works ... ok\ntest tests::set_counter_value_requires_root ... ok\ntest tests::set_counter_value_respects_max_value ... ok\ntest tests::set_counter_value_works ... ok\n\ntest result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out\n```\n\n!!!note \"Mock Runtime Tests\"\n You'll notice 2 additional tests from the `mock` module:\n\n - `mock::__construct_runtime_integrity_test::runtime_integrity_tests` - Auto-generated test that validates runtime construction\n - `mock::test_genesis_config_builds` - Validates that genesis configuration builds correctly\n\n These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid.\n\n🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns!\n\nThese tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality.\n\n??? code \"Full Test Suite Code\"\n Here's the complete `tests.rs` file for quick reference:\n\n ```rust\n use crate::{mock::*, Error, Event};\n use frame::deps::frame_support::{assert_noop, assert_ok};\n use frame::deps::sp_runtime::DispatchError;\n\n #[test]\n fn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n }\n\n #[test]\n fn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter with non-root origin should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(1), 100),\n DispatchError::BadOrigin\n );\n });\n }\n\n #[test]\n fn set_counter_value_respects_max_value() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter above max value (1000) should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::root(), 1001),\n Error::::CounterMaxValueExceeded\n );\n\n // Setting to exactly max value should work\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 1000));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn increment_tracks_multiple_interactions() {\n new_test_ext().execute_with(|| {\n let account = 1u64;\n\n // Increment multiple times\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 20));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 30));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 60);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n }\n\n #[test]\n fn increment_respects_max_value() {\n new_test_ext_with_counter(950).execute_with(|| {\n // Incrementing past max value (1000) should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 51),\n Error::::CounterMaxValueExceeded\n );\n\n // Incrementing to exactly max value should work\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(1), 50));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn decrement_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 2u64;\n\n // Decrement by 30\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 30));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterDecremented {\n new_value: 70,\n who: account,\n amount: 30,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n }\n\n #[test]\n fn decrement_tracks_multiple_interactions() {\n new_test_ext_with_counter(100).execute_with(|| {\n let account = 3u64;\n\n // Decrement multiple times\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 20));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 2)\n assert_eq!(crate::UserInteractions::::get(account), 2);\n });\n }\n\n #[test]\n fn mixed_increment_and_decrement_works() {\n new_test_ext_with_counter(50).execute_with(|| {\n let account = 4u64;\n\n // Mix of increment and decrement\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 25));\n assert_eq!(crate::CounterValue::::get(), 75);\n\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 15));\n assert_eq!(crate::CounterValue::::get(), 60);\n\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn different_users_tracked_separately() {\n new_test_ext().execute_with(|| {\n let account1 = 1u64;\n let account2 = 2u64;\n\n // User 1 increments\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n\n // User 2 decrements\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account2), 5));\n\n // Check counter value (10 + 10 - 5 = 15)\n assert_eq!(crate::CounterValue::::get(), 15);\n\n // Check user interactions are tracked separately\n assert_eq!(crate::UserInteractions::::get(account1), 2);\n assert_eq!(crate::UserInteractions::::get(account2), 1);\n });\n }\n\n #[test]\n fn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n }\n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 19815, "end_char": 20165, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Add Your Custom Pallet to the Runtime__\n\n ---\n\n Your pallet is tested and ready! Learn how to integrate it into your runtime.\n\n [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)\n\n
"} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 26, "end_char": 754, "estimated_token_count": 146, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nA blockchain runtime is more than just a fixed set of rules—it's a dynamic foundation that you can shape to match your specific needs. With Polkadot SDK's [FRAME (Framework for Runtime Aggregation of Modularized Entities)](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\\_blank}, customizing your runtime is straightforward and modular. Instead of building everything from scratch, you combine pre-built pallets with your own custom logic to create a runtime suited to your blockchain's purpose.\n\nThis overview explains how runtime customization works, introduces the building blocks you'll use, and guides you through the key patterns for extending your runtime."} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 1, "depth": 2, "title": "Understanding Your Runtime", "anchor": "understanding-your-runtime", "start_char": 754, "end_char": 1532, "estimated_token_count": 158, "token_estimator": "heuristic-v1", "text": "## Understanding Your Runtime\n\nThe runtime is the core logic of your blockchain—it processes transactions, manages state, and enforces the rules that govern your network. When a transaction arrives at your blockchain, the [`frame_executive`](https://paritytech.github.io/polkadot-sdk/master/frame_executive/index.html){target=\\_blank} pallet receives it and routes it to the appropriate pallet for execution.\n\nThink of your runtime as a collection of specialized modules, each handling a different aspect of your blockchain. Need token balances? Use the Balances pallet. Want governance? Add the Governance pallet. Need something custom? Create your own pallet. By mixing and matching these modules, you build a runtime that's efficient, secure, and tailored to your use case."} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 2, "depth": 2, "title": "Runtime Architecture", "anchor": "runtime-architecture", "start_char": 1532, "end_char": 2084, "estimated_token_count": 121, "token_estimator": "heuristic-v1", "text": "## Runtime Architecture\n\nThe following diagram shows how FRAME components work together to form your runtime:\n\n![](/images/parachains/customize-runtime/index/frame-overview-01.webp)\n\nThe main components are:\n\n- **`frame_executive`**: Routes all incoming transactions to the correct pallet for execution.\n- **Pallets**: Domain-specific modules that implement your blockchain's features and business logic.\n- **`frame_system`**: Provides core runtime primitives and storage.\n- **`frame_support`**: Utilities and macros that simplify pallet development."} @@ -1544,11 +1544,11 @@ {"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-obtain-coretime", "page_title": "Obtain Coretime", "index": 5, "depth": 3, "title": "Purchase a Core", "anchor": "purchase-a-core", "start_char": 5896, "end_char": 7568, "estimated_token_count": 440, "token_estimator": "heuristic-v1", "text": "### Purchase a Core\n\nFor this tutorial, we will use [RegionX](https://app.regionx.tech){target=\\_blank}. Once you open the app, you should be presented with the following screen:\n\n![Screenshot of the RegionX app displaying the main interface.](/images/tutorials/polkadot-sdk/parachains/zero-to-hero/obtain-coretime/obtain-coretime-3.webp)\n\nOn the top left is a network switch. Ensure you have selected your parachain and that it is registered before purchasing a core.\n\nTo purchase a core, go to the menu on the left and select the **Purchase A Core** item under **Primary Market**. Here, you should see the cores available for purchase, details regarding the sale period, and its current phase. Alternatively, you may use this link to visit it: [**Primary Market > Purchase A Core**](https://app.regionx.tech/purchase){target=\\_blank}.\n\n![](/images/tutorials/polkadot-sdk/parachains/zero-to-hero/obtain-coretime/obtain-coretime-4.webp)\n\nAt the bottom-right corner of the page, select the **Purchase a Core** button. A modal detailing the fees will appear. Review the details, then click **Ok** and sign the transaction using the wallet of your choice.\n\n![](/images/tutorials/polkadot-sdk/parachains/zero-to-hero/obtain-coretime/obtain-coretime-5.webp)\n\nOnce the transaction is confirmed, click [**My Regions**](https://app.regionx.tech/regions){target=\\_blank} on the left-hand menu, and you will see your purchased core.\n\n![](/images/tutorials/polkadot-sdk/parachains/zero-to-hero/obtain-coretime/obtain-coretime-6.webp)\n\nCongratulations, you just purchased a core using RegionX! You can assign the core to your parachain, partition, interlace, and more using RegionX."} {"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-obtain-coretime", "page_title": "Obtain Coretime", "index": 6, "depth": 3, "title": "Assign a Core", "anchor": "assign-a-core", "start_char": 7568, "end_char": 8625, "estimated_token_count": 250, "token_estimator": "heuristic-v1", "text": "### Assign a Core\n\nOnce you have the core as shown in the dashboard, select it by clicking on it, then click the **Assign** option on the left-hand side. You will be presented with a modal in which you can add a new task.\n\n![](/images/tutorials/polkadot-sdk/parachains/zero-to-hero/obtain-coretime/obtain-coretime-7.webp)\n\nClick the **Add Task** button and input the parachain identifier, along with the name of your project, and finalize it by clicking **Add Task**.\n\n![](/images/tutorials/polkadot-sdk/parachains/zero-to-hero/obtain-coretime/obtain-coretime-8.webp)\n\nYou may now select a task from the list. You must also set the core's finality, which determines whether you can renew this specific core. Provisional finality allows for interlacing and partitioning, whereas Final finality does not allow the region to be modified. A core must not be interlaced or partitioned to be renewable, so Finality should be selected if you want to renew this specific core.\n\nOnce you sign and send this transaction, your parachain will be assigned to that core."} {"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 0, "end_char": 1110, "estimated_token_count": 227, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nAfter validating your pallet through testing and integrating it into your runtime, the next crucial step is benchmarking. Testing procedures were detailed in the [Pallet Unit Testing](/tutorials/polkadot-sdk/parachains/zero-to-hero/pallet-unit-testing/){target=\\_blank} tutorial, while runtime integration was covered in the [Add Pallets to the Runtime](/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/){target=\\_blank} guide.\n\nBenchmarking assigns precise [weight](/reference/glossary/#weight){target=\\_blank} to each extrinsic, \nmeasuring their computational and storage costs. These derived weights enable accurate fee calculation and resource \nallocation within the runtime.\n\nThis tutorial demonstrates how to:\n\n- Configure your development environment for benchmarking.\n- Create and implement benchmark tests for your extrinsics.\n- Apply benchmark results to your pallet's extrinsics.\n\nFor comprehensive information about benchmarking concepts, refer to the [Benchmarking](/parachains/customize-runtime/pallet-development/benchmark-pallet/){target=\\_blank} guide."} -{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 1, "depth": 2, "title": "Environment Setup", "anchor": "environment-setup", "start_char": 1110, "end_char": 3670, "estimated_token_count": 579, "token_estimator": "heuristic-v1", "text": "## Environment Setup\n\nFollow these steps to prepare your environment for pallet benchmarking:\n\n1. Install the [`frame-omni-bencher`](https://crates.io/crates/frame-omni-bencher/0.13.0){target=\\_blank} command-line tool:\n \n ```bash\n cargo install --locked frame-omni-bencher@0.13.0\n ```\n\n2. Update your pallet's `Cargo.toml` file in the `pallets/custom-pallet` directory by adding the `runtime-benchmarks` feature flag:\n\n ```toml hl_lines=\"4\" title=\"Cargo.toml\"\n [features]\n default = [\"std\"]\n std = [\"codec/std\", \"frame/std\", \"scale-info/std\"]\n runtime-benchmarks = [\"frame/runtime-benchmarks\"]\n\n ```\n\n3. Add your pallet to the runtime's benchmark configuration:\n\n 1. Register your pallet in `runtime/src/benchmarks.rs`:\n\n ```rust hl_lines=\"11\" title=\"benchmarks.rs\"\n polkadot_sdk::frame_benchmarking::define_benchmarks!(\n [frame_system, SystemBench::]\n [pallet_balances, Balances]\n [pallet_session, SessionBench::]\n [pallet_timestamp, Timestamp]\n [pallet_message_queue, MessageQueue]\n [pallet_sudo, Sudo]\n [pallet_collator_selection, CollatorSelection]\n [cumulus_pallet_parachain_system, ParachainSystem]\n [cumulus_pallet_xcmp_queue, XcmpQueue]\n [custom_pallet, CustomPallet]\n );\n ```\n\n 2. Enable runtime benchmarking for your pallet in `runtime/Cargo.toml`:\n\n ```toml hl_lines=\"6\" title=\"Cargo.toml\"\n runtime-benchmarks = [\n \t\"cumulus-pallet-parachain-system/runtime-benchmarks\",\n \t\"hex-literal\",\n \t\"pallet-parachain-template/runtime-benchmarks\",\n \t\"polkadot-sdk/runtime-benchmarks\",\n \t\"custom-pallet/runtime-benchmarks\",\n ]\n ```\n\n4. Set up the benchmarking module in your pallet:\n 1. Create a `benchmarking.rs` file in your pallet's `src/` directory:\n \n ```bash\n touch benchmarking.rs\n ```\n\n 2. Add the benchmarking module to your pallet. In the pallet `lib.rs` file add the following:\n\n ```rust hl_lines=\"9-10\" title=\"lib.rs\"\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n\n #[cfg(feature = \"runtime-benchmarks\")]\n mod benchmarking;\n\n ```\n\n The `benchmarking` module is gated behind the `runtime-benchmarks` feature flag. It will only be compiled when this flag is explicitly enabled in your project's `Cargo.toml` or via the `--features runtime-benchmarks` compilation flag."} -{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 2, "depth": 2, "title": "Implement Benchmark Tests", "anchor": "implement-benchmark-tests", "start_char": 3670, "end_char": 7640, "estimated_token_count": 963, "token_estimator": "heuristic-v1", "text": "## Implement Benchmark Tests\n\nWhen writing benchmarking tests for your pallet, you'll create specialized test functions for each extrinsic, similar to unit tests. These tests use the mock runtime you created earlier for testing, allowing you to leverage its utility functions.\n\nEvery benchmark test must follow a three-step pattern:\n\n1. **Setup**: Perform any necessary setup before calling the extrinsic. This might include creating accounts, setting initial states, or preparing test data.\n2. **Execute the extrinsic**: Execute the actual extrinsic using the [`#[extrinsic_call]`](https://paritytech.github.io/polkadot-sdk/master/frame_benchmarking/v2/attr.extrinsic_call.html){target=\\_blank} macro. This must be a single line that calls your extrinsic function with the origin as its first argument.\n3. **Verification**: Check that the extrinsic worked correctly within the benchmark context by checking the expected state changes.\n\nCheck the following example on how to benchmark the `increment` extrinsic:\n\n```rust\n #[benchmark]\n fn increment() {\n let caller: T::AccountId = whitelisted_caller();\n\n assert_ok!(CustomPallet::::set_counter_value(\n RawOrigin::Root.into(),\n 5u32\n ));\n\n #[extrinsic_call]\n increment(RawOrigin::Signed(caller.clone()), 1);\n\n assert_eq!(CounterValue::::get(), Some(6u32.into()));\n assert_eq!(UserInteractions::::get(caller), 1u32.into());\n }\n```\n\nThis benchmark test:\n\n1. Creates a whitelisted caller and sets an initial counter value of 5.\n2. Calls the increment extrinsic to increase the counter by 1.\n3. Verifies that the counter was properly incremented to 6 and that the user's interaction was recorded in storage.\n\nThis example demonstrates how to properly set up state, execute an extrinsic, and verify its effects during benchmarking.\n\nNow, implement the complete set of benchmark tests. Copy the following content in the `benchmarking.rs` file:\n\n```rust title=\"benchmarking.rs\"\n#![cfg(feature = \"runtime-benchmarks\")]\n\nuse super::{Pallet as CustomPallet, *};\nuse frame::deps::frame_support::assert_ok;\nuse frame::{deps::frame_benchmarking::v2::*, prelude::*};\n\n#[benchmarks]\nmod benchmarks {\n use super::*;\n #[cfg(test)]\n use crate::pallet::Pallet as CustomPallet;\n use frame_system::RawOrigin;\n\n #[benchmark]\n fn set_counter_value() {\n #[extrinsic_call]\n set_counter_value(RawOrigin::Root, 5);\n\n assert_eq!(CounterValue::::get(), Some(5u32.into()));\n }\n\n #[benchmark]\n fn increment() {\n let caller: T::AccountId = whitelisted_caller();\n\n assert_ok!(CustomPallet::::set_counter_value(\n RawOrigin::Root.into(),\n 5u32\n ));\n\n #[extrinsic_call]\n increment(RawOrigin::Signed(caller.clone()), 1);\n\n assert_eq!(CounterValue::::get(), Some(6u32.into()));\n assert_eq!(UserInteractions::::get(caller), 1u32.into());\n }\n\n #[benchmark]\n fn decrement() {\n let caller: T::AccountId = whitelisted_caller();\n\n assert_ok!(CustomPallet::::set_counter_value(\n RawOrigin::Root.into(),\n 5u32\n ));\n\n #[extrinsic_call]\n decrement(RawOrigin::Signed(caller.clone()), 1);\n\n assert_eq!(CounterValue::::get(), Some(4u32.into()));\n assert_eq!(UserInteractions::::get(caller), 1u32.into());\n }\n\n impl_benchmark_test_suite!(CustomPallet, crate::mock::new_test_ext(), crate::mock::Test);\n}\n\n```\n\nThe [`#[benchmark]`](https://paritytech.github.io/polkadot-sdk/master/frame_benchmarking/v2/attr.benchmark.html){target=\\_blank} macro marks these functions as benchmark tests, while the `#[extrinsic_call]` macro specifically identifies which line contains the extrinsic being measured. For more information, see the [frame_benchmarking](https://paritytech.github.io/polkadot-sdk/master/frame_benchmarking/v2/index.html){target=\\_blank} Rust docs."} -{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 3, "depth": 2, "title": "Execute the Benchmarking", "anchor": "execute-the-benchmarking", "start_char": 7640, "end_char": 9614, "estimated_token_count": 423, "token_estimator": "heuristic-v1", "text": "## Execute the Benchmarking\n\nAfter implementing your benchmark test suite, you'll need to execute the tests and generate the weights for your extrinsics. This process involves building your runtime with benchmarking features enabled and using the `frame-omni-bencher` CLI tool. To do that, follow these steps:\n\n1. Build your runtime with the `runtime-benchmarks` feature enabled:\n\n ```bash\n cargo build --features runtime-benchmarks --release\n ```\n\n This special build includes all the necessary benchmarking code that's normally excluded from production builds.\n\n2. Create a `weights.rs` file in your pallet's `src/` directory. This file will store the auto-generated weight calculations:\n\n ```bash\n touch weights.rs\n ```\n\n3. Before running the benchmarking tool, you'll need a template file that defines how weight information should be formatted. Download the official template from the Polkadot SDK repository and save it in your project folders for future use:\n\n ```bash\n mkdir ./pallets/benchmarking && \\\n curl https://raw.githubusercontent.com/paritytech/polkadot-sdk/refs/heads/stable2412/substrate/.maintain/frame-umbrella-weight-template.hbs \\\n --output ./pallets/benchmarking/frame-umbrella-weight-template.hbs\n ```\n\n4. Execute the benchmarking process using the `frame-omni-bencher` CLI:\n\n ```bash\n frame-omni-bencher v1 benchmark pallet \\\n --runtime target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm \\\n --pallet \"custom_pallet\" \\\n --extrinsic \"\" \\\n --template ./pallets/benchmarking/frame-umbrella-weight-template.hbs \\\n --output ./pallets/custom-pallet/src/weights.rs\n ```\n\nWhen the benchmarking process completes, your `weights.rs` file will contain auto-generated code with weight calculations for each of your pallet's extrinsics. These weights help ensure fair and accurate fee calculations when your pallet is used in a production environment."} -{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 4, "depth": 2, "title": "Add Benchmarking Weights to the Pallet", "anchor": "add-benchmarking-weights-to-the-pallet", "start_char": 9614, "end_char": 12427, "estimated_token_count": 632, "token_estimator": "heuristic-v1", "text": "## Add Benchmarking Weights to the Pallet\n\nAfter generating the weight calculations, you need to integrate these weights into your pallet's code. This integration ensures your pallet properly accounts for computational costs in its extrinsics.\n\nFirst, add the necessary module imports to your pallet. These imports make the weights available to your code:\n\n```rust hl_lines=\"4-5\" title=\"lib.rs\"\n#[cfg(feature = \"runtime-benchmarks\")]\nmod benchmarking;\n\npub mod weights;\nuse crate::weights::WeightInfo;\n```\n\nNext, update your pallet's `Config` trait to include weight information. Define the `WeightInfo` type:\n\n```rust hl_lines=\"9-10\" title=\"lib.rs\"\n pub trait Config: frame_system::Config {\n // Defines the event type for the pallet.\n type RuntimeEvent: From> + IsType<::RuntimeEvent>;\n\n // Defines the maximum value the counter can hold.\n #[pallet::constant]\n type CounterMaxValue: Get;\n\n /// A type representing the weights required by the dispatchables of this pallet.\n type WeightInfo: WeightInfo;\n }\n```\n\nNow you can assign weights to your extrinsics. Here's how to add weight calculations to the `set_counter_value` function:\n\n```rust hl_lines=\"1\" title=\"lib.rs\"\n #[pallet::weight(T::WeightInfo::set_counter_value())]\n pub fn set_counter_value(origin: OriginFor, new_value: u32) -> DispatchResult {\n ensure_root(origin)?;\n\n ensure!(\n new_value <= T::CounterMaxValue::get(),\n Error::::CounterValueExceedsMax\n );\n\n CounterValue::::put(new_value);\n\n Self::deposit_event(Event::::CounterValueSet {\n counter_value: new_value,\n });\n\n Ok(())\n }\n\n```\n\nYou must apply similar weight annotations to the other extrinsics in your pallet. Add the `#[pallet::weight(T::WeightInfo::function_name())]` attribute to both `increment` and `decrement`, replacing `function_name` with the respective function names from your `WeightInfo` trait.\n\nFor testing purposes, you must implement the weight calculations in your mock runtime. Open `custom-pallet/src/mock.rs` and add:\n\n```rust hl_lines=\"4\" title=\"mock.rs\"\nimpl custom_pallet::Config for Test {\n type RuntimeEvent = RuntimeEvent;\n type CounterMaxValue = CounterMaxValue;\n type WeightInfo = custom_pallet::weights::SubstrateWeight;\n}\n```\n\nFinally, configure the actual weight values in your production runtime. In `runtime/src/config/mod.rs`, add:\n\n```rust hl_lines=\"5\" title=\"mod.rs\"\n\n// Define counter max value runtime constant.\nparameter_types! {\n pub const CounterMaxValue: u32 = 500;\n}\n\n```\n\nYour pallet is now complete with full testing and benchmarking support, ready for production use."} -{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 5, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 12427, "end_char": 12857, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Tutorial __Runtime Upgrade__\n\n ---\n\n Learn how to safely perform runtime upgrades for your Polkadot SDK-based blockchain, including step-by-step instructions for preparing, submitting, and verifying upgrades.\n\n [:octicons-arrow-right-24: Get Started](/tutorials/polkadot-sdk/parachains/zero-to-hero/runtime-upgrade/)\n\n
"} +{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 1, "depth": 2, "title": "Environment Setup", "anchor": "environment-setup", "start_char": 1110, "end_char": 3123, "estimated_token_count": 508, "token_estimator": "heuristic-v1", "text": "## Environment Setup\n\nFollow these steps to prepare your environment for pallet benchmarking:\n\n1. Install the [`frame-omni-bencher`](https://crates.io/crates/frame-omni-bencher/0.13.0){target=\\_blank} command-line tool:\n \n ```bash\n cargo install --locked frame-omni-bencher@0.13.0\n ```\n\n2. Update your pallet's `Cargo.toml` file in the `pallets/custom-pallet` directory by adding the `runtime-benchmarks` feature flag:\n\n ```toml hl_lines=\"4\" title=\"Cargo.toml\"\n [features]\n default = [\"std\"]\n std = [\"codec/std\", \"frame/std\", \"scale-info/std\"]\n runtime-benchmarks = [\"frame/runtime-benchmarks\"]\n\n ```\n\n3. Add your pallet to the runtime's benchmark configuration:\n\n 1. Register your pallet in `runtime/src/benchmarks.rs`:\n\n ```rust hl_lines=\"11\" title=\"benchmarks.rs\"\n \n ```\n\n 2. Enable runtime benchmarking for your pallet in `runtime/Cargo.toml`:\n\n ```toml hl_lines=\"6\" title=\"Cargo.toml\"\n runtime-benchmarks = [\n \t\"cumulus-pallet-parachain-system/runtime-benchmarks\",\n \t\"hex-literal\",\n \t\"pallet-parachain-template/runtime-benchmarks\",\n \t\"polkadot-sdk/runtime-benchmarks\",\n \t\"custom-pallet/runtime-benchmarks\",\n ]\n ```\n\n4. Set up the benchmarking module in your pallet:\n 1. Create a `benchmarking.rs` file in your pallet's `src/` directory:\n \n ```bash\n touch benchmarking.rs\n ```\n\n 2. Add the benchmarking module to your pallet. In the pallet `lib.rs` file add the following:\n\n ```rust hl_lines=\"9-10\" title=\"lib.rs\"\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n\n #[cfg(feature = \"runtime-benchmarks\")]\n mod benchmarking;\n\n ```\n\n The `benchmarking` module is gated behind the `runtime-benchmarks` feature flag. It will only be compiled when this flag is explicitly enabled in your project's `Cargo.toml` or via the `--features runtime-benchmarks` compilation flag."} +{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 2, "depth": 2, "title": "Implement Benchmark Tests", "anchor": "implement-benchmark-tests", "start_char": 3123, "end_char": 7093, "estimated_token_count": 963, "token_estimator": "heuristic-v1", "text": "## Implement Benchmark Tests\n\nWhen writing benchmarking tests for your pallet, you'll create specialized test functions for each extrinsic, similar to unit tests. These tests use the mock runtime you created earlier for testing, allowing you to leverage its utility functions.\n\nEvery benchmark test must follow a three-step pattern:\n\n1. **Setup**: Perform any necessary setup before calling the extrinsic. This might include creating accounts, setting initial states, or preparing test data.\n2. **Execute the extrinsic**: Execute the actual extrinsic using the [`#[extrinsic_call]`](https://paritytech.github.io/polkadot-sdk/master/frame_benchmarking/v2/attr.extrinsic_call.html){target=\\_blank} macro. This must be a single line that calls your extrinsic function with the origin as its first argument.\n3. **Verification**: Check that the extrinsic worked correctly within the benchmark context by checking the expected state changes.\n\nCheck the following example on how to benchmark the `increment` extrinsic:\n\n```rust\n #[benchmark]\n fn increment() {\n let caller: T::AccountId = whitelisted_caller();\n\n assert_ok!(CustomPallet::::set_counter_value(\n RawOrigin::Root.into(),\n 5u32\n ));\n\n #[extrinsic_call]\n increment(RawOrigin::Signed(caller.clone()), 1);\n\n assert_eq!(CounterValue::::get(), Some(6u32.into()));\n assert_eq!(UserInteractions::::get(caller), 1u32.into());\n }\n```\n\nThis benchmark test:\n\n1. Creates a whitelisted caller and sets an initial counter value of 5.\n2. Calls the increment extrinsic to increase the counter by 1.\n3. Verifies that the counter was properly incremented to 6 and that the user's interaction was recorded in storage.\n\nThis example demonstrates how to properly set up state, execute an extrinsic, and verify its effects during benchmarking.\n\nNow, implement the complete set of benchmark tests. Copy the following content in the `benchmarking.rs` file:\n\n```rust title=\"benchmarking.rs\"\n#![cfg(feature = \"runtime-benchmarks\")]\n\nuse super::{Pallet as CustomPallet, *};\nuse frame::deps::frame_support::assert_ok;\nuse frame::{deps::frame_benchmarking::v2::*, prelude::*};\n\n#[benchmarks]\nmod benchmarks {\n use super::*;\n #[cfg(test)]\n use crate::pallet::Pallet as CustomPallet;\n use frame_system::RawOrigin;\n\n #[benchmark]\n fn set_counter_value() {\n #[extrinsic_call]\n set_counter_value(RawOrigin::Root, 5);\n\n assert_eq!(CounterValue::::get(), Some(5u32.into()));\n }\n\n #[benchmark]\n fn increment() {\n let caller: T::AccountId = whitelisted_caller();\n\n assert_ok!(CustomPallet::::set_counter_value(\n RawOrigin::Root.into(),\n 5u32\n ));\n\n #[extrinsic_call]\n increment(RawOrigin::Signed(caller.clone()), 1);\n\n assert_eq!(CounterValue::::get(), Some(6u32.into()));\n assert_eq!(UserInteractions::::get(caller), 1u32.into());\n }\n\n #[benchmark]\n fn decrement() {\n let caller: T::AccountId = whitelisted_caller();\n\n assert_ok!(CustomPallet::::set_counter_value(\n RawOrigin::Root.into(),\n 5u32\n ));\n\n #[extrinsic_call]\n decrement(RawOrigin::Signed(caller.clone()), 1);\n\n assert_eq!(CounterValue::::get(), Some(4u32.into()));\n assert_eq!(UserInteractions::::get(caller), 1u32.into());\n }\n\n impl_benchmark_test_suite!(CustomPallet, crate::mock::new_test_ext(), crate::mock::Test);\n}\n\n```\n\nThe [`#[benchmark]`](https://paritytech.github.io/polkadot-sdk/master/frame_benchmarking/v2/attr.benchmark.html){target=\\_blank} macro marks these functions as benchmark tests, while the `#[extrinsic_call]` macro specifically identifies which line contains the extrinsic being measured. For more information, see the [frame_benchmarking](https://paritytech.github.io/polkadot-sdk/master/frame_benchmarking/v2/index.html){target=\\_blank} Rust docs."} +{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 3, "depth": 2, "title": "Execute the Benchmarking", "anchor": "execute-the-benchmarking", "start_char": 7093, "end_char": 9067, "estimated_token_count": 423, "token_estimator": "heuristic-v1", "text": "## Execute the Benchmarking\n\nAfter implementing your benchmark test suite, you'll need to execute the tests and generate the weights for your extrinsics. This process involves building your runtime with benchmarking features enabled and using the `frame-omni-bencher` CLI tool. To do that, follow these steps:\n\n1. Build your runtime with the `runtime-benchmarks` feature enabled:\n\n ```bash\n cargo build --features runtime-benchmarks --release\n ```\n\n This special build includes all the necessary benchmarking code that's normally excluded from production builds.\n\n2. Create a `weights.rs` file in your pallet's `src/` directory. This file will store the auto-generated weight calculations:\n\n ```bash\n touch weights.rs\n ```\n\n3. Before running the benchmarking tool, you'll need a template file that defines how weight information should be formatted. Download the official template from the Polkadot SDK repository and save it in your project folders for future use:\n\n ```bash\n mkdir ./pallets/benchmarking && \\\n curl https://raw.githubusercontent.com/paritytech/polkadot-sdk/refs/heads/stable2412/substrate/.maintain/frame-umbrella-weight-template.hbs \\\n --output ./pallets/benchmarking/frame-umbrella-weight-template.hbs\n ```\n\n4. Execute the benchmarking process using the `frame-omni-bencher` CLI:\n\n ```bash\n frame-omni-bencher v1 benchmark pallet \\\n --runtime target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm \\\n --pallet \"custom_pallet\" \\\n --extrinsic \"\" \\\n --template ./pallets/benchmarking/frame-umbrella-weight-template.hbs \\\n --output ./pallets/custom-pallet/src/weights.rs\n ```\n\nWhen the benchmarking process completes, your `weights.rs` file will contain auto-generated code with weight calculations for each of your pallet's extrinsics. These weights help ensure fair and accurate fee calculations when your pallet is used in a production environment."} +{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 4, "depth": 2, "title": "Add Benchmarking Weights to the Pallet", "anchor": "add-benchmarking-weights-to-the-pallet", "start_char": 9067, "end_char": 11770, "estimated_token_count": 611, "token_estimator": "heuristic-v1", "text": "## Add Benchmarking Weights to the Pallet\n\nAfter generating the weight calculations, you need to integrate these weights into your pallet's code. This integration ensures your pallet properly accounts for computational costs in its extrinsics.\n\nFirst, add the necessary module imports to your pallet. These imports make the weights available to your code:\n\n```rust hl_lines=\"4-5\" title=\"lib.rs\"\n#[cfg(feature = \"runtime-benchmarks\")]\nmod benchmarking;\n\npub mod weights;\nuse crate::weights::WeightInfo;\n```\n\nNext, update your pallet's `Config` trait to include weight information. Define the `WeightInfo` type:\n\n```rust hl_lines=\"9-10\" title=\"lib.rs\"\n pub trait Config: frame_system::Config {\n // Defines the event type for the pallet.\n type RuntimeEvent: From> + IsType<::RuntimeEvent>;\n\n // Defines the maximum value the counter can hold.\n #[pallet::constant]\n type CounterMaxValue: Get;\n\n /// A type representing the weights required by the dispatchables of this pallet.\n type WeightInfo: WeightInfo;\n }\n```\n\nNow you can assign weights to your extrinsics. Here's how to add weight calculations to the `set_counter_value` function:\n\n```rust hl_lines=\"1\" title=\"lib.rs\"\n #[pallet::weight(T::WeightInfo::set_counter_value())]\n pub fn set_counter_value(origin: OriginFor, new_value: u32) -> DispatchResult {\n ensure_root(origin)?;\n\n ensure!(\n new_value <= T::CounterMaxValue::get(),\n Error::::CounterValueExceedsMax\n );\n\n CounterValue::::put(new_value);\n\n Self::deposit_event(Event::::CounterValueSet {\n counter_value: new_value,\n });\n\n Ok(())\n }\n\n```\n\nYou must apply similar weight annotations to the other extrinsics in your pallet. Add the `#[pallet::weight(T::WeightInfo::function_name())]` attribute to both `increment` and `decrement`, replacing `function_name` with the respective function names from your `WeightInfo` trait.\n\nFor testing purposes, you must implement the weight calculations in your mock runtime. Open `custom-pallet/src/mock.rs` and add:\n\n```rust hl_lines=\"4\" title=\"mock.rs\"\nimpl custom_pallet::Config for Test {\n type RuntimeEvent = RuntimeEvent;\n type CounterMaxValue = CounterMaxValue;\n type WeightInfo = custom_pallet::weights::SubstrateWeight;\n}\n```\n\nFinally, configure the actual weight values in your production runtime. In `runtime/src/config/mod.rs`, add:\n\n```rust hl_lines=\"5\" title=\"mod.rs\"\n\n```\n\nYour pallet is now complete with full testing and benchmarking support, ready for production use."} +{"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-benchmarking", "page_title": "Pallet Benchmarking", "index": 5, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 11770, "end_char": 12200, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Tutorial __Runtime Upgrade__\n\n ---\n\n Learn how to safely perform runtime upgrades for your Polkadot SDK-based blockchain, including step-by-step instructions for preparing, submitting, and verifying upgrades.\n\n [:octicons-arrow-right-24: Get Started](/tutorials/polkadot-sdk/parachains/zero-to-hero/runtime-upgrade/)\n\n
"} {"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-unit-testing", "page_title": "Pallet Unit Testing", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 23, "end_char": 934, "estimated_token_count": 202, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nYou have learned how to create a new pallet in the [Build a Custom Pallet](/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/){target=\\_blank} tutorial; now you will see how to test the pallet to ensure that it works as expected. As stated in the [Pallet Testing](/parachains/customize-runtime/pallet-development/pallet-testing/){target=\\_blank} article, unit testing is crucial for ensuring the reliability and correctness of pallets in Polkadot SDK-based blockchains. Comprehensive testing helps validate pallet functionality, prevent potential bugs, and maintain the integrity of your blockchain logic.\n\nThis tutorial will guide you through creating a unit testing suite for a custom pallet created in the [Build a Custom Pallet](/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/){target=\\_blank} tutorial, covering essential testing aspects and steps."} {"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-unit-testing", "page_title": "Pallet Unit Testing", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 934, "end_char": 1463, "estimated_token_count": 139, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nTo set up your testing environment for Polkadot SDK pallets, you'll need:\n\n- [Polkadot SDK dependencies](/parachains/install-polkadot-sdk/){target=\\_blank} installed.\n- Basic understanding of Substrate/Polkadot SDK concepts.\n- A custom pallet implementation, check the [Build a Custom Pallet](/tutorials/polkadot-sdk/parachains/zero-to-hero/build-custom-pallet/){target=\\_blank} tutorial.\n- Familiarity with [Rust testing frameworks](https://doc.rust-lang.org/book/ch11-01-writing-tests.html){target=\\_blank}."} {"page_id": "tutorials-polkadot-sdk-parachains-zero-to-hero-pallet-unit-testing", "page_title": "Pallet Unit Testing", "index": 2, "depth": 2, "title": "Set Up the Testing Environment", "anchor": "set-up-the-testing-environment", "start_char": 1463, "end_char": 2077, "estimated_token_count": 175, "token_estimator": "heuristic-v1", "text": "## Set Up the Testing Environment\n\nTo effectively create the test environment for your pallet, you'll need to follow these steps:\n\n1. Move to the project directory:\n\n ```bash\n cd custom-pallet\n ```\n\n2. Create a `mock.rs` and a `tests.rs` files (leave these files empty for now, they will be filled in later):\n\n ```bash\n touch src/mock.rs\n touch src/tests.rs\n ```\n\n3. Include them in your `lib.rs` module:\n\n ```rust hl_lines=\"5-9\" title=\"lib.rs\"\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n ```"} diff --git a/parachains/customize-runtime/pallet-development/pallet-testing.md b/parachains/customize-runtime/pallet-development/pallet-testing.md index 2f909cbd5..3cfff42ad 100644 --- a/parachains/customize-runtime/pallet-development/pallet-testing.md +++ b/parachains/customize-runtime/pallet-development/pallet-testing.md @@ -106,11 +106,19 @@ use frame::deps::sp_runtime::DispatchError; ``` This setup imports: + - The mock runtime and test utilities from `mock.rs` - Your pallet's `Error` and `Event` types - FRAME's assertion macros via `frame::deps` - `DispatchError` for testing origin checks +???+ code "Complete Pallet Code Reference" + Here's the complete pallet code that you'll be testing throughout this guide: + + ```rust + ---8<-- 'code/parachains/customize-runtime/pallet-development/create-a-pallet/lib-complete.rs' + ``` + ## Write Your First Test Let's start with a simple test to verify the increment function works correctly. From aea766c6a35cfdef0025cc75ac6d4d43beb56f15 Mon Sep 17 00:00:00 2001 From: Bruno Galvao Date: Wed, 12 Nov 2025 09:51:58 +0700 Subject: [PATCH 06/10] llms --- .ai/categories/basics.md | 182 +- .ai/categories/dapps.md | 182 +- .ai/categories/infrastructure.md | 182 +- .ai/categories/networks.md | 182 +- .ai/categories/parachains.md | 322 +- .ai/categories/polkadot-protocol.md | 193 +- .ai/categories/smart-contracts.md | 338 +- .ai/categories/tooling.md | 184 +- ...roperability-transfer-assets-parachains.md | 44 +- ...untime-add-smart-contract-functionality.md | 18 +- ...ntime-pallet-development-pallet-testing.md | 122 +- .ai/pages/parachains-install-polkadot-sdk.md | 100 +- ...parachain-set-up-the-parachain-template.md | 2 +- ...polkadot-hub-assets-and-smart-contracts.md | 11 - .ai/pages/reference-tools-paraspell.md | 51 +- .ai/pages/reference-tools-xcm-tools.md | 10 +- ...t-contracts-cookbook-dapps-zero-to-hero.md | 2 +- .../smart-contracts-for-eth-devs-migration.md | 148 +- .ai/site-index.json | 13351 +++++++--------- llms-full.jsonl | 245 +- llms.txt | 20 +- .../pallet-development/pallet-testing.md | 4 +- 22 files changed, 7528 insertions(+), 8365 deletions(-) diff --git a/.ai/categories/basics.md b/.ai/categories/basics.md index 94a6470bd..e8026fb72 100644 --- a/.ai/categories/basics.md +++ b/.ai/categories/basics.md @@ -4150,17 +4150,22 @@ Page Title: Install Polkadot SDK - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md - Canonical (HTML): https://docs.polkadot.com/parachains/install-polkadot-sdk/ -- Summary: Install everything you need to begin working with Substrated-based blockchains and the Polkadot SDK, the framework for building blockchains. +- Summary: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. -# Install Polkadot SDK Dependencies +# Install Polkadot SDK -This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. +This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -## macOS +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. + +Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. + +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -4170,7 +4175,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -4196,7 +4201,7 @@ To install Homebrew: Homebrew 4.3.15 -#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -4204,7 +4209,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -4245,16 +4250,17 @@ To install `openssl` and the Rust toolchain on macOS: rustup component add rust-src ``` -8. [Verify your installation](#verifying-installation). -9. Install `cmake` using the following command: +8. Install `cmake` using the following command: ```bash brew install cmake ``` -## Linux +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). ### Before You Begin {: #before-you-begin-linux } @@ -4277,7 +4283,7 @@ Because the blockchain requires standard cryptography to support the generation To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -4311,7 +4317,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -4341,22 +4347,22 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. [Verify your installation](#verifying-installation). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -### Before You Begin {: #before-you-begin-windows } +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. ### Set Up Windows Subsystem for Linux @@ -4394,12 +4400,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -### Install Required Packages and Rust {: #install-required-packages-and-rust-windows } +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -4442,34 +4448,122 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. [Verify your installation](#verifying-installation). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Build the Polkadot SDK + +After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. -## Verifying Installation +### Clone the Polkadot SDK -Verify the configuration of your development environment by running the following command: +1. Clone the Polkadot SDK repository: + + ```bash + git clone https://github.com/paritytech/polkadot-sdk.git + ``` + +2. Navigate into the project directory: + + ```bash + cd polkadot-sdk + ``` + +### Compile the Polkadot SDK + +Compile the entire Polkadot SDK repository to ensure your environment is properly configured: ```bash -rustup show +cargo build --release --locked ``` -The command displays output similar to the following: +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. -
- rustup show - ... -
- active toolchain - ---------------- - name: stable-aarch64-apple-darwin - active because: it's the default toolchain - installed targets: - aarch64-apple-darwin - wasm32-unknown-unknown -
+### Verify the Build + +Once the build completes successfully, verify the installation by checking the compiled binaries: + +```bash +ls target/release +``` + +You should see several binaries, including: + +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. + +Verify the Polkadot binary works by checking its version: + +```bash +./target/release/polkadot --version +``` + +This should display version information similar to: + +```bash +polkadot 1.16.0-1234abcd567 +``` + +If you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development! + +## Optional: Run the Kitchensink Node + +The Polkadot SDK includes a feature-rich node called "kitchensink" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together. + +!!!note + If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node. + +### Run the Kitchensink Node in Development Mode + +From the `polkadot-sdk` root directory, start the kitchensink node in development mode: + +```bash +./target/release/substrate-node --dev +``` + +The `--dev` flag enables development mode, which: + +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + + +You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. + +### Interact with the Kitchensink Node + +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) + +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) + +You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. + +To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Parachain Zero to Hero Tutorials](/tutorials/polkadot-sdk/parachains/zero-to-hero/){target=\_blank}**: A series of step-by-step guides to building, testing, and deploying custom pallets and runtimes using the Polkadot SDK. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
--- @@ -7202,7 +7296,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. @@ -8935,15 +9029,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools diff --git a/.ai/categories/dapps.md b/.ai/categories/dapps.md index e0099e1d5..1a7178d23 100644 --- a/.ai/categories/dapps.md +++ b/.ai/categories/dapps.md @@ -5434,17 +5434,22 @@ Page Title: Install Polkadot SDK - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md - Canonical (HTML): https://docs.polkadot.com/parachains/install-polkadot-sdk/ -- Summary: Install everything you need to begin working with Substrated-based blockchains and the Polkadot SDK, the framework for building blockchains. +- Summary: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. -# Install Polkadot SDK Dependencies +# Install Polkadot SDK -This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. +This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -## macOS +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. + +Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. + +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -5454,7 +5459,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -5480,7 +5485,7 @@ To install Homebrew: Homebrew 4.3.15 -#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -5488,7 +5493,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -5529,16 +5534,17 @@ To install `openssl` and the Rust toolchain on macOS: rustup component add rust-src ``` -8. [Verify your installation](#verifying-installation). -9. Install `cmake` using the following command: +8. Install `cmake` using the following command: ```bash brew install cmake ``` -## Linux +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). ### Before You Begin {: #before-you-begin-linux } @@ -5561,7 +5567,7 @@ Because the blockchain requires standard cryptography to support the generation To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -5595,7 +5601,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -5625,22 +5631,22 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. [Verify your installation](#verifying-installation). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -### Before You Begin {: #before-you-begin-windows } +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. ### Set Up Windows Subsystem for Linux @@ -5678,12 +5684,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -### Install Required Packages and Rust {: #install-required-packages-and-rust-windows } +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -5726,34 +5732,122 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. [Verify your installation](#verifying-installation). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Build the Polkadot SDK + +After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. -## Verifying Installation +### Clone the Polkadot SDK -Verify the configuration of your development environment by running the following command: +1. Clone the Polkadot SDK repository: + + ```bash + git clone https://github.com/paritytech/polkadot-sdk.git + ``` + +2. Navigate into the project directory: + + ```bash + cd polkadot-sdk + ``` + +### Compile the Polkadot SDK + +Compile the entire Polkadot SDK repository to ensure your environment is properly configured: ```bash -rustup show +cargo build --release --locked ``` -The command displays output similar to the following: +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. -
- rustup show - ... -
- active toolchain - ---------------- - name: stable-aarch64-apple-darwin - active because: it's the default toolchain - installed targets: - aarch64-apple-darwin - wasm32-unknown-unknown -
+### Verify the Build + +Once the build completes successfully, verify the installation by checking the compiled binaries: + +```bash +ls target/release +``` + +You should see several binaries, including: + +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. + +Verify the Polkadot binary works by checking its version: + +```bash +./target/release/polkadot --version +``` + +This should display version information similar to: + +```bash +polkadot 1.16.0-1234abcd567 +``` + +If you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development! + +## Optional: Run the Kitchensink Node + +The Polkadot SDK includes a feature-rich node called "kitchensink" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together. + +!!!note + If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node. + +### Run the Kitchensink Node in Development Mode + +From the `polkadot-sdk` root directory, start the kitchensink node in development mode: + +```bash +./target/release/substrate-node --dev +``` + +The `--dev` flag enables development mode, which: + +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + + +You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. + +### Interact with the Kitchensink Node + +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) + +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) + +You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. + +To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Parachain Zero to Hero Tutorials](/tutorials/polkadot-sdk/parachains/zero-to-hero/){target=\_blank}**: A series of step-by-step guides to building, testing, and deploying custom pallets and runtimes using the Polkadot SDK. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
--- @@ -10232,7 +10326,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. @@ -13773,15 +13867,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools diff --git a/.ai/categories/infrastructure.md b/.ai/categories/infrastructure.md index fa9bb979b..c918007f4 100644 --- a/.ai/categories/infrastructure.md +++ b/.ai/categories/infrastructure.md @@ -5244,17 +5244,22 @@ Page Title: Install Polkadot SDK - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md - Canonical (HTML): https://docs.polkadot.com/parachains/install-polkadot-sdk/ -- Summary: Install everything you need to begin working with Substrated-based blockchains and the Polkadot SDK, the framework for building blockchains. +- Summary: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. -# Install Polkadot SDK Dependencies +# Install Polkadot SDK -This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. +This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -## macOS +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. + +Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. + +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -5264,7 +5269,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -5290,7 +5295,7 @@ To install Homebrew: Homebrew 4.3.15 -#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -5298,7 +5303,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -5339,16 +5344,17 @@ To install `openssl` and the Rust toolchain on macOS: rustup component add rust-src ``` -8. [Verify your installation](#verifying-installation). -9. Install `cmake` using the following command: +8. Install `cmake` using the following command: ```bash brew install cmake ``` -## Linux +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). ### Before You Begin {: #before-you-begin-linux } @@ -5371,7 +5377,7 @@ Because the blockchain requires standard cryptography to support the generation To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -5405,7 +5411,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -5435,22 +5441,22 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. [Verify your installation](#verifying-installation). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -### Before You Begin {: #before-you-begin-windows } +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. ### Set Up Windows Subsystem for Linux @@ -5488,12 +5494,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -### Install Required Packages and Rust {: #install-required-packages-and-rust-windows } +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -5536,34 +5542,122 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. [Verify your installation](#verifying-installation). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Build the Polkadot SDK + +After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. -## Verifying Installation +### Clone the Polkadot SDK -Verify the configuration of your development environment by running the following command: +1. Clone the Polkadot SDK repository: + + ```bash + git clone https://github.com/paritytech/polkadot-sdk.git + ``` + +2. Navigate into the project directory: + + ```bash + cd polkadot-sdk + ``` + +### Compile the Polkadot SDK + +Compile the entire Polkadot SDK repository to ensure your environment is properly configured: ```bash -rustup show +cargo build --release --locked ``` -The command displays output similar to the following: +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. -
- rustup show - ... -
- active toolchain - ---------------- - name: stable-aarch64-apple-darwin - active because: it's the default toolchain - installed targets: - aarch64-apple-darwin - wasm32-unknown-unknown -
+### Verify the Build + +Once the build completes successfully, verify the installation by checking the compiled binaries: + +```bash +ls target/release +``` + +You should see several binaries, including: + +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. + +Verify the Polkadot binary works by checking its version: + +```bash +./target/release/polkadot --version +``` + +This should display version information similar to: + +```bash +polkadot 1.16.0-1234abcd567 +``` + +If you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development! + +## Optional: Run the Kitchensink Node + +The Polkadot SDK includes a feature-rich node called "kitchensink" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together. + +!!!note + If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node. + +### Run the Kitchensink Node in Development Mode + +From the `polkadot-sdk` root directory, start the kitchensink node in development mode: + +```bash +./target/release/substrate-node --dev +``` + +The `--dev` flag enables development mode, which: + +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + + +You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. + +### Interact with the Kitchensink Node + +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) + +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) + +You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. + +To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Parachain Zero to Hero Tutorials](/tutorials/polkadot-sdk/parachains/zero-to-hero/){target=\_blank}**: A series of step-by-step guides to building, testing, and deploying custom pallets and runtimes using the Polkadot SDK. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
--- @@ -10415,7 +10509,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. @@ -14146,15 +14240,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools diff --git a/.ai/categories/networks.md b/.ai/categories/networks.md index f9b300c14..19079c283 100644 --- a/.ai/categories/networks.md +++ b/.ai/categories/networks.md @@ -4519,17 +4519,22 @@ Page Title: Install Polkadot SDK - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md - Canonical (HTML): https://docs.polkadot.com/parachains/install-polkadot-sdk/ -- Summary: Install everything you need to begin working with Substrated-based blockchains and the Polkadot SDK, the framework for building blockchains. +- Summary: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. -# Install Polkadot SDK Dependencies +# Install Polkadot SDK -This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. +This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -## macOS +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. + +Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. + +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -4539,7 +4544,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -4565,7 +4570,7 @@ To install Homebrew: Homebrew 4.3.15 -#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -4573,7 +4578,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -4614,16 +4619,17 @@ To install `openssl` and the Rust toolchain on macOS: rustup component add rust-src ``` -8. [Verify your installation](#verifying-installation). -9. Install `cmake` using the following command: +8. Install `cmake` using the following command: ```bash brew install cmake ``` -## Linux +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). ### Before You Begin {: #before-you-begin-linux } @@ -4646,7 +4652,7 @@ Because the blockchain requires standard cryptography to support the generation To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -4680,7 +4686,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -4710,22 +4716,22 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. [Verify your installation](#verifying-installation). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -### Before You Begin {: #before-you-begin-windows } +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. ### Set Up Windows Subsystem for Linux @@ -4763,12 +4769,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -### Install Required Packages and Rust {: #install-required-packages-and-rust-windows } +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -4811,34 +4817,122 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. [Verify your installation](#verifying-installation). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Build the Polkadot SDK + +After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. -## Verifying Installation +### Clone the Polkadot SDK -Verify the configuration of your development environment by running the following command: +1. Clone the Polkadot SDK repository: + + ```bash + git clone https://github.com/paritytech/polkadot-sdk.git + ``` + +2. Navigate into the project directory: + + ```bash + cd polkadot-sdk + ``` + +### Compile the Polkadot SDK + +Compile the entire Polkadot SDK repository to ensure your environment is properly configured: ```bash -rustup show +cargo build --release --locked ``` -The command displays output similar to the following: +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. -
- rustup show - ... -
- active toolchain - ---------------- - name: stable-aarch64-apple-darwin - active because: it's the default toolchain - installed targets: - aarch64-apple-darwin - wasm32-unknown-unknown -
+### Verify the Build + +Once the build completes successfully, verify the installation by checking the compiled binaries: + +```bash +ls target/release +``` + +You should see several binaries, including: + +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. + +Verify the Polkadot binary works by checking its version: + +```bash +./target/release/polkadot --version +``` + +This should display version information similar to: + +```bash +polkadot 1.16.0-1234abcd567 +``` + +If you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development! + +## Optional: Run the Kitchensink Node + +The Polkadot SDK includes a feature-rich node called "kitchensink" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together. + +!!!note + If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node. + +### Run the Kitchensink Node in Development Mode + +From the `polkadot-sdk` root directory, start the kitchensink node in development mode: + +```bash +./target/release/substrate-node --dev +``` + +The `--dev` flag enables development mode, which: + +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + + +You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. + +### Interact with the Kitchensink Node + +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) + +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) + +You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. + +To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Parachain Zero to Hero Tutorials](/tutorials/polkadot-sdk/parachains/zero-to-hero/){target=\_blank}**: A series of step-by-step guides to building, testing, and deploying custom pallets and runtimes using the Polkadot SDK. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
--- @@ -8442,7 +8536,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. @@ -11543,15 +11637,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools diff --git a/.ai/categories/parachains.md b/.ai/categories/parachains.md index bbc8a2d97..69853b014 100644 --- a/.ai/categories/parachains.md +++ b/.ai/categories/parachains.md @@ -1256,9 +1256,9 @@ Any language that can compile to PolkaVM bytecode and utilize `pallet-revive`'s ### Key Benefits -- **Unified Platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet. +- **Unified platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet. - **Performance**: PolkaVM execution provides improved performance compared to the traditional EVM, leveraging the [RISC-V](https://en.wikipedia.org/wiki/RISC-V){target=\_blank} architecture to map instructions to the CPU and requires little transpiling. -- **Ethereum Compatibility**: Supports full integration with Ethereum tooling via RPC adapter. +- **Ethereum compatibility**: Supports full integration with Ethereum tooling via RPC adapter. ### Implementation Examples @@ -1276,7 +1276,7 @@ Frontier offers flexible integration depending on your compatibility needs: For basic EVM support using Polkadot SDK native APIs: -- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment +- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment. This configuration allows EVM contract execution but requires using Polkadot SDK-specific APIs for interaction. @@ -1290,20 +1290,20 @@ For complete Ethereum ecosystem integration with Ethereum RPC support: ### Key Benefits -- **Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Truffle, and other Ethereum development tools -- **Minimal-friction migration**: Deployment of existing Ethereum dApps with minimal or no modifications -- **Native Ethereum formats**: Support for Ethereum transaction formats, signatures, and gas mechanics -- **Block emulation**: Ethereum-style block structure within Substrate's block production +- **Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Foundry, and other Ethereum development tools. +- **Minimal-friction migration**: Deployment of existing Ethereum dApps with minimal or no modifications. +- **Native Ethereum formats**: Support for Ethereum transaction formats, signatures, and gas mechanics. +- **Block emulation**: Ethereum-style block structure within Substrate's block production. ### Implementation Examples Production implementations demonstrate Frontier's capabilities: -- **Moonbeam**: See their implementation of [`pallet-evm`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L532){target=\_blank} and [`pallet-ethereum`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L698){target=\_blank} +- **Moonbeam**: See their implementation of [`pallet-evm`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L532){target=\_blank} and [`pallet-ethereum`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L698){target=\_blank}. ## pallet-contracts (Legacy) -[`pallet-contracts`](https://docs.rs/pallet-contracts/latest/pallet_contracts/index.html#contracts-pallet){target=\_blank} is the original Wasm-based smart contract pallet for Polkadot SDK chains. While still functional, it's considered legacy as development efforts have shifted to pallet-revive. +[`pallet-contracts`](https://docs.rs/pallet-contracts/latest/pallet_contracts/index.html#contracts-pallet){target=\_blank} is the original Wasm-based smart contract pallet for Polkadot SDK chains. While still functional, it's considered legacy as development efforts have shifted to `pallet-revive`. ### Implementation Example @@ -9398,17 +9398,22 @@ Page Title: Install Polkadot SDK - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md - Canonical (HTML): https://docs.polkadot.com/parachains/install-polkadot-sdk/ -- Summary: Install everything you need to begin working with Substrated-based blockchains and the Polkadot SDK, the framework for building blockchains. +- Summary: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. -# Install Polkadot SDK Dependencies +# Install Polkadot SDK -This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. +This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -## macOS +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. + +Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. + +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -9418,7 +9423,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -9444,7 +9449,7 @@ To install Homebrew: Homebrew 4.3.15 -#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -9452,7 +9457,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -9493,16 +9498,17 @@ To install `openssl` and the Rust toolchain on macOS: rustup component add rust-src ``` -8. [Verify your installation](#verifying-installation). -9. Install `cmake` using the following command: +8. Install `cmake` using the following command: ```bash brew install cmake ``` -## Linux +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). ### Before You Begin {: #before-you-begin-linux } @@ -9525,7 +9531,7 @@ Because the blockchain requires standard cryptography to support the generation To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -9559,7 +9565,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -9589,22 +9595,22 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. [Verify your installation](#verifying-installation). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -### Before You Begin {: #before-you-begin-windows } +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. ### Set Up Windows Subsystem for Linux @@ -9642,12 +9648,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -### Install Required Packages and Rust {: #install-required-packages-and-rust-windows } +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -9690,34 +9696,122 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. [Verify your installation](#verifying-installation). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Build the Polkadot SDK + +After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. + +### Clone the Polkadot SDK + +1. Clone the Polkadot SDK repository: + + ```bash + git clone https://github.com/paritytech/polkadot-sdk.git + ``` + +2. Navigate into the project directory: + + ```bash + cd polkadot-sdk + ``` -## Verifying Installation +### Compile the Polkadot SDK -Verify the configuration of your development environment by running the following command: +Compile the entire Polkadot SDK repository to ensure your environment is properly configured: ```bash -rustup show +cargo build --release --locked ``` -The command displays output similar to the following: +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. -
- rustup show - ... -
- active toolchain - ---------------- - name: stable-aarch64-apple-darwin - active because: it's the default toolchain - installed targets: - aarch64-apple-darwin - wasm32-unknown-unknown -
+### Verify the Build + +Once the build completes successfully, verify the installation by checking the compiled binaries: + +```bash +ls target/release +``` + +You should see several binaries, including: + +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. + +Verify the Polkadot binary works by checking its version: + +```bash +./target/release/polkadot --version +``` + +This should display version information similar to: + +```bash +polkadot 1.16.0-1234abcd567 +``` + +If you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development! + +## Optional: Run the Kitchensink Node + +The Polkadot SDK includes a feature-rich node called "kitchensink" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together. + +!!!note + If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node. + +### Run the Kitchensink Node in Development Mode + +From the `polkadot-sdk` root directory, start the kitchensink node in development mode: + +```bash +./target/release/substrate-node --dev +``` + +The `--dev` flag enables development mode, which: + +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + + +You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. + +### Interact with the Kitchensink Node + +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) + +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) + +You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. + +To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Parachain Zero to Hero Tutorials](/tutorials/polkadot-sdk/parachains/zero-to-hero/){target=\_blank}**: A series of step-by-step guides to building, testing, and deploying custom pallets and runtimes using the Polkadot SDK. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
--- @@ -13800,7 +13894,123 @@ This setup imports: Here's the complete pallet code that you'll be testing throughout this guide: ```rust - + #![cfg_attr(not(feature = "std"), no_std)] + + pub use pallet::*; + + #[frame::pallet] + pub mod pallet { + use frame::prelude::*; + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + + #[pallet::constant] + type CounterMaxValue: Get; + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + CounterValueSet { + new_value: u32, + }, + CounterIncremented { + new_value: u32, + who: T::AccountId, + amount: u32, + }, + CounterDecremented { + new_value: u32, + who: T::AccountId, + amount: u32, + }, + } + + #[pallet::error] + pub enum Error { + NoneValue, + Overflow, + Underflow, + CounterMaxValueExceeded, + } + + #[pallet::storage] + pub type CounterValue = StorageValue<_, u32, ValueQuery>; + + #[pallet::storage] + pub type UserInteractions = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + u32, + ValueQuery + >; + + #[pallet::genesis_config] + #[derive(DefaultNoBound)] + pub struct GenesisConfig { + pub initial_counter_value: u32, + pub initial_user_interactions: Vec<(T::AccountId, u32)>, + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) { + CounterValue::::put(self.initial_counter_value); + for (account, count) in &self.initial_user_interactions { + UserInteractions::::insert(account, count); + } + } + } + + #[pallet::call] + impl Pallet { + #[pallet::call_index(0)] + #[pallet::weight(0)] + pub fn set_counter_value(origin: OriginFor, new_value: u32) -> DispatchResult { + ensure_root(origin)?; + ensure!(new_value <= T::CounterMaxValue::get(), Error::::CounterMaxValueExceeded); + CounterValue::::put(new_value); + Self::deposit_event(Event::CounterValueSet { new_value }); + Ok(()) + } + + #[pallet::call_index(1)] + #[pallet::weight(0)] + pub fn increment(origin: OriginFor, amount: u32) -> DispatchResult { + let who = ensure_signed(origin)?; + let current_value = CounterValue::::get(); + let new_value = current_value.checked_add(amount).ok_or(Error::::Overflow)?; + ensure!(new_value <= T::CounterMaxValue::get(), Error::::CounterMaxValueExceeded); + CounterValue::::put(new_value); + UserInteractions::::mutate(&who, |count| { + *count = count.saturating_add(1); + }); + Self::deposit_event(Event::CounterIncremented { new_value, who, amount }); + Ok(()) + } + + #[pallet::call_index(2)] + #[pallet::weight(0)] + pub fn decrement(origin: OriginFor, amount: u32) -> DispatchResult { + let who = ensure_signed(origin)?; + let current_value = CounterValue::::get(); + let new_value = current_value.checked_sub(amount).ok_or(Error::::Underflow)?; + CounterValue::::put(new_value); + UserInteractions::::mutate(&who, |count| { + *count = count.saturating_add(1); + }); + Self::deposit_event(Event::CounterDecremented { new_value, who, amount }); + Ok(()) + } + } + } + ``` ## Write Your First Test @@ -13853,7 +14063,7 @@ running 1 test test tests::increment_works ... ok ``` -🎉 Congratulations! You've written and run your first pallet test. +Congratulations! You've written and run your first pallet test. ## Test Error Conditions @@ -14044,7 +14254,7 @@ test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid. -🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! +Congratulations! You have a well-tested pallet covering the essential testing patterns! These tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality. @@ -16666,7 +16876,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. @@ -20614,15 +20824,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools diff --git a/.ai/categories/polkadot-protocol.md b/.ai/categories/polkadot-protocol.md index e7fc598ed..5e9ddcc2f 100644 --- a/.ai/categories/polkadot-protocol.md +++ b/.ai/categories/polkadot-protocol.md @@ -671,17 +671,6 @@ These public instances are primarily for ad-hoc testing and quick checks. `TxWrapper` provides the flexibility needed to integrate asset operations into custom applications while maintaining the security and efficiency of Polkadot's transaction model. -### ParaSpell - -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. ### Parachain Node @@ -5077,17 +5066,22 @@ Page Title: Install Polkadot SDK - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md - Canonical (HTML): https://docs.polkadot.com/parachains/install-polkadot-sdk/ -- Summary: Install everything you need to begin working with Substrated-based blockchains and the Polkadot SDK, the framework for building blockchains. +- Summary: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. + +# Install Polkadot SDK -# Install Polkadot SDK Dependencies +This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. -## macOS +Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. + +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -5097,7 +5091,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -5123,7 +5117,7 @@ To install Homebrew: Homebrew 4.3.15 -#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -5131,7 +5125,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -5172,16 +5166,17 @@ To install `openssl` and the Rust toolchain on macOS: rustup component add rust-src ``` -8. [Verify your installation](#verifying-installation). -9. Install `cmake` using the following command: +8. Install `cmake` using the following command: ```bash brew install cmake ``` -## Linux +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). ### Before You Begin {: #before-you-begin-linux } @@ -5204,7 +5199,7 @@ Because the blockchain requires standard cryptography to support the generation To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -5238,7 +5233,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -5268,22 +5263,22 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. [Verify your installation](#verifying-installation). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -### Before You Begin {: #before-you-begin-windows } +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. ### Set Up Windows Subsystem for Linux @@ -5321,12 +5316,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -### Install Required Packages and Rust {: #install-required-packages-and-rust-windows } +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -5369,34 +5364,122 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. [Verify your installation](#verifying-installation). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Build the Polkadot SDK + +After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. + +### Clone the Polkadot SDK + +1. Clone the Polkadot SDK repository: + + ```bash + git clone https://github.com/paritytech/polkadot-sdk.git + ``` + +2. Navigate into the project directory: -## Verifying Installation + ```bash + cd polkadot-sdk + ``` -Verify the configuration of your development environment by running the following command: +### Compile the Polkadot SDK + +Compile the entire Polkadot SDK repository to ensure your environment is properly configured: ```bash -rustup show +cargo build --release --locked ``` -The command displays output similar to the following: +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. -
- rustup show - ... -
- active toolchain - ---------------- - name: stable-aarch64-apple-darwin - active because: it's the default toolchain - installed targets: - aarch64-apple-darwin - wasm32-unknown-unknown -
+### Verify the Build + +Once the build completes successfully, verify the installation by checking the compiled binaries: + +```bash +ls target/release +``` + +You should see several binaries, including: + +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. + +Verify the Polkadot binary works by checking its version: + +```bash +./target/release/polkadot --version +``` + +This should display version information similar to: + +```bash +polkadot 1.16.0-1234abcd567 +``` + +If you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development! + +## Optional: Run the Kitchensink Node + +The Polkadot SDK includes a feature-rich node called "kitchensink" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together. + +!!!note + If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node. + +### Run the Kitchensink Node in Development Mode + +From the `polkadot-sdk` root directory, start the kitchensink node in development mode: + +```bash +./target/release/substrate-node --dev +``` + +The `--dev` flag enables development mode, which: + +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + + +You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. + +### Interact with the Kitchensink Node + +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) + +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) + +You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. + +To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Parachain Zero to Hero Tutorials](/tutorials/polkadot-sdk/parachains/zero-to-hero/){target=\_blank}**: A series of step-by-step guides to building, testing, and deploying custom pallets and runtimes using the Polkadot SDK. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
--- @@ -9409,7 +9492,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. @@ -12510,15 +12593,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools diff --git a/.ai/categories/smart-contracts.md b/.ai/categories/smart-contracts.md index 18e603f60..119b6a2b1 100644 --- a/.ai/categories/smart-contracts.md +++ b/.ai/categories/smart-contracts.md @@ -7918,21 +7918,26 @@ npx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotHubTes --- -Page Title: Install Polkadot SDK Dependencies +Page Title: Install Polkadot SDK - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md - Canonical (HTML): https://docs.polkadot.com/parachains/install-polkadot-sdk/ -- Summary: Install everything you need to begin working with Substrated-based blockchains and the Polkadot SDK, the framework for building blockchains. +- Summary: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. -# Install Polkadot SDK Dependencies +# Install Polkadot SDK -This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. +This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -## macOS +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. + +Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. + +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -7942,7 +7947,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -7968,7 +7973,7 @@ To install Homebrew: Homebrew 4.3.15 -#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -7976,7 +7981,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -8017,16 +8022,17 @@ To install `openssl` and the Rust toolchain on macOS: rustup component add rust-src ``` -8. [Verify your installation](#verifying-installation). -9. Install `cmake` using the following command: +8. Install `cmake` using the following command: ```bash brew install cmake ``` -## Linux +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). ### Before You Begin {: #before-you-begin-linux } @@ -8049,7 +8055,7 @@ Because the blockchain requires standard cryptography to support the generation To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -8083,7 +8089,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -8113,22 +8119,22 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. [Verify your installation](#verifying-installation). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -### Before You Begin {: #before-you-begin-windows } +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. ### Set Up Windows Subsystem for Linux @@ -8166,12 +8172,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -### Install Required Packages and Rust {: #install-required-packages-and-rust-windows } +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -8214,34 +8220,122 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. [Verify your installation](#verifying-installation). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Build the Polkadot SDK + +After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. -## Verifying Installation +### Clone the Polkadot SDK -Verify the configuration of your development environment by running the following command: +1. Clone the Polkadot SDK repository: + + ```bash + git clone https://github.com/paritytech/polkadot-sdk.git + ``` + +2. Navigate into the project directory: + + ```bash + cd polkadot-sdk + ``` + +### Compile the Polkadot SDK + +Compile the entire Polkadot SDK repository to ensure your environment is properly configured: ```bash -rustup show +cargo build --release --locked ``` -The command displays output similar to the following: +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. -
- rustup show - ... -
- active toolchain - ---------------- - name: stable-aarch64-apple-darwin - active because: it's the default toolchain - installed targets: - aarch64-apple-darwin - wasm32-unknown-unknown -
+### Verify the Build + +Once the build completes successfully, verify the installation by checking the compiled binaries: + +```bash +ls target/release +``` + +You should see several binaries, including: + +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. + +Verify the Polkadot binary works by checking its version: + +```bash +./target/release/polkadot --version +``` + +This should display version information similar to: + +```bash +polkadot 1.16.0-1234abcd567 +``` + +If you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development! + +## Optional: Run the Kitchensink Node + +The Polkadot SDK includes a feature-rich node called "kitchensink" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together. + +!!!note + If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node. + +### Run the Kitchensink Node in Development Mode + +From the `polkadot-sdk` root directory, start the kitchensink node in development mode: + +```bash +./target/release/substrate-node --dev +``` + +The `--dev` flag enables development mode, which: + +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + + +You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. + +### Interact with the Kitchensink Node + +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) + +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) + +You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. + +To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Parachain Zero to Hero Tutorials](/tutorials/polkadot-sdk/parachains/zero-to-hero/){target=\_blank}**: A series of step-by-step guides to building, testing, and deploying custom pallets and runtimes using the Polkadot SDK. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
--- @@ -10585,6 +10679,160 @@ Your local development environment is now active and accessible at `http://local You can connect wallets, deploy contracts using Remix or Hardhat, and interact with your smart contracts as you would on any Ethereum-compatible network. +--- + +Page Title: Migration FAQs and Considerations + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-migration.md +- Canonical (HTML): https://docs.polkadot.com/smart-contracts/for-eth-devs/migration/ +- Summary: Learn how to migrate your existing Ethereum contracts to the Polkadot Hub using REVM and PolkaVM by following these considerations. + +# Migration FAQs and Considerations + +## Introduction + +This guide helps Ethereum developers migrate their smart contracts to Polkadot Hub. Most contracts work without modifications on the REVM backend, while the PolkaVM backend offers enhanced performance with minimal adaptation for standard patterns. + +## Migration Considerations + +Take into account the following considerations before migrating your contracts: + +- Standard ERC-20, ERC-721, ERC-1155 tokens work without changes. +- DeFi protocols, DEXs, and AMMs migrate seamlessly. +- DAOs and governance contracts are fully compatible. +- Most Solidity contracts deploy identically to Ethereum. + +## Migration Checklist + +Before migrating your contracts, review this checklist: + +- Factory contracts using PVM bytecode need pre-uploaded dependencies. +- Contracts using `EXTCODECOPY` for runtime manipulation require review (for projects that will use PVM bytecode, not EVM bytecode). +- Replace `transfer()` and `send()` with proper reentrancy guards (for projects that will use PVM bytecode, not EVM bytecode). + +## Migration FAQs + +### Which backend should I choose? + +- Choose REVM if you want: + + - Zero-modification deployment of existing Ethereum contracts. + - Exact EVM behavior for audited code. + - Compatibility with tools that inspect EVM bytecode. + - Rapid deployment without optimization. + +- Choose PolkaVM if you want: + + - Better performance for computation-heavy applications. + - Lower execution costs for intensive operations. + - Access to next-generation smart contract features. + +If you are unsure which to choose, start with REVM for immediate compatibility, then consider PolkaVM for performance optimization once deployed. + +### Do I need to rewrite my Solidity code? + +No, for most contracts. Standard Solidity patterns work on both backends. + +### What about factory contracts? + +- **REVM**: Factory contracts work identically to Ethereum with no changes needed. + + The original factory pattern is: + + ```solidity + contract TokenFactory { + function createToken(string memory name) public returns (address) { + // Creates new contract at runtime + Token newToken = new Token(name); + return address(newToken); + } + } + ``` + +- **PolkaVM**: Factory contracts require pre-uploading dependent contracts. + + Here's how to adapt the original factory pattern: + + ```solidity + contract TokenFactory { + // Reference pre-uploaded Token contract by hash + bytes32 public tokenCodeHash; + + constructor(bytes32 _tokenCodeHash) { + tokenCodeHash = _tokenCodeHash; + } + + function createToken(string memory name) public returns (address) { + // Instantiate from pre-uploaded code + Token newToken = new Token{salt: keccak256(abi.encode(name))}(name); + return address(newToken); + } + } + ``` + +The deployment steps for PolkaVM factories are: + +1. Upload the contract code to the chain. +2. Note the returned code hash. +3. Deploy the Factory contract with the contract code hash. +4. Factory can now instantiate contracts using the pre-uploaded code. + +### How do gas costs compare? + +For more information on gas costs, see the [Gas Model](/smart-contracts/for-eth-devs/gas-model/){target=\_blank} page. + +### Which Solidity features are not supported? + +For REVM, any Solidity feature will function smoothly without requiring changes or adaptations. For PVM, there are considerations, as was mentioned above. + +For PolkaVM, there are some considerations: + +- `EXTCODECOPY`: Only works in constructor code. +- Runtime code modification: Use on-chain constructors instead. +- **Gas stipends**: `address.send()` and `address.transfer()` don't provide reentrancy protection. +- **Unsupported operations**: `pc`, `extcodecopy`, `selfdestruct`, `blobhash`, and `blobbasefee` (blob-related operations). + +### How do I handle the existential deposit? + +Polkadot requires accounts to maintain a minimum balance (existential deposit or ED) to remain active. + +This is handled automatically for you: + +- Balance queries via Ethereum RPC automatically deduct the ED. +- New account transfers include ED in transaction fees. +- Contract-to-contract transfers draw ED from the transaction signer. + +You typically don't need to do anything special, but be aware: + +- Accounts below ED threshold are automatically deleted. +- ED is around 0.01 DOT (varies by network). +- Your contracts don't need to manage this explicitly. + +### Can I use my existing development tools? + +Yes. Both backends support: + +- **Wallets**: [MetaMask](https://metamask.io/){target=\_blank}, [Talisman](https://talisman.xyz/){target=\_blank}, [SubWallet](https://www.subwallet.app/){target=\_blank} +- **Development frameworks**: [Hardhat](/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat/){target=\_blank}, [Foundry](/smart-contracts/cookbook/smart-contracts/deploy-basic/foundry/){target=\_blank}, [Remix](/smart-contracts/cookbook/smart-contracts/deploy-basic/remix/){target=\_blank} (just consider that for PVM bytecode, you will use the Polkadot version of the tooling) +- **Libraries**: [ethers.js](/smart-contracts/libraries/ethers-js/){target=\_blank}, [web3.js](/smart-contracts/libraries/web3-js/){target=\_blank}, [viem](/smart-contracts/libraries/viem/){target=\_blank} +- **Testing tools**: Your existing test suites work + +Connect to Polkadot Hub's Ethereum JSON-RPC endpoint and use your familiar workflow. + +## Conclusion + +Most Ethereum contracts migrate to Polkadot Hub with minimal or no changes. Use REVM for seamless compatibility or PolkaVM for enhanced performance. + +There are a few key points to keep in mind during migration: + +- Replace `transfer()` and `send()` with `.call{value}("")` and use reentrancy guards (for projects that will use PVM bytecode, not EVM bytecode). +- PolkaVM factory contracts using PVM bytecode need pre-uploaded dependencies. +- Don't hardcode gas values. +- Test thoroughly on [TestNet](/smart-contracts/connect/#__tabbed_1_1){target=\_blank} before mainnet deployment. + +Your existing Solidity knowledge and tooling transfer directly to Polkadot Hub, making migration straightforward for standard smart contract patterns. + + --- Page Title: Networks @@ -13407,7 +13655,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. @@ -19049,15 +19297,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools diff --git a/.ai/categories/tooling.md b/.ai/categories/tooling.md index fef3b4da3..68685d566 100644 --- a/.ai/categories/tooling.md +++ b/.ai/categories/tooling.md @@ -13505,17 +13505,22 @@ Page Title: Install Polkadot SDK - Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md - Canonical (HTML): https://docs.polkadot.com/parachains/install-polkadot-sdk/ -- Summary: Install everything you need to begin working with Substrated-based blockchains and the Polkadot SDK, the framework for building blockchains. +- Summary: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. -# Install Polkadot SDK Dependencies +# Install Polkadot SDK -This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. +This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -## macOS +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. + +Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. + +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -13525,7 +13530,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -13551,7 +13556,7 @@ To install Homebrew: Homebrew 4.3.15 -#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -13559,7 +13564,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -13600,16 +13605,17 @@ To install `openssl` and the Rust toolchain on macOS: rustup component add rust-src ``` -8. [Verify your installation](#verifying-installation). -9. Install `cmake` using the following command: +8. Install `cmake` using the following command: ```bash brew install cmake ``` -## Linux +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). ### Before You Begin {: #before-you-begin-linux } @@ -13632,7 +13638,7 @@ Because the blockchain requires standard cryptography to support the generation To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -13666,7 +13672,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -13696,22 +13702,22 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. [Verify your installation](#verifying-installation). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -### Before You Begin {: #before-you-begin-windows } +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. ### Set Up Windows Subsystem for Linux @@ -13749,12 +13755,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -### Install Required Packages and Rust {: #install-required-packages-and-rust-windows } +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -13797,34 +13803,122 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. [Verify your installation](#verifying-installation). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). + +## Build the Polkadot SDK + +After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. -## Verifying Installation +### Clone the Polkadot SDK -Verify the configuration of your development environment by running the following command: +1. Clone the Polkadot SDK repository: + + ```bash + git clone https://github.com/paritytech/polkadot-sdk.git + ``` + +2. Navigate into the project directory: + + ```bash + cd polkadot-sdk + ``` + +### Compile the Polkadot SDK + +Compile the entire Polkadot SDK repository to ensure your environment is properly configured: ```bash -rustup show +cargo build --release --locked ``` -The command displays output similar to the following: +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. -
- rustup show - ... -
- active toolchain - ---------------- - name: stable-aarch64-apple-darwin - active because: it's the default toolchain - installed targets: - aarch64-apple-darwin - wasm32-unknown-unknown -
+### Verify the Build + +Once the build completes successfully, verify the installation by checking the compiled binaries: + +```bash +ls target/release +``` + +You should see several binaries, including: + +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. + +Verify the Polkadot binary works by checking its version: + +```bash +./target/release/polkadot --version +``` + +This should display version information similar to: + +```bash +polkadot 1.16.0-1234abcd567 +``` + +If you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development! + +## Optional: Run the Kitchensink Node + +The Polkadot SDK includes a feature-rich node called "kitchensink" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together. + +!!!note + If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node. + +### Run the Kitchensink Node in Development Mode + +From the `polkadot-sdk` root directory, start the kitchensink node in development mode: + +```bash +./target/release/substrate-node --dev +``` + +The `--dev` flag enables development mode, which: + +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + + +You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. + +### Interact with the Kitchensink Node + +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) + +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) + +You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. + +To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Parachain Zero to Hero Tutorials](/tutorials/polkadot-sdk/parachains/zero-to-hero/){target=\_blank}**: A series of step-by-step guides to building, testing, and deploying custom pallets and runtimes using the Polkadot SDK. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
--- @@ -18727,7 +18821,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. @@ -25641,15 +25735,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools @@ -25913,7 +25999,7 @@ export default buildModule("StorageModule", (m) => { Deploy the contract to Polkadot Hub TestNet: ```bash -npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotHub +npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet ``` You should see output similar to: diff --git a/.ai/pages/chain-interactions-send-transactions-interoperability-transfer-assets-parachains.md b/.ai/pages/chain-interactions-send-transactions-interoperability-transfer-assets-parachains.md index d7f85a2ee..8b85b616f 100644 --- a/.ai/pages/chain-interactions-send-transactions-interoperability-transfer-assets-parachains.md +++ b/.ai/pages/chain-interactions-send-transactions-interoperability-transfer-assets-parachains.md @@ -1,14 +1,14 @@ --- -title: Transfer Tokens Between Parachains +title: Transfer Assets Between Parachains description: A step-by-step guide to using the ParaSpell XCM SDK to build, verify, and execute a transfer from one Parachain to another. url: https://docs.polkadot.com/chain-interactions/send-transactions/interoperability/transfer-assets-parachains/ --- -# Transfer Tokens Between Parachains +# Transfer Assets Between Parachains ## Introduction -This guide walks you through transferring tokens between two parachains using the [ParaSpell XCM SDK](https://paraspell.github.io/docs/){target=\_blank}. This example utilizes [Asset Hub](/polkadot-protocol/architecture/system-chains/asset-hub/){target=\_blank} and the [People Chain](/polkadot-protocol/architecture/system-chains/people/){target=\_blank}. However, the same approach can be applied to transfers between other parachains. +This guide walks you through transferring tokens between two parachains using the [ParaSpell XCM SDK](/reference/tools/paraspell/){target=\_blank}. This example utilizes [Asset Hub](/polkadot-protocol/architecture/system-chains/asset-hub/){target=\_blank} and the [People Chain](/polkadot-protocol/architecture/system-chains/people/){target=\_blank}. However, the same approach can be applied to transfers between other parachains. For development purposes, this guide will use the [Polkadot TestNet](/develop/networks/#paseo){target=\_blank}, so the transferred token will be PAS. @@ -16,7 +16,7 @@ In this guide, you will: - Build an XCM transfer transaction using ParaSpell XCM SDK. - Perform a dry run to validate the transfer. -- Verify the [Existential Deposit (ED)](/polkadot-protocol/glossary/#existential-deposit){target=\_blank} requirement on the destination chain. +- Verify the [Existential Deposit (ED)](/reference/glossary/#existential-deposit){target=\_blank} requirement on the destination chain. - Retrieve information regarding the transfer, along with fee estimates. - Submit the transaction. @@ -24,30 +24,36 @@ In this guide, you will: Before you begin, ensure you have the following: -- Knowledge of the [fundamentals of Polkadot](/polkadot-protocol/parachain-basics/){target=\_blank}. -- Basic understanding of [XCM](/develop/interoperability/intro-to-xcm/){target=\_blank}. +- Knowledge of the [fundamentals of Polkadot](/parachains/get-started/){target=\_blank}. +- Basic understanding of [XCM](/parachains/interoperability/get-started/){target=\_blank}. - Basic familiarity with JavaScript or TypeScript. -- Installed [bun](https://bun.com/docs/installation){target=\_blank}, a JavaScript and TypeScript package manager. +- Installed [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm){target=\_blank}, a JavaScript and TypeScript package manager. ## Initialize Your Project Create the project folder: ```bash -mkdir paraspell-transfer +mkdir paraspell-transfer && \ cd paraspell-transfer ``` Initialize the JavaScript project: ```bash -bun init -y +npm init -y +``` + +Install dev dependencies: + +```bash +npm install --save-dev @types/node@^22.12.0 tsx@^4.20.6 typescript@^5.7.3 ``` Install the required dependencies: ```bash -bun add @paraspell/sdk@11.3.2 polkadot-api@1.17.1 @polkadot-labs/hdkd-helpers@0.0.25 @polkadot-labs/hdkd@0.0.24 +npm install --save @paraspell/sdk@11.12.6 polkadot-api@1.20.0 @polkadot-labs/hdkd-helpers@0.0.26 @polkadot-labs/hdkd@0.0.25 ``` Now add the following setup code to `index.ts`: @@ -154,13 +160,13 @@ dryRunTransfer(); Run the script using the following command: ```bash -bun run index.ts +npx tsx index.ts ``` The result of the dry run will look similar to the following example output:
- bun run index.ts + npx tsx index.ts { failureReason: undefined, failureChain: undefined, @@ -313,13 +319,13 @@ verifyED(); Comment out the `dryRunTransfer()` function so that it is not executed again. Then, execute the `verifyED()` by running the following command: ```bash -bun run index.ts +npx tsx index.ts ``` After that, you will get output confirming the ED which will look similar to the following:
- bun run index.ts + npx tsx index.ts ED verification successful.
## Get Transfer Info and Fee Estimates @@ -351,13 +357,13 @@ XcmTransferInfo(); Comment out the `verifyED()` function so it doesn't execute again. Then, execute the `XcmTransferInfo()` function by running the following command: ```bash -bun run index.ts +npx tsx index.ts ``` You will see all the information for your transfer similar to the following example:
- bun run index.ts + npx tsx index.ts Transfer Info: { chain: { origin: "AssetHubPaseo", @@ -420,13 +426,13 @@ transfer(); Comment out the `XcmTransferInfo()` function so it doesn't execute again. Then, execute the transfer by running the following command: ```bash -bun run index.ts +npx tsx index.ts ``` Your `transfer` function will submit the transaction, and you will get the following output:
- bun run index.ts + npx tsx index.ts ... Built transaction: { getPaymentInfo: [AsyncFunction: getPaymentInfo], @@ -873,4 +879,4 @@ You have now successfully created and sent a cross-chain transfer using the Para - Read the Docs: Dive deeper into the features of the [ParaSpell XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.html){target=\_blank} documentation. -- Learn about XCM: Understand the underlying protocol by visiting the [Introduction to XCM page](/develop/interoperability/intro-to-xcm/) in the Polkadot Docs. +- Learn about XCM: Understand the underlying protocol by visiting the [Introduction to XCM page](/parachains/interoperability/get-started/) in the Polkadot Docs. diff --git a/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md b/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md index eda88f870..e4d53a6e1 100644 --- a/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md +++ b/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md @@ -50,9 +50,9 @@ Any language that can compile to PolkaVM bytecode and utilize `pallet-revive`'s ### Key Benefits -- **Unified Platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet. +- **Unified platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet. - **Performance**: PolkaVM execution provides improved performance compared to the traditional EVM, leveraging the [RISC-V](https://en.wikipedia.org/wiki/RISC-V){target=\_blank} architecture to map instructions to the CPU and requires little transpiling. -- **Ethereum Compatibility**: Supports full integration with Ethereum tooling via RPC adapter. +- **Ethereum compatibility**: Supports full integration with Ethereum tooling via RPC adapter. ### Implementation Examples @@ -70,7 +70,7 @@ Frontier offers flexible integration depending on your compatibility needs: For basic EVM support using Polkadot SDK native APIs: -- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment +- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment. This configuration allows EVM contract execution but requires using Polkadot SDK-specific APIs for interaction. @@ -84,20 +84,20 @@ For complete Ethereum ecosystem integration with Ethereum RPC support: ### Key Benefits -- **Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Truffle, and other Ethereum development tools -- **Minimal-friction migration**: Deployment of existing Ethereum dApps with minimal or no modifications -- **Native Ethereum formats**: Support for Ethereum transaction formats, signatures, and gas mechanics -- **Block emulation**: Ethereum-style block structure within Substrate's block production +- **Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Foundry, and other Ethereum development tools. +- **Minimal-friction migration**: Deployment of existing Ethereum dApps with minimal or no modifications. +- **Native Ethereum formats**: Support for Ethereum transaction formats, signatures, and gas mechanics. +- **Block emulation**: Ethereum-style block structure within Substrate's block production. ### Implementation Examples Production implementations demonstrate Frontier's capabilities: -- **Moonbeam**: See their implementation of [`pallet-evm`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L532){target=\_blank} and [`pallet-ethereum`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L698){target=\_blank} +- **Moonbeam**: See their implementation of [`pallet-evm`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L532){target=\_blank} and [`pallet-ethereum`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L698){target=\_blank}. ## pallet-contracts (Legacy) -[`pallet-contracts`](https://docs.rs/pallet-contracts/latest/pallet_contracts/index.html#contracts-pallet){target=\_blank} is the original Wasm-based smart contract pallet for Polkadot SDK chains. While still functional, it's considered legacy as development efforts have shifted to pallet-revive. +[`pallet-contracts`](https://docs.rs/pallet-contracts/latest/pallet_contracts/index.html#contracts-pallet){target=\_blank} is the original Wasm-based smart contract pallet for Polkadot SDK chains. While still functional, it's considered legacy as development efforts have shifted to `pallet-revive`. ### Implementation Example diff --git a/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md b/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md index 329c62040..61f94af8d 100644 --- a/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md +++ b/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md @@ -117,7 +117,123 @@ This setup imports: Here's the complete pallet code that you'll be testing throughout this guide: ```rust - + #![cfg_attr(not(feature = "std"), no_std)] + + pub use pallet::*; + + #[frame::pallet] + pub mod pallet { + use frame::prelude::*; + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + + #[pallet::constant] + type CounterMaxValue: Get; + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + CounterValueSet { + new_value: u32, + }, + CounterIncremented { + new_value: u32, + who: T::AccountId, + amount: u32, + }, + CounterDecremented { + new_value: u32, + who: T::AccountId, + amount: u32, + }, + } + + #[pallet::error] + pub enum Error { + NoneValue, + Overflow, + Underflow, + CounterMaxValueExceeded, + } + + #[pallet::storage] + pub type CounterValue = StorageValue<_, u32, ValueQuery>; + + #[pallet::storage] + pub type UserInteractions = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + u32, + ValueQuery + >; + + #[pallet::genesis_config] + #[derive(DefaultNoBound)] + pub struct GenesisConfig { + pub initial_counter_value: u32, + pub initial_user_interactions: Vec<(T::AccountId, u32)>, + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) { + CounterValue::::put(self.initial_counter_value); + for (account, count) in &self.initial_user_interactions { + UserInteractions::::insert(account, count); + } + } + } + + #[pallet::call] + impl Pallet { + #[pallet::call_index(0)] + #[pallet::weight(0)] + pub fn set_counter_value(origin: OriginFor, new_value: u32) -> DispatchResult { + ensure_root(origin)?; + ensure!(new_value <= T::CounterMaxValue::get(), Error::::CounterMaxValueExceeded); + CounterValue::::put(new_value); + Self::deposit_event(Event::CounterValueSet { new_value }); + Ok(()) + } + + #[pallet::call_index(1)] + #[pallet::weight(0)] + pub fn increment(origin: OriginFor, amount: u32) -> DispatchResult { + let who = ensure_signed(origin)?; + let current_value = CounterValue::::get(); + let new_value = current_value.checked_add(amount).ok_or(Error::::Overflow)?; + ensure!(new_value <= T::CounterMaxValue::get(), Error::::CounterMaxValueExceeded); + CounterValue::::put(new_value); + UserInteractions::::mutate(&who, |count| { + *count = count.saturating_add(1); + }); + Self::deposit_event(Event::CounterIncremented { new_value, who, amount }); + Ok(()) + } + + #[pallet::call_index(2)] + #[pallet::weight(0)] + pub fn decrement(origin: OriginFor, amount: u32) -> DispatchResult { + let who = ensure_signed(origin)?; + let current_value = CounterValue::::get(); + let new_value = current_value.checked_sub(amount).ok_or(Error::::Underflow)?; + CounterValue::::put(new_value); + UserInteractions::::mutate(&who, |count| { + *count = count.saturating_add(1); + }); + Self::deposit_event(Event::CounterDecremented { new_value, who, amount }); + Ok(()) + } + } + } + ``` ## Write Your First Test @@ -170,7 +286,7 @@ running 1 test test tests::increment_works ... ok ``` -🎉 Congratulations! You've written and run your first pallet test. +Congratulations! You've written and run your first pallet test. ## Test Error Conditions @@ -361,7 +477,7 @@ test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid. -🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! +Congratulations! You have a well-tested pallet covering the essential testing patterns! These tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality. diff --git a/.ai/pages/parachains-install-polkadot-sdk.md b/.ai/pages/parachains-install-polkadot-sdk.md index 020eb6a42..ce4bdce00 100644 --- a/.ai/pages/parachains-install-polkadot-sdk.md +++ b/.ai/pages/parachains-install-polkadot-sdk.md @@ -1,6 +1,6 @@ --- title: Install Polkadot SDK -description: Install everything you need to begin working with the Polkadot SDK, the framework for building blockchains. +description: Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. categories: Basics, Tooling url: https://docs.polkadot.com/parachains/install-polkadot-sdk/ --- @@ -9,18 +9,16 @@ url: https://docs.polkadot.com/parachains/install-polkadot-sdk/ This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts: -1. **Installing Dependencies** - Setting up Rust, required system packages, and development tools -2. **Building the Polkadot SDK** - Cloning and compiling the Polkadot SDK repository +- **Installing dependencies**: Setting up Rust, required system packages, and development tools. +- **Building the Polkadot SDK**: Cloning and compiling the Polkadot SDK repository. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly. -## Part 1: Install Dependencies - -### macOS +## Install Dependencies: macOS You can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors. -#### Before You Begin +### Before You Begin {: #before-you-begin-mac-os } Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements: @@ -30,7 +28,7 @@ Before you install Rust and set up your development environment on macOS, verify - Storage of at least 10 GB of available space. - Broadband Internet connection. -#### Install Homebrew +### Install Homebrew In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing. @@ -56,7 +54,7 @@ To install Homebrew: Homebrew 4.3.15
-#### Support for Apple Silicon +### Support for Apple Silicon Protobuf must be installed before the build process can begin. To install it, run the following command: @@ -64,7 +62,7 @@ Protobuf must be installed before the build process can begin. To install it, ru brew install protobuf ``` -#### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os } Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`. @@ -111,13 +109,13 @@ To install `openssl` and the Rust toolchain on macOS: brew install cmake ``` -9. Proceed to [Part 2: Build the Polkadot SDK](#part-2-build-the-polkadot-sdk). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -### Linux +## Install Dependencies: Linux -Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE). +Rust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE). -#### Before You Begin +### Before You Begin {: #before-you-begin-linux } Check the documentation for your operating system for information about the installed packages and how to download and install any additional packages you might need. For example, if you use Ubuntu, you can use the Ubuntu Advanced Packaging Tool (`apt`) to install the `build-essential` package: @@ -133,12 +131,12 @@ clang curl git make Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `libssl-dev` or `openssl-devel`. -#### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-linux } To install the Rust toolchain on Linux: 1. Open a terminal shell. -2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution. +2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution. 3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution: === "Ubuntu" @@ -172,7 +170,7 @@ To install the Rust toolchain on Linux: sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf ``` - Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. + Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS. 4. Download the `rustup` installation program and use it to install Rust by running the following command: @@ -202,24 +200,24 @@ To install the Rust toolchain on Linux: rustup component add rust-src ``` -9. Proceed to [Part 2: Build the Polkadot SDK](#part-2-build-the-polkadot-sdk). +9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -### Windows (WSL) +## Install Dependencies: Windows (WSL) In general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains. However, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment. -#### Before You Begin +### Before You Begin {: #before-you-begin-windows-wls } Before installing on Microsoft Windows, verify the following basic requirements: - You have a computer running a supported Microsoft Windows operating system: - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL. - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system. -- You have good internet connection and access to a shell terminal on your local computer. +- You have a good internet connection and access to a shell terminal on your local computer. -#### Set Up Windows Subsystem for Linux +### Set Up Windows Subsystem for Linux WSL enables you to emulate a Linux environment on a computer that uses the Windows operating system. The primary advantage of this approach for Substrate development is that you can use all of the code and command-line examples as described in the Substrate documentation. For example, you can run common commands—such as `ls` and `ps`—unmodified. By using WSL, you can avoid configuring a virtual machine image or a dual-boot operating system. @@ -255,12 +253,12 @@ To prepare a development environment using WSL: For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\_blank} docs. -#### Install Required Packages and Rust +### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls } To install the Rust toolchain on WSL: 1. Click the **Start** menu, then select **Ubuntu**. -2. Type a UNIX user name to create user account. +2. Type a UNIX user name to create a user account. 3. Type a password for your UNIX user, then retype the password to confirm it. 4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command: @@ -303,9 +301,9 @@ To install the Rust toolchain on WSL: rustup component add rust-src ``` -11. Proceed to [Part 2: Build the Polkadot SDK](#part-2-build-the-polkadot-sdk). +11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk). -## Part 2: Build the Polkadot SDK +## Build the Polkadot SDK After installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup. @@ -331,8 +329,8 @@ Compile the entire Polkadot SDK repository to ensure your environment is properl cargo build --release --locked ``` -!!!warning - This initial compilation will take significant time (30-60 minutes or more) depending on your machine specifications. The `--release` flag optimizes for performance. This step compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. +!!!note + This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured. ### Verify the Build @@ -342,12 +340,12 @@ Once the build completes successfully, verify the installation by checking the c ls target/release ``` -You should see several binaries including: +You should see several binaries, including: -- `polkadot` - The Polkadot relay chain node -- `polkadot-parachain` - The parachain collator node -- `polkadot-omni-node` - The omni node for running parachains -- `substrate-node` - The kitchensink node with many pre-configured pallets +- `polkadot`: The Polkadot relay chain node. +- `polkadot-parachain`: The parachain collator node. +- `polkadot-omni-node`:The omni node for running parachains. +- `substrate-node`: The kitchensink node with many pre-configured pallets. Verify the Polkadot binary works by checking its version: @@ -380,21 +378,27 @@ From the `polkadot-sdk` root directory, start the kitchensink node in developmen The `--dev` flag enables development mode, which: -- Runs a single-node development chain -- Produces and finalizes blocks automatically -- Uses pre-configured development accounts (Alice, Bob, etc.) -- Deletes all data when stopped, ensuring a clean state on restart +- Runs a single-node development chain. +- Produces and finalizes blocks automatically. +- Uses pre-configured development accounts (Alice, Bob, etc.). +- Deletes all data when stopped, ensuring a clean state on restart. + You should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`. ### Interact with the Kitchensink Node -The kitchensink node is accessible at `ws://localhost:9944`. To explore its features using the Polkadot.js Apps interface: +The kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your browser to explore its features and connect to the local node. + +1. Click the network icon in the top left corner. +2. Scroll to **Development** and select **Local Node**. +3. Click **Switch** to connect to your local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp) -1. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} in your web browser -2. Click the network icon in the top left corner -3. Scroll to **Development** and select **Local Node** -4. Click **Switch** to connect to your local node +Once connected, the interface updates its color scheme to indicate a successful connection to the local node. + +![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp) You can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications. @@ -402,4 +406,14 @@ To stop the node, press `Control-C` in the terminal. ## Where to Go Next -- **[Get Started with Parachain Development](/parachains/get-started/){target=\_blank}**: Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. +
+ +- __Get Started with Parachain Development__ + + --- + + Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. + + [:octicons-arrow-right-24: Get Started](/parachains/get-started/) + +
diff --git a/.ai/pages/parachains-launch-a-parachain-set-up-the-parachain-template.md b/.ai/pages/parachains-launch-a-parachain-set-up-the-parachain-template.md index 3b0b0260e..906950754 100644 --- a/.ai/pages/parachains-launch-a-parachain-set-up-the-parachain-template.md +++ b/.ai/pages/parachains-launch-a-parachain-set-up-the-parachain-template.md @@ -26,7 +26,7 @@ By the end of this guide, you'll have a working template ready to customize and Before getting started, ensure you have done the following: -- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment +- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\_blank} and the required packages to set up your development environment. For this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version. diff --git a/.ai/pages/reference-polkadot-hub-assets-and-smart-contracts.md b/.ai/pages/reference-polkadot-hub-assets-and-smart-contracts.md index 0dcbd4a79..4773cc0df 100644 --- a/.ai/pages/reference-polkadot-hub-assets-and-smart-contracts.md +++ b/.ai/pages/reference-polkadot-hub-assets-and-smart-contracts.md @@ -150,17 +150,6 @@ These public instances are primarily for ad-hoc testing and quick checks. `TxWrapper` provides the flexibility needed to integrate asset operations into custom applications while maintaining the security and efficiency of Polkadot's transaction model. -### ParaSpell - -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. ### Parachain Node diff --git a/.ai/pages/reference-tools-paraspell.md b/.ai/pages/reference-tools-paraspell.md index 240c80f44..f285118e8 100644 --- a/.ai/pages/reference-tools-paraspell.md +++ b/.ai/pages/reference-tools-paraspell.md @@ -14,12 +14,12 @@ The primary goal of ParaSpell is to abstract away the complexities of the XCM pr The ParaSpell suite includes: -- **[XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.html){target=\_blank}**: A powerful library for integrating XCM interoperability into dApps. -- **[XCM API](https://paraspell.github.io/docs/api/g-started.html){target=\_blank}**: A lightweight alternative to the SDK for package-less integration. -- **[XCM Router](https://paraspell.github.io/docs/router/getting-strtd.html){target=\_blank}**: A tool for enabling cross-chain swaps of different assets in a single transaction. -- **[XCM Analyser](https://paraspell.github.io/docs/analyser/getng-strtd.html){target=\_blank}**: A utility for decoding and translating complex XCM data into a human-readable format. -- **[XCM Visualizator](https://paraspell.github.io/docs/visualizer/getting-start.html){target=\_blank}**: A tool for visualizing XCM activity across the Polkadot ecosystem. -- **[XCM Playground](https://paraspell.github.io/docs/tools/playground.html){target=\_blank}**: A tool for testing different XCM scenarios. +- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. +- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. +- **[XCM Router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). +- **[XCM Analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. +- **[XCM Visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. +- **[XCM Playground](https://paraspell.xyz/#try-it){target=\_blank}**: An interactive playground for testing different XCM scenarios. ### ParaSpell XCM SDK @@ -28,3 +28,42 @@ The [ParaSpell XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.htm The SDK simplifies the process of creating and sending XCM messages by providing a user-friendly builder pattern. This allows developers to construct complex XCM calls with just a few lines of code, reducing the likelihood of errors and ensuring that messages are constructed correctly. By using the ParaSpell XCM SDK, developers can significantly accelerate their development workflow and build powerful, interoperable dApps that take full advantage of the Polkadot network's cross-chain capabilities. + +## Install ParaSpell + +If you want to use ParaSpell in your project you can add it as a dependency with the following command: + +=== "npm" + + ```bash + npm install --save @paraspell/sdk@11.12.6 + ``` + +=== "pnpm" + + ```bash + pnpm add @paraspell/sdk@11.12.6 + ``` + +=== "yarn" + + ```bash + yarn add @paraspell/sdk@11.12.6 + ``` + + +## Where to Go Next + +Explore more about ParaSpell through these resources: + +
+ +- Tutorial __Transfer Assets Between Parachains__ + + --- + + Learn how to transfer assets across chains with ParaSpell. + + [:octicons-arrow-right-24: Get Started](/chain-interactions/send-transactions/interoperability/transfer-assets-parachains/) + +
diff --git a/.ai/pages/reference-tools-xcm-tools.md b/.ai/pages/reference-tools-xcm-tools.md index 84a46ffde..dad6dfb50 100644 --- a/.ai/pages/reference-tools-xcm-tools.md +++ b/.ai/pages/reference-tools-xcm-tools.md @@ -37,15 +37,7 @@ For a full overview of each script, visit the [scripts](https://github.com/Moons ### ParaSpell -[ParaSpell](https://paraspell.xyz/){target=\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are: - -- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions. -- **[XCM API](https://paraspell.xyz/#xcm-api){target=\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance. -- **[XCM router](https://paraspell.xyz/#xcm-router){target=\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar). -- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging. -- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow. - -ParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications. +[ParaSpell](/reference/tools/paraspell/){target=\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization. ### Astar XCM Tools diff --git a/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md b/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md index d2c8e9ade..b0cc72fa0 100644 --- a/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md +++ b/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md @@ -213,7 +213,7 @@ export default buildModule("StorageModule", (m) => { Deploy the contract to Polkadot Hub TestNet: ```bash -npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotHub +npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet ``` You should see output similar to: diff --git a/.ai/pages/smart-contracts-for-eth-devs-migration.md b/.ai/pages/smart-contracts-for-eth-devs-migration.md index e791fd24d..58c91eb15 100644 --- a/.ai/pages/smart-contracts-for-eth-devs-migration.md +++ b/.ai/pages/smart-contracts-for-eth-devs-migration.md @@ -1,5 +1,151 @@ --- +title: Migration FAQs and Considerations +description: Learn how to migrate your existing Ethereum contracts to the Polkadot Hub using REVM and PolkaVM by following these considerations. +categories: Smart Contracts url: https://docs.polkadot.com/smart-contracts/for-eth-devs/migration/ --- -TODO +# Migration FAQs and Considerations + +## Introduction + +This guide helps Ethereum developers migrate their smart contracts to Polkadot Hub. Most contracts work without modifications on the REVM backend, while the PolkaVM backend offers enhanced performance with minimal adaptation for standard patterns. + +## Migration Considerations + +Take into account the following considerations before migrating your contracts: + +- Standard ERC-20, ERC-721, ERC-1155 tokens work without changes. +- DeFi protocols, DEXs, and AMMs migrate seamlessly. +- DAOs and governance contracts are fully compatible. +- Most Solidity contracts deploy identically to Ethereum. + +## Migration Checklist + +Before migrating your contracts, review this checklist: + +- Factory contracts using PVM bytecode need pre-uploaded dependencies. +- Contracts using `EXTCODECOPY` for runtime manipulation require review (for projects that will use PVM bytecode, not EVM bytecode). +- Replace `transfer()` and `send()` with proper reentrancy guards (for projects that will use PVM bytecode, not EVM bytecode). + +## Migration FAQs + +### Which backend should I choose? + +- Choose REVM if you want: + + - Zero-modification deployment of existing Ethereum contracts. + - Exact EVM behavior for audited code. + - Compatibility with tools that inspect EVM bytecode. + - Rapid deployment without optimization. + +- Choose PolkaVM if you want: + + - Better performance for computation-heavy applications. + - Lower execution costs for intensive operations. + - Access to next-generation smart contract features. + +If you are unsure which to choose, start with REVM for immediate compatibility, then consider PolkaVM for performance optimization once deployed. + +### Do I need to rewrite my Solidity code? + +No, for most contracts. Standard Solidity patterns work on both backends. + +### What about factory contracts? + +- **REVM**: Factory contracts work identically to Ethereum with no changes needed. + + The original factory pattern is: + + ```solidity + contract TokenFactory { + function createToken(string memory name) public returns (address) { + // Creates new contract at runtime + Token newToken = new Token(name); + return address(newToken); + } + } + ``` + +- **PolkaVM**: Factory contracts require pre-uploading dependent contracts. + + Here's how to adapt the original factory pattern: + + ```solidity + contract TokenFactory { + // Reference pre-uploaded Token contract by hash + bytes32 public tokenCodeHash; + + constructor(bytes32 _tokenCodeHash) { + tokenCodeHash = _tokenCodeHash; + } + + function createToken(string memory name) public returns (address) { + // Instantiate from pre-uploaded code + Token newToken = new Token{salt: keccak256(abi.encode(name))}(name); + return address(newToken); + } + } + ``` + +The deployment steps for PolkaVM factories are: + +1. Upload the contract code to the chain. +2. Note the returned code hash. +3. Deploy the Factory contract with the contract code hash. +4. Factory can now instantiate contracts using the pre-uploaded code. + +### How do gas costs compare? + +For more information on gas costs, see the [Gas Model](/smart-contracts/for-eth-devs/gas-model/){target=\_blank} page. + +### Which Solidity features are not supported? + +For REVM, any Solidity feature will function smoothly without requiring changes or adaptations. For PVM, there are considerations, as was mentioned above. + +For PolkaVM, there are some considerations: + +- `EXTCODECOPY`: Only works in constructor code. +- Runtime code modification: Use on-chain constructors instead. +- **Gas stipends**: `address.send()` and `address.transfer()` don't provide reentrancy protection. +- **Unsupported operations**: `pc`, `extcodecopy`, `selfdestruct`, `blobhash`, and `blobbasefee` (blob-related operations). + +### How do I handle the existential deposit? + +Polkadot requires accounts to maintain a minimum balance (existential deposit or ED) to remain active. + +This is handled automatically for you: + +- Balance queries via Ethereum RPC automatically deduct the ED. +- New account transfers include ED in transaction fees. +- Contract-to-contract transfers draw ED from the transaction signer. + +You typically don't need to do anything special, but be aware: + +- Accounts below ED threshold are automatically deleted. +- ED is around 0.01 DOT (varies by network). +- Your contracts don't need to manage this explicitly. + +### Can I use my existing development tools? + +Yes. Both backends support: + +- **Wallets**: [MetaMask](https://metamask.io/){target=\_blank}, [Talisman](https://talisman.xyz/){target=\_blank}, [SubWallet](https://www.subwallet.app/){target=\_blank} +- **Development frameworks**: [Hardhat](/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat/){target=\_blank}, [Foundry](/smart-contracts/cookbook/smart-contracts/deploy-basic/foundry/){target=\_blank}, [Remix](/smart-contracts/cookbook/smart-contracts/deploy-basic/remix/){target=\_blank} (just consider that for PVM bytecode, you will use the Polkadot version of the tooling) +- **Libraries**: [ethers.js](/smart-contracts/libraries/ethers-js/){target=\_blank}, [web3.js](/smart-contracts/libraries/web3-js/){target=\_blank}, [viem](/smart-contracts/libraries/viem/){target=\_blank} +- **Testing tools**: Your existing test suites work + +Connect to Polkadot Hub's Ethereum JSON-RPC endpoint and use your familiar workflow. + +## Conclusion + +Most Ethereum contracts migrate to Polkadot Hub with minimal or no changes. Use REVM for seamless compatibility or PolkaVM for enhanced performance. + +There are a few key points to keep in mind during migration: + +- Replace `transfer()` and `send()` with `.call{value}("")` and use reentrancy guards (for projects that will use PVM bytecode, not EVM bytecode). +- PolkaVM factory contracts using PVM bytecode need pre-uploaded dependencies. +- Don't hardcode gas values. +- Test thoroughly on [TestNet](/smart-contracts/connect/#__tabbed_1_1){target=\_blank} before mainnet deployment. + +Your existing Solidity knowledge and tooling transfer directly to Polkadot Hub, making migration straightforward for standard smart contract patterns. diff --git a/.ai/site-index.json b/.ai/site-index.json index f9e03970a..64e6e3326 100644 --- a/.ai/site-index.json +++ b/.ai/site-index.json @@ -17,7 +17,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -38,7 +37,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -59,7 +57,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -80,7 +77,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -101,7 +97,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -122,7 +117,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -234,7 +228,6 @@ "estimated_token_count_total": 4830 }, "hash": "sha256:a6bf7623a535e7a9162c0913b07bd59d43c8535025ad8225fb3e5adc83084c7a", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -306,7 +299,6 @@ "estimated_token_count_total": 7755 }, "hash": "sha256:086a87823ab67ceac102358030e316583cd733c0ec326316e7f29061fe7f6934", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -327,19 +319,18 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { "id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", - "title": "Transfer Tokens Between Parachains", + "title": "Transfer Assets Between Parachains", "slug": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "categories": [ "Uncategorized" ], "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-send-transactions-interoperability-transfer-assets-parachains.md", "html_url": "https://docs.polkadot.com/chain-interactions/send-transactions/interoperability/transfer-assets-parachains/", - "preview": "This guide walks you through transferring tokens between two parachains using the [ParaSpell XCM SDK](https://paraspell.github.io/docs/){target=\\_blank}. This example utilizes [Asset Hub](/polkadot-protocol/architecture/system-chains/asset-hub/){target=\\_blank} and the [People Chain](/polkadot-protocol/architecture/system-chains/people/){target=\\_blank}. However, the same approach can be applied to transfers between other parachains.", + "preview": "This guide walks you through transferring tokens between two parachains using the [ParaSpell XCM SDK](/reference/tools/paraspell/){target=\\_blank}. This example utilizes [Asset Hub](/polkadot-protocol/architecture/system-chains/asset-hub/){target=\\_blank} and the [People Chain](/polkadot-protocol/architecture/system-chains/people/){target=\\_blank}. However, the same approach can be applied to transfers between other parachains.", "outline": [ { "depth": 2, @@ -383,13 +374,12 @@ } ], "stats": { - "chars": 26623, - "words": 2267, + "chars": 26764, + "words": 2289, "headings": 8, - "estimated_token_count_total": 5207 + "estimated_token_count_total": 5257 }, - "hash": "sha256:91f59a76dd33641ca2b5bf6d58230f65034fa3cc5f8313525fb57e854a878a56", - "last_modified": "2025-10-28T14:42:10+00:00", + "hash": "sha256:681b3f8e3bae1727c0f3742484dfc58ac817ad131199adb1f6f802592006fc69", "token_estimator": "heuristic-v1" }, { @@ -481,7 +471,6 @@ "estimated_token_count_total": 2132 }, "hash": "sha256:1b9efd2fe00b251d3b4054c9cfcb55f9b5a1384238eeaca81a6f1542fc36d75c", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -502,7 +491,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -569,7 +557,6 @@ "estimated_token_count_total": 4063 }, "hash": "sha256:bd07cdae71bf63786994865d2f33fba5f7bf8855dce6399414ad44ab0ec6635c", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -626,7 +613,6 @@ "estimated_token_count_total": 2225 }, "hash": "sha256:e916033f54c2874eb5ce9a43d58af058eb935429f73b7b1acc7da1592218e0b8", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -674,7 +660,6 @@ "estimated_token_count_total": 1523 }, "hash": "sha256:d9d85827d2c14bff8dd6b3301617345430cf63db603e37859720713004ecafae", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -694,9 +679,7 @@ "headings": 0, "estimated_token_count_total": 0 }, - "hash": "sha256:2b017d8a89f8734b9cbb501f03612a22657d2f8d4d85c51e490e4c8ca4bf771b", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", "token_estimator": "heuristic-v1" }, { @@ -754,7 +737,6 @@ "estimated_token_count_total": 1635 }, "hash": "sha256:46252e238b0b51105148dc622da6d8809c55ec11da7ec7b2953c35ca52f5f585", - "last_modified": "2025-10-28T14:42:10+00:00", "token_estimator": "heuristic-v1" }, { @@ -797,7 +779,6 @@ "estimated_token_count_total": 1491 }, "hash": "sha256:db37b2f5888f283b5eb5bd84a5f8c81fc66b2313e3f94f510a73dfeb310ae3f0", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -864,7 +845,6 @@ "estimated_token_count_total": 955 }, "hash": "sha256:72ee7394fd1308c111a8d548cb4dc63c6b9bc5b6e2bb556dd1baacbaedb92286", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -916,7 +896,6 @@ "estimated_token_count_total": 876 }, "hash": "sha256:d6cb22337280a19bdf24981dcba98f337d48ee4f79ce7ac040466ef1cb4b330b", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -998,7 +977,6 @@ "estimated_token_count_total": 2744 }, "hash": "sha256:1a2d34ccab19bd71263763bbc294977acf34f5800398f51398753594cfc7d7a6", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -1070,7 +1048,6 @@ "estimated_token_count_total": 608 }, "hash": "sha256:7bba6105d99721373aa6f494627d20af97b1851c19703f26be26c32f0c83524b", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -1137,7 +1114,6 @@ "estimated_token_count_total": 558 }, "hash": "sha256:b79fe56c9604712825bdf30d17667fd8f237fce9691be0d8d042d38691dbba7a", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -1189,7 +1165,58 @@ "estimated_token_count_total": 348 }, "hash": "sha256:11cd8d428fa9c3e70490da5c63ce4597cd89ec46306d2bb49b016ced6aa68c3d", - "last_modified": "2025-10-28T14:42:11+00:00", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-interoperability-versions-v5", + "title": "XCMv5", + "slug": "develop-interoperability-versions-v5", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-interoperability-versions-v5.md", + "html_url": "https://docs.polkadot.com/develop/interoperability/versions/v5/", + "preview": "The latest iteration of XCM is version 5. The main RFCs defining the changes in version 5 are the following:", + "outline": [ + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 2970, + "words": 438, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:3821c2ef97699091b76e1de58e6d95e866df69d39fca16f2a15c156b71da5b22", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-interoperability-versions", + "title": "XCM Versions", + "slug": "develop-interoperability-versions", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-interoperability-versions.md", + "html_url": "https://docs.polkadot.com/develop/interoperability/versions/", + "preview": "XCM is a versioned language that evolves to meet the growing needs of cross-chain communication in the Polkadot ecosystem. Understanding XCM versioning is essential for developers building interoperable applications to keep up with the latest improvements.", + "outline": [ + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 835, + "words": 114, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:634e299f347beb8ad690697943bb7f99915d62d40cda4227179619ed18abe2ff", "token_estimator": "heuristic-v1" }, { @@ -1237,7 +1264,6 @@ "estimated_token_count_total": 1365 }, "hash": "sha256:5f8fa89fc725c5c559975012fe2f9ae92c3b62f10024b5688dcd118331118f1a", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -1290,7 +1316,6 @@ "estimated_token_count_total": 4979 }, "hash": "sha256:ed3b7c8101b69f9c907cca7c5edfef67fdb5e7bc3c8df8d9fbad297f9dd3c80a", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -1347,7 +1372,6 @@ "estimated_token_count_total": 1781 }, "hash": "sha256:35c71a215558cd0642d363e4515ad240093995d42720e6495cd2994c859243e4", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -1394,7 +1418,6 @@ "estimated_token_count_total": 1447 }, "hash": "sha256:0e39aee80fbcf3dfaa19133f31d664914ed45b42a1a929270f05d8ae876b89e2", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -1441,7 +1464,6 @@ "estimated_token_count_total": 1082 }, "hash": "sha256:ec82957c768c2c07a272e7a28659c812b223df836e21372b1642f0bb249d7b39", - "last_modified": "2025-10-28T14:42:11+00:00", "token_estimator": "heuristic-v1" }, { @@ -1483,7 +1505,63 @@ "estimated_token_count_total": 4178 }, "hash": "sha256:d480791a76082937b47c77f7cf3794e701f193452ed347fcb1c04c3c67577bf5", - "last_modified": "2025-10-28T14:42:11+00:00", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-interoperability-xcm-guides-from-apps", + "title": "From Apps", + "slug": "develop-interoperability-xcm-guides-from-apps", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-interoperability-xcm-guides-from-apps.md", + "html_url": "https://docs.polkadot.com/develop/interoperability/xcm-guides/from-apps/", + "preview": "This section shows how to interact with XCM from applications, providing practical guidance for implementing cross-chain functionality in your dApps and services.", + "outline": [ + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 511, + "words": 70, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:63584f5b1dab7b67b18b35b47dfc19d00ad5c013804772f0d653a11ac3fca38d", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-interoperability-xcm-guides", + "title": "XCM Guides", + "slug": "develop-interoperability-xcm-guides", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-interoperability-xcm-guides.md", + "html_url": "https://docs.polkadot.com/develop/interoperability/xcm-guides/", + "preview": "This section provides comprehensive guides for implementing XCM functionality, including application development patterns, fee management, asset transfers, and cross-chain transaction handling.", + "outline": [ + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + }, + { + "depth": 2, + "title": "Additional Resources", + "anchor": "additional-resources" + } + ], + "stats": { + "chars": 1663, + "words": 215, + "headings": 2, + "estimated_token_count_total": 340 + }, + "hash": "sha256:d4c2d7fd46ddf60f638f948c88ba3940de6d69f140923ba8df52ed787b0afede", "token_estimator": "heuristic-v1" }, { @@ -1551,7 +1629,37 @@ "estimated_token_count_total": 6510 }, "hash": "sha256:353ad782303ef79bce1262bfa945e6f11b3c3c9ca1edf5705b778c46bada6200", - "last_modified": "2025-10-28T14:42:12+00:00", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-interoperability", + "title": "Interoperability", + "slug": "develop-interoperability", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-interoperability.md", + "html_url": "https://docs.polkadot.com/develop/interoperability/", + "preview": "This section covers everything you need to know about building and implementing [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\\_blank} solutions in the Polkadot ecosystem. Whether you're working on establishing cross-chain channels, sending and receiving XCM messages, or testing and debugging your cross-chain configurations, you'll find the essential resources and tools here to support your interoperability needs, regardless of your development focus.", + "outline": [ + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + }, + { + "depth": 2, + "title": "Additional Resources", + "anchor": "additional-resources" + } + ], + "stats": { + "chars": 2363, + "words": 323, + "headings": 2, + "estimated_token_count_total": 402 + }, + "hash": "sha256:5da6bdeec1deee5ef3d7ab1a43f546067bcef91acdc67df4ce114ee8f8669e82", "token_estimator": "heuristic-v1" }, { @@ -1614,19 +1722,19 @@ "estimated_token_count_total": 1520 }, "hash": "sha256:ed09ef7a6abe21204006186fd5791ada7597688fad67e30244dc449c51330309", - "last_modified": "2025-10-28T14:42:12+00:00", "token_estimator": "heuristic-v1" }, { - "id": "develop-parachains-customize-parachain-add-existing-pallets", - "title": "Add a Pallet to the Runtime", - "slug": "develop-parachains-customize-parachain-add-existing-pallets", + "id": "develop-parachains-customize-parachain-overview", + "title": "Overview of FRAME", + "slug": "develop-parachains-customize-parachain-overview", "categories": [ + "Basics", "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-customize-parachain-add-existing-pallets.md", - "html_url": "https://docs.polkadot.com/develop/parachains/customize-parachain/add-existing-pallets/", - "preview": "The [Polkadot SDK Solochain Template](https://github.com/paritytech/polkadot-sdk-solochain-template){target=\\_blank} provides a functional runtime that includes default FRAME development modules (pallets) to help you get started with building a custom blockchain.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-customize-parachain-overview.md", + "html_url": "https://docs.polkadot.com/develop/parachains/customize-parachain/overview/", + "preview": "The runtime is the heart of any Polkadot SDK-based blockchain, handling the essential logic that governs state changes and transaction processing. With Polkadot SDK’s [FRAME (Framework for Runtime Aggregation of Modularized Entities)](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\\_bank}, developers gain access to a powerful suite of tools for building custom blockchain runtimes. FRAME offers a modular architecture, featuring reusable pallets and su", "outline": [ { "depth": 2, @@ -1635,91 +1743,38 @@ }, { "depth": 2, - "title": "Configuring Runtime Dependencies", - "anchor": "configuring-runtime-dependencies" - }, - { - "depth": 2, - "title": "Dependencies for a New Pallet", - "anchor": "dependencies-for-a-new-pallet" - }, - { - "depth": 2, - "title": "Config Trait for Pallets", - "anchor": "config-trait-for-pallets" + "title": "FRAME Runtime Architecture", + "anchor": "frame-runtime-architecture" }, { "depth": 3, - "title": "Utility Pallet Example", - "anchor": "utility-pallet-example" - }, - { - "depth": 2, - "title": "Parameter Configuration for Pallets", - "anchor": "parameter-configuration-for-pallets" - }, - { - "depth": 2, - "title": "Pallet Config in the Runtime", - "anchor": "pallet-config-in-the-runtime" + "title": "Pallets", + "anchor": "pallets" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 11939, - "words": 1615, - "headings": 8, - "estimated_token_count_total": 2598 - }, - "hash": "sha256:b2b3d8c048863e7760f633b12ab2a0202c741be3050ea4beafb9a7265cfe96b5", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-parachains-customize-parachain-add-pallet-instances", - "title": "Add Multiple Pallet Instances", - "slug": "develop-parachains-customize-parachain-add-pallet-instances", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-customize-parachain-add-pallet-instances.md", - "html_url": "https://docs.polkadot.com/develop/parachains/customize-parachain/add-pallet-instances/", - "preview": "Running multiple instances of the same pallet within a runtime is a powerful technique in Polkadot SDK development. This approach lets you reuse pallet functionality without reimplementing it, enabling diverse use cases with the same codebase. The Polkadot SDK provides developer-friendly traits for creating instantiable pallets and, in most cases, handles unique storage allocation for different instances automatically. This guide teaches you how to implement and configure multiple instances of a", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "depth": 3, + "title": "Support Libraries", + "anchor": "support-libraries" }, { "depth": 2, - "title": "Understanding Instantiable Pallets", - "anchor": "understanding-instantiable-pallets" + "title": "Compose a Runtime with Pallets", + "anchor": "compose-a-runtime-with-pallets" }, { "depth": 2, - "title": "Adding Instantiable Pallets to Your Runtime", - "anchor": "adding-instantiable-pallets-to-your-runtime" - }, - { - "depth": 3, - "title": "Define Pallet Parameters", - "anchor": "define-pallet-parameters" + "title": "Starting from Templates", + "anchor": "starting-from-templates" }, { "depth": 3, - "title": "Configure the Pallet Instances", - "anchor": "configure-the-pallet-instances" + "title": "Solochain Templates", + "anchor": "solochain-templates" }, { "depth": 3, - "title": "Add Pallet Instances to the Runtime", - "anchor": "add-pallet-instances-to-the-runtime" + "title": "Parachain Templates", + "anchor": "parachain-templates" }, { "depth": 2, @@ -1728,69 +1783,55 @@ } ], "stats": { - "chars": 6294, - "words": 729, - "headings": 7, - "estimated_token_count_total": 1219 + "chars": 9427, + "words": 1267, + "headings": 9, + "estimated_token_count_total": 2019 }, - "hash": "sha256:262e7a3ad3d0a0102897c52c7589e3f94c7827c441398b3b446b205f6c6753d3", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:d03ea172f2af9f4648e730d60033a80c2c1e64efa9241fed0c1ba40a5f846ae5", "token_estimator": "heuristic-v1" }, { - "id": "develop-parachains-customize-parachain-add-smart-contract-functionality", - "title": "Add Smart Contract Functionality", - "slug": "develop-parachains-customize-parachain-add-smart-contract-functionality", + "id": "develop-parachains-customize-parachain", + "title": "Customize Your Parachain", + "slug": "develop-parachains-customize-parachain", "categories": [ - "Parachains" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-customize-parachain-add-smart-contract-functionality.md", - "html_url": "https://docs.polkadot.com/develop/parachains/customize-parachain/add-smart-contract-functionality/", - "preview": "When building your custom blockchain with the Polkadot SDK, you have the flexibility to add smart contract capabilities through specialized pallets. These pallets allow blockchain users to deploy and execute smart contracts, enhancing your chain's functionality and programmability.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-customize-parachain.md", + "html_url": "https://docs.polkadot.com/develop/parachains/customize-parachain/", + "preview": "Learn how to build a custom parachain with Polkadot SDK's FRAME framework, which includes pallet development, testing, smart contracts, and runtime customization. Pallets are modular components within the FRAME ecosystem that contain specific blockchain functionalities. This modularity grants developers increased flexibility and control around which behaviors to include in the core logic of their parachain.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "EVM Smart Contracts", - "anchor": "evm-smart-contracts" - }, - { - "depth": 2, - "title": "Wasm Smart Contracts", - "anchor": "wasm-smart-contracts" + "title": "In This Section", + "anchor": "in-this-section" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 3896, - "words": 523, - "headings": 4, - "estimated_token_count_total": 905 + "chars": 1899, + "words": 259, + "headings": 2, + "estimated_token_count_total": 335 }, - "hash": "sha256:ad8e6d9c77d5451c5f4d17f8e6311b21e6ad24eae8780fd4c3ae6013744822cf", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:9a08b66442c564c7116c686d8914b74ad617326f450d0894b05e753462f69aac", "token_estimator": "heuristic-v1" }, { - "id": "develop-parachains-customize-parachain-make-custom-pallet", - "title": "Make a Custom Pallet", - "slug": "develop-parachains-customize-parachain-make-custom-pallet", + "id": "develop-parachains-deployment-build-deterministic-runtime", + "title": "Build a deterministic runtime", + "slug": "develop-parachains-deployment-build-deterministic-runtime", "categories": [ "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-customize-parachain-make-custom-pallet.md", - "html_url": "https://docs.polkadot.com/develop/parachains/customize-parachain/make-custom-pallet/", - "preview": "FRAME provides a powerful set of tools for blockchain development, including a library of pre-built pallets. However, its true strength lies in the ability to create custom pallets tailored to your specific needs. This section will guide you through creating your own custom pallet, allowing you to extend your blockchain's functionality in unique ways.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-deployment-build-deterministic-runtime.md", + "html_url": "https://docs.polkadot.com/develop/parachains/deployment/build-deterministic-runtime/", + "preview": "By default, the Rust compiler produces optimized Wasm binaries. These binaries are suitable for working in an isolated environment, such as local development. However, the Wasm binaries the compiler builds by default aren't guaranteed to be deterministically reproducible. Each time the compiler generates the Wasm runtime, it might produce a slightly different Wasm byte code. This is problematic in a blockchain network where all nodes must use exactly the same raw chain specification file.", "outline": [ { "depth": 2, @@ -1799,67 +1840,64 @@ }, { "depth": 2, - "title": "Initial Setup", - "anchor": "initial-setup" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "Pallet Configuration", - "anchor": "pallet-configuration" + "title": "Tooling for Wasm Runtime", + "anchor": "tooling-for-wasm-runtime" }, { "depth": 2, - "title": "Pallet Events", - "anchor": "pallet-events" + "title": "Working with the Docker Container", + "anchor": "working-with-the-docker-container" }, { "depth": 2, - "title": "Pallet Errors", - "anchor": "pallet-errors" + "title": "Prepare the Environment", + "anchor": "prepare-the-environment" }, { "depth": 2, - "title": "Pallet Storage", - "anchor": "pallet-storage" + "title": "Start a Deterministic Build", + "anchor": "start-a-deterministic-build" }, { "depth": 2, - "title": "Pallet Dispatchable Extrinsics", - "anchor": "pallet-dispatchable-extrinsics" + "title": "Use srtool in GitHub Actions", + "anchor": "use-srtool-in-github-actions" }, { "depth": 2, - "title": "Pallet Implementation Overview", - "anchor": "pallet-implementation-overview" + "title": "Use the srtool Image via Docker Hub", + "anchor": "use-the-srtool-image-via-docker-hub" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "depth": 3, + "title": "Naming Convention for Images", + "anchor": "naming-convention-for-images" } ], "stats": { - "chars": 17824, - "words": 2311, + "chars": 8470, + "words": 1227, "headings": 9, - "estimated_token_count_total": 3995 + "estimated_token_count_total": 1944 }, - "hash": "sha256:19997d390abf2847824024ba923f46a61106ef77544d256d50b371210816b309", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:4fc8cab40e982e860b64d9aede1058fe7fa82ec321ac215b919db00c4df0a9c0", "token_estimator": "heuristic-v1" }, { - "id": "develop-parachains-customize-parachain-overview", - "title": "Overview of FRAME", - "slug": "develop-parachains-customize-parachain-overview", + "id": "develop-parachains-deployment-coretime-renewal", + "title": "Coretime Renewal", + "slug": "develop-parachains-deployment-coretime-renewal", "categories": [ - "Basics", "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-customize-parachain-overview.md", - "html_url": "https://docs.polkadot.com/develop/parachains/customize-parachain/overview/", - "preview": "The runtime is the heart of any Polkadot SDK-based blockchain, handling the essential logic that governs state changes and transaction processing. With Polkadot SDK’s [FRAME (Framework for Runtime Aggregation of Modularized Entities)](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\\_bank}, developers gain access to a powerful suite of tools for building custom blockchain runtimes. FRAME offers a modular architecture, featuring reusable pallets and su", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-deployment-coretime-renewal.md", + "html_url": "https://docs.polkadot.com/develop/parachains/deployment/coretime-renewal/", + "preview": "Coretime can be purchased in bulk for a period of 28 days, providing access to Polkadot's shared security and interoperability for Polkadot parachains. The bulk purchase of coretime includes a rent-control mechanism that keeps future purchases within a predictable price range of the initial purchase. This allows cores to be renewed at a known price without competing against other participants in the open market.", "outline": [ { "depth": 2, @@ -1868,162 +1906,28 @@ }, { "depth": 2, - "title": "FRAME Runtime Architecture", - "anchor": "frame-runtime-architecture" - }, - { - "depth": 3, - "title": "Pallets", - "anchor": "pallets" + "title": "Bulk Sale Phases", + "anchor": "bulk-sale-phases" }, { - "depth": 3, - "title": "Support Libraries", - "anchor": "support-libraries" + "depth": 2, + "title": "Renewal Timing", + "anchor": "renewal-timing" }, { "depth": 2, - "title": "Compose a Runtime with Pallets", - "anchor": "compose-a-runtime-with-pallets" + "title": "Manual Renewal", + "anchor": "manual-renewal" }, { "depth": 2, - "title": "Starting from Templates", - "anchor": "starting-from-templates" + "title": "Auto-Renewal", + "anchor": "auto-renewal" }, { "depth": 3, - "title": "Solochain Templates", - "anchor": "solochain-templates" - }, - { - "depth": 3, - "title": "Parachain Templates", - "anchor": "parachain-templates" - }, - { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 9427, - "words": 1267, - "headings": 9, - "estimated_token_count_total": 2019 - }, - "hash": "sha256:0becb82886d34e2ed23d963efd2c14120112e6e080ea4072e864531299b59753", - "last_modified": "2025-10-28T14:42:12+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-parachains-deployment-build-deterministic-runtime", - "title": "Build a deterministic runtime", - "slug": "develop-parachains-deployment-build-deterministic-runtime", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-deployment-build-deterministic-runtime.md", - "html_url": "https://docs.polkadot.com/develop/parachains/deployment/build-deterministic-runtime/", - "preview": "By default, the Rust compiler produces optimized Wasm binaries. These binaries are suitable for working in an isolated environment, such as local development. However, the Wasm binaries the compiler builds by default aren't guaranteed to be deterministically reproducible. Each time the compiler generates the Wasm runtime, it might produce a slightly different Wasm byte code. This is problematic in a blockchain network where all nodes must use exactly the same raw chain specification file.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Tooling for Wasm Runtime", - "anchor": "tooling-for-wasm-runtime" - }, - { - "depth": 2, - "title": "Working with the Docker Container", - "anchor": "working-with-the-docker-container" - }, - { - "depth": 2, - "title": "Prepare the Environment", - "anchor": "prepare-the-environment" - }, - { - "depth": 2, - "title": "Start a Deterministic Build", - "anchor": "start-a-deterministic-build" - }, - { - "depth": 2, - "title": "Use srtool in GitHub Actions", - "anchor": "use-srtool-in-github-actions" - }, - { - "depth": 2, - "title": "Use the srtool Image via Docker Hub", - "anchor": "use-the-srtool-image-via-docker-hub" - }, - { - "depth": 3, - "title": "Naming Convention for Images", - "anchor": "naming-convention-for-images" - } - ], - "stats": { - "chars": 8470, - "words": 1227, - "headings": 9, - "estimated_token_count_total": 1944 - }, - "hash": "sha256:4fc8cab40e982e860b64d9aede1058fe7fa82ec321ac215b919db00c4df0a9c0", - "last_modified": "2025-10-28T14:42:12+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-parachains-deployment-coretime-renewal", - "title": "Coretime Renewal", - "slug": "develop-parachains-deployment-coretime-renewal", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-deployment-coretime-renewal.md", - "html_url": "https://docs.polkadot.com/develop/parachains/deployment/coretime-renewal/", - "preview": "Coretime can be purchased in bulk for a period of 28 days, providing access to Polkadot's shared security and interoperability for Polkadot parachains. The bulk purchase of coretime includes a rent-control mechanism that keeps future purchases within a predictable price range of the initial purchase. This allows cores to be renewed at a known price without competing against other participants in the open market.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Bulk Sale Phases", - "anchor": "bulk-sale-phases" - }, - { - "depth": 2, - "title": "Renewal Timing", - "anchor": "renewal-timing" - }, - { - "depth": 2, - "title": "Manual Renewal", - "anchor": "manual-renewal" - }, - { - "depth": 2, - "title": "Auto-Renewal", - "anchor": "auto-renewal" - }, - { - "depth": 3, - "title": "Set Up an HRMP Channel", - "anchor": "set-up-an-hrmp-channel" + "title": "Set Up an HRMP Channel", + "anchor": "set-up-an-hrmp-channel" }, { "depth": 3, @@ -2053,7 +1957,6 @@ "estimated_token_count_total": 3068 }, "hash": "sha256:9918593a46c12a1756552ddfaf7421ad6262600735b6f1fec030911420fe1736", - "last_modified": "2025-10-28T14:42:12+00:00", "token_estimator": "heuristic-v1" }, { @@ -2135,7 +2038,6 @@ "estimated_token_count_total": 3025 }, "hash": "sha256:a60fe36a5ba6d1cafe12eab75300afd24a46d3ace1e791087adb7e3e538afcc3", - "last_modified": "2025-10-28T14:42:12+00:00", "token_estimator": "heuristic-v1" }, { @@ -2187,7 +2089,6 @@ "estimated_token_count_total": 1289 }, "hash": "sha256:39c58dbe2ddcd542d7074d08d72f1811318dc8a3130419025480fd5cbe9fc3e7", - "last_modified": "2025-10-28T14:42:12+00:00", "token_estimator": "heuristic-v1" }, { @@ -2223,152 +2124,7 @@ "headings": 3, "estimated_token_count_total": 966 }, - "hash": "sha256:358ed14147b96b47deb61df9a1ea0e1103a139ea5edb78c5d50a48d5a779b80d", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-parachains-install-polkadot-sdk", - "title": "Install Polkadot SDK Dependencies", - "slug": "develop-parachains-install-polkadot-sdk", - "categories": [ - "Basics", - "Tooling" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-install-polkadot-sdk.md", - "html_url": "https://docs.polkadot.com/develop/parachains/install-polkadot-sdk/", - "preview": "This guide provides step-by-step instructions for installing the dependencies you need to work with the Polkadot SDK-based chains on macOS, Linux, and Windows. Follow the appropriate section for your operating system to ensure all necessary tools are installed and configured properly.", - "outline": [ - { - "depth": 2, - "title": "macOS", - "anchor": "macos" - }, - { - "depth": 3, - "title": "Before You Begin", - "anchor": "before-you-begin" - }, - { - "depth": 3, - "title": "Install Required Packages and Rust", - "anchor": "install-required-packages-and-rust" - }, - { - "depth": 2, - "title": "Linux", - "anchor": "linux" - }, - { - "depth": 3, - "title": "Before You Begin {: #before-you-begin-linux }", - "anchor": "before-you-begin-before-you-begin-linux" - }, - { - "depth": 3, - "title": "Install Required Packages and Rust {: #install-required-packages-and-rust-linux }", - "anchor": "install-required-packages-and-rust-install-required-packages-and-rust-linux" - }, - { - "depth": 2, - "title": "Windows (WSL)", - "anchor": "windows-wsl" - }, - { - "depth": 3, - "title": "Before You Begin {: #before-you-begin-windows }", - "anchor": "before-you-begin-before-you-begin-windows" - }, - { - "depth": 3, - "title": "Set Up Windows Subsystem for Linux", - "anchor": "set-up-windows-subsystem-for-linux" - }, - { - "depth": 3, - "title": "Install Required Packages and Rust {: #install-required-packages-and-rust-windows }", - "anchor": "install-required-packages-and-rust-install-required-packages-and-rust-windows" - }, - { - "depth": 2, - "title": "Verifying Installation", - "anchor": "verifying-installation" - }, - { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 12756, - "words": 1840, - "headings": 12, - "estimated_token_count_total": 2709 - }, - "hash": "sha256:2ee5656f749b4bca445172f2bc66c7fc39af40ff173626662ae4c399f49cf909", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-parachains-intro-polkadot-sdk", - "title": "Introduction to Polkadot SDK", - "slug": "develop-parachains-intro-polkadot-sdk", - "categories": [ - "Basics", - "Tooling" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-intro-polkadot-sdk.md", - "html_url": "https://docs.polkadot.com/develop/parachains/intro-polkadot-sdk/", - "preview": "The [Polkadot SDK](https://github.com/paritytech/polkadot-sdk/tree/polkadot-stable2506-2){target=\\_blank} is a powerful and versatile developer kit designed to facilitate building on the Polkadot network. It provides the necessary components for creating custom blockchains, parachains, generalized rollups, and more. Written in the Rust programming language, it puts security and robustness at the forefront of its design.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Polkadot SDK Overview", - "anchor": "polkadot-sdk-overview" - }, - { - "depth": 3, - "title": "Substrate", - "anchor": "substrate" - }, - { - "depth": 3, - "title": "FRAME", - "anchor": "frame" - }, - { - "depth": 3, - "title": "Cumulus", - "anchor": "cumulus" - }, - { - "depth": 2, - "title": "Why Use Polkadot SDK?", - "anchor": "why-use-polkadot-sdk" - }, - { - "depth": 2, - "title": "Create a Custom Blockchain Using the SDK", - "anchor": "create-a-custom-blockchain-using-the-sdk" - } - ], - "stats": { - "chars": 8758, - "words": 1156, - "headings": 7, - "estimated_token_count_total": 1892 - }, - "hash": "sha256:74de798c287cae75729e7db54019507f03a361dbbd1f2bb58c4694605f83efab", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:b25618dc598f4f946da06f854211645768214e0b51d06b684b0cab668b66124c", "token_estimator": "heuristic-v1" }, { @@ -2420,7 +2176,6 @@ "estimated_token_count_total": 4719 }, "hash": "sha256:bfad885d8053d052c55dbffc3c09e6196586795c3a1d07ab6ad58f9006ec3345", - "last_modified": "2025-10-28T14:42:12+00:00", "token_estimator": "heuristic-v1" }, { @@ -2482,7 +2237,6 @@ "estimated_token_count_total": 1819 }, "hash": "sha256:b0c1535fa8e969a9bdeee426a5a35a42b4649121fb8ce6fd2b15fdeba35b5d5f", - "last_modified": "2025-10-28T14:42:12+00:00", "token_estimator": "heuristic-v1" }, { @@ -2513,9 +2267,7 @@ "headings": 2, "estimated_token_count_total": 236 }, - "hash": "sha256:07e63e1e99b9acf1cc3b5ef8fa1f06ff22182b2a801582ce800eba37d7d39408", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:3b0a9e8037c7634c33ac6674170bd763599fca914855d9d2fbf490d359140130", "token_estimator": "heuristic-v1" }, { @@ -2546,9 +2298,7 @@ "headings": 2, "estimated_token_count_total": 211 }, - "hash": "sha256:55dc252fdecf1590048ce8d009b822e90231442abe81e9593cf1635944a31336", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:0ce1fe38de00827a0735b9fa8076492205c2450c61da9fbd1937d9f38cfe7825", "token_estimator": "heuristic-v1" }, { @@ -2579,61 +2329,29 @@ "headings": 2, "estimated_token_count_total": 330 }, - "hash": "sha256:f4964f894f7cd2fdfd699c017b4bd25cffc322b03a5a88a36c682cf952832ccc", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:75a6fa2f21b67009be62e07bab01655a10b2c35a5292dc1f7ca57df846d709f3", "token_estimator": "heuristic-v1" }, { - "id": "develop-parachains-testing-benchmarking", - "title": "Benchmarking FRAME Pallets", - "slug": "develop-parachains-testing-benchmarking", + "id": "develop-smart-contracts-connect-to-kusama", + "title": "Connect to Kusama", + "slug": "develop-smart-contracts-connect-to-kusama", "categories": [ - "Parachains" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-testing-benchmarking.md", - "html_url": "https://docs.polkadot.com/develop/parachains/testing/benchmarking/", - "preview": "Benchmarking is a critical component of developing efficient and secure blockchain runtimes. In the Polkadot ecosystem, accurately benchmarking your custom pallets ensures that each extrinsic has a precise [weight](/polkadot-protocol/glossary/#weight){target=\\_blank}, representing its computational and storage demands. This process is vital for maintaining the blockchain's performance and preventing potential vulnerabilities, such as Denial of Service (DoS) attacks.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-connect-to-kusama.md", + "html_url": "https://docs.polkadot.com/develop/smart-contracts/connect-to-kusama/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Networks Details", + "anchor": "networks-details" }, { "depth": 2, - "title": "The Case for Benchmarking", - "anchor": "the-case-for-benchmarking" - }, - { - "depth": 3, - "title": "Benchmarking and Weight", - "anchor": "benchmarking-and-weight" - }, - { - "depth": 2, - "title": "Benchmarking Process", - "anchor": "benchmarking-process" - }, - { - "depth": 3, - "title": "Prepare Your Environment", - "anchor": "prepare-your-environment" - }, - { - "depth": 3, - "title": "Write Benchmark Tests", - "anchor": "write-benchmark-tests" - }, - { - "depth": 3, - "title": "Add Benchmarks to Runtime", - "anchor": "add-benchmarks-to-runtime" - }, - { - "depth": 3, - "title": "Run Benchmarks", - "anchor": "run-benchmarks" + "title": "Important Deployment Considerations", + "anchor": "important-deployment-considerations" }, { "depth": 2, @@ -2642,217 +2360,206 @@ } ], "stats": { - "chars": 14731, - "words": 1881, - "headings": 9, - "estimated_token_count_total": 3342 + "chars": 3601, + "words": 476, + "headings": 3, + "estimated_token_count_total": 514 }, - "hash": "sha256:9d6daa3f4daf149ae822b60060d14ff022bd4b3440cecdc969a48c105eb82a21", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:e8ffeaa3a17e20437a59f2c95a63821eb75bf3c33001e748c23958b2b99ac3c2", "token_estimator": "heuristic-v1" }, { - "id": "develop-parachains-testing-mock-runtime", - "title": "Mock Runtime for Pallet Testing", - "slug": "develop-parachains-testing-mock-runtime", + "id": "develop-smart-contracts-dev-environments", + "title": "Dev Environments", + "slug": "develop-smart-contracts-dev-environments", "categories": [ - "Parachains" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-testing-mock-runtime.md", - "html_url": "https://docs.polkadot.com/develop/parachains/testing/mock-runtime/", - "preview": "Testing is essential in Polkadot SDK development to ensure your blockchain operates as intended and effectively handles various potential scenarios. This guide walks you through setting up an environment to test pallets within the [runtime](/polkadot-protocol/glossary#runtime){target=_blank}, allowing you to evaluate how different pallets, their configurations, and system components interact to ensure reliable blockchain functionality.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-dev-environments.md", + "html_url": "https://docs.polkadot.com/develop/smart-contracts/dev-environments/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Explore the tools and frameworks available for building and testing smart contracts on the Polkadot network. These environments streamline the development process, from writing and compiling to testing and deploying smart contracts. The guides in this section will help you evaluate each tool's strengths, making it easier to choose t", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "What to Consider", + "anchor": "what-to-consider" }, { "depth": 2, - "title": "Configuring a Mock Runtime", - "anchor": "configuring-a-mock-runtime" + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 1601, + "words": 154, + "headings": 2, + "estimated_token_count_total": 323 + }, + "hash": "sha256:5c3a10769e30b4da62e6c188e99310354e6e9af4595c7920c2977a54b8e1853c", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-smart-contracts-faqs", + "title": "Polkadot Hub Smart Contract FAQs", + "slug": "develop-smart-contracts-faqs", + "categories": [ + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-faqs.md", + "html_url": "https://docs.polkadot.com/develop/smart-contracts/faqs/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. !!! note For a list of known incompatibilities, please refer to the [Solidity and Yul IR translation incompatibilities](/polkadot-protocol/smart-contract-basics/evm-vs-polkavm/#solidity-and-yul-ir-translation-incompatibilities){target=\\_blank} section.", + "outline": [ + { + "depth": 2, + "title": "General Questions", + "anchor": "general-questions" }, { "depth": 3, - "title": "Testing Module", - "anchor": "testing-module" + "title": "What are the different types of smart contracts I can build on Polkadot?", + "anchor": "what-are-the-different-types-of-smart-contracts-i-can-build-on-polkadot" }, { "depth": 3, - "title": "Genesis Storage", - "anchor": "genesis-storage" + "title": "Should I build a smart contract or a parachain?", + "anchor": "should-i-build-a-smart-contract-or-a-parachain" }, { "depth": 3, - "title": "Pallet Configuration", - "anchor": "pallet-configuration" + "title": "What's the difference between Polkadot Hub smart contracts and other EVM chains?", + "anchor": "whats-the-difference-between-polkadot-hub-smart-contracts-and-other-evm-chains" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 7493, - "words": 904, - "headings": 6, - "estimated_token_count_total": 1572 - }, - "hash": "sha256:68fc67390e24741081c9a04d78951e76c7d4ff7cf6eddaba7dcbbdc1812c71d3", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-parachains-testing-pallet-testing", - "title": "Pallet Testing", - "slug": "develop-parachains-testing-pallet-testing", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-parachains-testing-pallet-testing.md", - "html_url": "https://docs.polkadot.com/develop/parachains/testing/pallet-testing/", - "preview": "Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. The Polkadot SDK offers a set of APIs to create a test environment to simulate runtime and mock transaction execution for extrinsics and queries.", - "outline": [ + "title": "Development Environment", + "anchor": "development-environment" + }, { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "depth": 3, + "title": "Can I use my existing Ethereum development tools?", + "anchor": "can-i-use-my-existing-ethereum-development-tools" + }, + { + "depth": 3, + "title": "How do I set up local development?", + "anchor": "how-do-i-set-up-local-development" + }, + { + "depth": 3, + "title": "What networks are available for testing and deployment?", + "anchor": "what-networks-are-available-for-testing-and-deployment" }, { "depth": 2, - "title": "Writing Unit Tests", - "anchor": "writing-unit-tests" + "title": "Technical Implementation", + "anchor": "technical-implementation" }, { "depth": 3, - "title": "Test Initialization", - "anchor": "test-initialization" + "title": "How do Ethereum addresses work on Polkadot?", + "anchor": "how-do-ethereum-addresses-work-on-polkadot" }, { "depth": 3, - "title": "Function Call Testing", - "anchor": "function-call-testing" + "title": "What are the key differences in the gas model?", + "anchor": "what-are-the-key-differences-in-the-gas-model" }, { "depth": 3, - "title": "Storage Testing", - "anchor": "storage-testing" + "title": "How does contract deployment work?", + "anchor": "how-does-contract-deployment-work" }, { "depth": 3, - "title": "Event Testing", - "anchor": "event-testing" + "title": "Which Solidity features are not supported?", + "anchor": "which-solidity-features-are-not-supported" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 6871, - "words": 909, - "headings": 7, - "estimated_token_count_total": 1559 - }, - "hash": "sha256:0024f5e4c12ab7b019e5ee183e7c78d175e1125868c5458b97d3accd9fac75bc", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-smart-contracts-connect-to-kusama", - "title": "Connect to Kusama", - "slug": "develop-smart-contracts-connect-to-kusama", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-connect-to-kusama.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/connect-to-kusama/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ", - "outline": [ + "depth": 3, + "title": "How do I handle the existential deposit requirement?", + "anchor": "how-do-i-handle-the-existential-deposit-requirement" + }, { "depth": 2, - "title": "Networks Details", - "anchor": "networks-details" + "title": "Migration and Compatibility", + "anchor": "migration-and-compatibility" }, { - "depth": 2, - "title": "Important Deployment Considerations", - "anchor": "important-deployment-considerations" + "depth": 3, + "title": "Can I migrate my existing Ethereum contracts?", + "anchor": "can-i-migrate-my-existing-ethereum-contracts" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 3601, - "words": 476, - "headings": 3, - "estimated_token_count_total": 514 - }, - "hash": "sha256:e8ffeaa3a17e20437a59f2c95a63821eb75bf3c33001e748c23958b2b99ac3c2", - "last_modified": "2025-10-28T14:42:12+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-smart-contracts-connect-to-polkadot", - "title": "Connect to Polkadot", - "slug": "develop-smart-contracts-connect-to-polkadot", - "categories": [ - "Smart Contracts" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-connect-to-polkadot.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/connect-to-polkadot/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ", - "outline": [ + "title": "Troubleshooting", + "anchor": "troubleshooting" + }, { - "depth": 2, - "title": "Networks Details", - "anchor": "networks-details" + "depth": 3, + "title": "Why are my gas calculations different?", + "anchor": "why-are-my-gas-calculations-different" }, { - "depth": 2, - "title": "Test Tokens", - "anchor": "test-tokens" + "depth": 3, + "title": "I deployed a contract with MetaMask, and got a `code size` error - why?", + "anchor": "i-deployed-a-contract-with-metamask-and-got-a-code-size-error-why" + }, + { + "depth": 3, + "title": "I found a bug, where can I log it?", + "anchor": "i-found-a-bug-where-can-i-log-it" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Known Issues", + "anchor": "known-issues" + }, + { + "depth": 3, + "title": "Runtime Behavior", + "anchor": "runtime-behavior" + }, + { + "depth": 3, + "title": "Development Tools", + "anchor": "development-tools" + }, + { + "depth": 3, + "title": "Contract Patterns", + "anchor": "contract-patterns" + }, + { + "depth": 3, + "title": "Compilation", + "anchor": "compilation" } ], "stats": { - "chars": 3496, - "words": 482, - "headings": 3, - "estimated_token_count_total": 570 + "chars": 7480, + "words": 984, + "headings": 25, + "estimated_token_count_total": 1618 }, - "hash": "sha256:1247dfb5f5ac040bca81cd1002153e0ee53f4052b2a3d40b623834bd7f00d065", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:5cc63ff0a377ef0ec96a064748e13b88bc852bd1862c6e344066855a7fe93b19", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-dev-environments-foundry", - "title": "Use Foundry with Polkadot Hub", - "slug": "develop-smart-contracts-dev-environments-foundry", + "id": "develop-smart-contracts-libraries", + "title": "Libraries", + "slug": "develop-smart-contracts-libraries", "categories": [ "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-dev-environments.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/dev-environments/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Explore the tools and frameworks available for building and testing smart contracts on the Polkadot network. These environments streamline the development process, from writing and compiling to testing and deploying smart contracts. The guides in this section will help you evaluate each tool's strengths, making it easier to choose t", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-libraries.md", + "html_url": "https://docs.polkadot.com/develop/smart-contracts/libraries/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Explore the key libraries for interacting with smart contracts on Polkadot-based networks. These libraries simplify contract calls, event listening, and transaction handling.", "outline": [ { "depth": 2, - "title": "What to Consider", - "anchor": "what-to-consider" + "title": "Library Comparison", + "anchor": "library-comparison" }, { "depth": 2, @@ -2861,322 +2568,352 @@ } ], "stats": { - "chars": 1601, - "words": 154, + "chars": 2056, + "words": 203, "headings": 2, - "estimated_token_count_total": 323 + "estimated_token_count_total": 415 }, - "hash": "sha256:72e41f816f07026d96c803f399c71852aa1151c464e79cec3e1746b282d5eaae", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:23137f6c74412fd98c0b6aeee3ff59938e44b817ec42974c453f9b0f66e36513", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-dev-environments-hardhat", - "title": "Use Hardhat with Polkadot Hub", - "slug": "develop-smart-contracts-dev-environments-hardhat", + "id": "develop-smart-contracts-precompiles-interact-with-precompiles", + "title": "Interact with Precompiles", + "slug": "develop-smart-contracts-precompiles-interact-with-precompiles", "categories": [ - "Smart Contracts", - "Tooling" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-dev-environments-hardhat.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/dev-environments/hardhat/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**.
- :octicons-code-16:{ .lg .middle } __Test and Deploy with Hardhat__", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-precompiles-interact-with-precompiles.md", + "html_url": "https://docs.polkadot.com/develop/smart-contracts/precompiles/interact-with-precompiles/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", "outline": [ { "depth": 2, - "title": "Overview", - "anchor": "overview" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Basic Precompile Interaction Pattern", + "anchor": "basic-precompile-interaction-pattern" }, { "depth": 2, - "title": "Set Up Hardhat", - "anchor": "set-up-hardhat" + "title": "ECRecover (0x01)", + "anchor": "ecrecover-0x01" }, { "depth": 2, - "title": "Compile Your Contract", - "anchor": "compile-your-contract" + "title": "SHA-256 (0x02)", + "anchor": "sha-256-0x02" }, { "depth": 2, - "title": "Set Up a Testing Environment", - "anchor": "set-up-a-testing-environment" + "title": "RIPEMD-160 (0x03)", + "anchor": "ripemd-160-0x03" }, { "depth": 2, - "title": "Test Your Contract", - "anchor": "test-your-contract" + "title": "Identity (Data Copy) (0x04)", + "anchor": "identity-data-copy-0x04" }, { "depth": 2, - "title": "Deploy to a Local Node", - "anchor": "deploy-to-a-local-node" + "title": "Modular Exponentiation (0x05)", + "anchor": "modular-exponentiation-0x05" }, { "depth": 2, - "title": "Deploying to a Live Network", - "anchor": "deploying-to-a-live-network" + "title": "BN128 Addition (0x06)", + "anchor": "bn128-addition-0x06" }, { "depth": 2, - "title": "Interacting with Your Contract", - "anchor": "interacting-with-your-contract" + "title": "BN128 Scalar Multiplication (0x07)", + "anchor": "bn128-scalar-multiplication-0x07" }, { "depth": 2, - "title": "Upgrading the Plugin", - "anchor": "upgrading-the-plugin" + "title": "BN128 Pairing Check (0x08)", + "anchor": "bn128-pairing-check-0x08" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Blake2F (0x09)", + "anchor": "blake2f-0x09" + }, + { + "depth": 2, + "title": "Conclusion", + "anchor": "conclusion" } ], "stats": { - "chars": 18520, - "words": 2475, - "headings": 11, - "estimated_token_count_total": 4188 + "chars": 18054, + "words": 2190, + "headings": 12, + "estimated_token_count_total": 3847 }, - "hash": "sha256:fe008393aa37c27bb71b4483d4e2c4fbcda94f8c1be461fdd07eff40efbb4e26", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:4b705b8dbe9b0ad8d19a897d91f3c64dbc4541297dadacbea2a31b4778e50a46", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-dev-environments-remix", - "title": "Use the Polkadot Remix IDE", - "slug": "develop-smart-contracts-dev-environments-remix", + "id": "develop-smart-contracts", + "title": "Smart Contracts", + "slug": "develop-smart-contracts", "categories": [ - "Smart Contracts", - "Tooling" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-dev-environments-remix.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/dev-environments/remix/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**.
- :octicons-code-16:{ .lg .middle } __Deploy NFTs Using Remix IDE__", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts.md", + "html_url": "https://docs.polkadot.com/develop/smart-contracts/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Polkadot allows scalable execution of smart contracts, offering cross-chain compatibility and lower fees than legacy L1 platforms. Polkadot provides developers with flexibility in building smart contracts, supporting both Solidity contracts executed by the [PolkaVM](/smart-contracts/for-eth-devs/#polkavm){target=\\_blank} (a Polkadot", "outline": [ { "depth": 2, - "title": "Overview", - "anchor": "overview" - }, - { - "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Accessing Remix IDE", - "anchor": "accessing-remix-ide" - }, - { - "depth": 2, - "title": "Creating a New Contract", - "anchor": "creating-a-new-contract" - }, - { - "depth": 2, - "title": "Compiling Your Contract", - "anchor": "compiling-your-contract" + "title": "Smart Contract Development Process", + "anchor": "smart-contract-development-process" }, { "depth": 2, - "title": "Deploying Contracts", - "anchor": "deploying-contracts" - }, + "title": "Additional Resources", + "anchor": "additional-resources" + } + ], + "stats": { + "chars": 1867, + "words": 247, + "headings": 2, + "estimated_token_count_total": 189 + }, + "hash": "sha256:4b56a119cbc63d87de98554cf4019e48ddb4f7cee11a51553ea234f91d78f8b8", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-toolkit-api-libraries", + "title": "API Libraries", + "slug": "develop-toolkit-api-libraries", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/api-libraries/", + "preview": "Explore the powerful API libraries designed for interacting with the Polkadot network. These libraries offer developers versatile tools to build, query, and manage blockchain interactions. Whether you’re working with JavaScript, TypeScript, Python, or RESTful services, they provide the flexibility to efficiently interact with and retrieve data from Polkadot-based chains.", + "outline": [ { "depth": 2, - "title": "Interacting with Contracts", - "anchor": "interacting-with-contracts" + "title": "In This Section", + "anchor": "in-this-section" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 6732, - "words": 913, - "headings": 8, - "estimated_token_count_total": 1375 + "chars": 1082, + "words": 139, + "headings": 2, + "estimated_token_count_total": 187 }, - "hash": "sha256:8e6bfed5fa59bb748e80698ea702f62ce6951c48bdb955ee9ef0d3516e856887", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:746788d1068fe3eaafc34eb461566d1682c27fcad7d448e65810b9662b45dd85", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-faqs", - "title": "Polkadot Hub Smart Contract FAQs", - "slug": "develop-smart-contracts-faqs", + "id": "develop-toolkit-integrations-storage", + "title": "Storage", + "slug": "develop-toolkit-integrations-storage", "categories": [ - "Smart Contracts" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-faqs.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/faqs/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. !!! note For a list of known incompatibilities, please refer to the [Solidity and Yul IR translation incompatibilities](/polkadot-protocol/smart-contract-basics/evm-vs-polkavm/#solidity-and-yul-ir-translation-incompatibilities){target=\\_blank} section.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-integrations-storage.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/integrations/storage/", + "preview": "Polkadot offers developers a range of decentralized storage solutions to manage dApp data, host front ends, and store large files in a censorship-resistant and resilient manner. These integrations are essential for building fully decentralized applications, ensuring that all components of your dApp, from the front end to the data, are not reliant on centralized servers.", "outline": [ { "depth": 2, - "title": "General Questions", - "anchor": "general-questions" + "title": "Key Storage Solutions", + "anchor": "key-storage-solutions" }, { - "depth": 3, - "title": "What are the different types of smart contracts I can build on Polkadot?", - "anchor": "what-are-the-different-types-of-smart-contracts-i-can-build-on-polkadot" + "depth": 2, + "title": "Crust Network", + "anchor": "crust-network" }, { "depth": 3, - "title": "Should I build a smart contract or a parachain?", - "anchor": "should-i-build-a-smart-contract-or-a-parachain" + "title": "Key Features of Crust", + "anchor": "key-features-of-crust" }, { "depth": 3, - "title": "What's the difference between Polkadot Hub smart contracts and other EVM chains?", - "anchor": "whats-the-difference-between-polkadot-hub-smart-contracts-and-other-evm-chains" + "title": "Use Cases", + "anchor": "use-cases" }, { "depth": 2, - "title": "Development Environment", - "anchor": "development-environment" + "title": "IPFS", + "anchor": "ipfs" }, { "depth": 3, - "title": "Can I use my existing Ethereum development tools?", - "anchor": "can-i-use-my-existing-ethereum-development-tools" + "title": "Using IPFS with Polkadot", + "anchor": "using-ipfs-with-polkadot" }, { - "depth": 3, - "title": "How do I set up local development?", - "anchor": "how-do-i-set-up-local-development" - }, + "depth": 2, + "title": "Other Solutions", + "anchor": "other-solutions" + } + ], + "stats": { + "chars": 4369, + "words": 642, + "headings": 7, + "estimated_token_count_total": 847 + }, + "hash": "sha256:a206dd86fc3d80aed22384000839ca0c9c75c69ad461abd9810d96c03cf6a3bd", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-toolkit-integrations-transaction-construction", + "title": "Transaction Construction", + "slug": "develop-toolkit-integrations-transaction-construction", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-integrations-transaction-construction.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/integrations/transaction-construction/", + "preview": "This page will discuss the transaction format in Polkadot and how to create, sign, and broadcast transactions, as well as highlight some of the commands and tools available for integrators.", + "outline": [ { - "depth": 3, - "title": "What networks are available for testing and deployment?", - "anchor": "what-networks-are-available-for-testing-and-deployment" + "depth": 2, + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Technical Implementation", - "anchor": "technical-implementation" + "title": "Transaction Format", + "anchor": "transaction-format" }, { "depth": 3, - "title": "How do Ethereum addresses work on Polkadot?", - "anchor": "how-do-ethereum-addresses-work-on-polkadot" + "title": "Mode and Metadata Hash", + "anchor": "mode-and-metadata-hash" }, { "depth": 3, - "title": "What are the key differences in the gas model?", - "anchor": "what-are-the-key-differences-in-the-gas-model" + "title": "Serialized Transactions and Metadata", + "anchor": "serialized-transactions-and-metadata" }, { "depth": 3, - "title": "How does contract deployment work?", - "anchor": "how-does-contract-deployment-work" + "title": "Transaction Flow", + "anchor": "transaction-flow" }, { - "depth": 3, - "title": "Which Solidity features are not supported?", - "anchor": "which-solidity-features-are-not-supported" + "depth": 2, + "title": "Polkadot-JS Tools", + "anchor": "polkadot-js-tools" }, { "depth": 3, - "title": "How do I handle the existential deposit requirement?", - "anchor": "how-do-i-handle-the-existential-deposit-requirement" + "title": "Creating a Transaction, Signing, and Submitting", + "anchor": "creating-a-transaction-signing-and-submitting" }, { "depth": 2, - "title": "Migration and Compatibility", - "anchor": "migration-and-compatibility" + "title": "Txwrapper", + "anchor": "txwrapper" }, { "depth": 3, - "title": "Can I migrate my existing Ethereum contracts?", - "anchor": "can-i-migrate-my-existing-ethereum-contracts" + "title": "Creating a Transaction, Signing, and Submitting", + "anchor": "creating-a-transaction-signing-and-submitting-2" }, { "depth": 2, - "title": "Troubleshooting", - "anchor": "troubleshooting" - }, + "title": "Additional Libraries for Submitting a Transaction", + "anchor": "additional-libraries-for-submitting-a-transaction" + } + ], + "stats": { + "chars": 27671, + "words": 2949, + "headings": 10, + "estimated_token_count_total": 6280 + }, + "hash": "sha256:9b03477d13a285fced6bf845c3827084f790a626989dc2c09ef9ff53643045f4", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-toolkit-integrations", + "title": "Integrations", + "slug": "develop-toolkit-integrations", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-integrations.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/integrations/", + "preview": "Polkadot offers a wide range of integrations that allow developers to enhance their decentralized applications (dApps) and leverage the full capabilities of the ecosystem. Whether you’re looking to extend your application’s functionality, integrate with other chains, or access specialized services, these integrations provide the tools and resources you need to build efficiently and effectively. Explore the available options to find the solutions that best suit your development needs.", + "outline": [ { - "depth": 3, - "title": "Why are my gas calculations different?", - "anchor": "why-are-my-gas-calculations-different" - }, - { - "depth": 3, - "title": "I deployed a contract with MetaMask, and got a `code size` error - why?", - "anchor": "i-deployed-a-contract-with-metamask-and-got-a-code-size-error-why" - }, - { - "depth": 3, - "title": "I found a bug, where can I log it?", - "anchor": "i-found-a-bug-where-can-i-log-it" + "depth": 2, + "title": "Key Integration Solutions", + "anchor": "key-integration-solutions" }, { "depth": 2, - "title": "Known Issues", - "anchor": "known-issues" - }, - { - "depth": 3, - "title": "Runtime Behavior", - "anchor": "runtime-behavior" - }, - { - "depth": 3, - "title": "Development Tools", - "anchor": "development-tools" - }, - { - "depth": 3, - "title": "Contract Patterns", - "anchor": "contract-patterns" - }, - { - "depth": 3, - "title": "Compilation", - "anchor": "compilation" + "title": "In This Section", + "anchor": "in-this-section" } ], "stats": { - "chars": 7480, - "words": 984, - "headings": 25, - "estimated_token_count_total": 1618 + "chars": 988, + "words": 135, + "headings": 2, + "estimated_token_count_total": 92 }, - "hash": "sha256:5cc63ff0a377ef0ec96a064748e13b88bc852bd1862c6e344066855a7fe93b19", - "last_modified": "2025-10-28T14:42:12+00:00", + "hash": "sha256:0de8c1655a1524784010b6cec5fa522b2f764e32f18913f0d262283e0ec0779e", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-libraries", - "title": "Libraries", - "slug": "develop-smart-contracts-libraries", + "id": "develop-toolkit-interoperability", + "title": "Interoperability", + "slug": "develop-toolkit-interoperability", "categories": [ "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-libraries.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/libraries/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Explore the key libraries for interacting with smart contracts on Polkadot-based networks. These libraries simplify contract calls, event listening, and transaction handling.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-interoperability.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/interoperability/", + "preview": "Polkadot's XCM tooling ecosystem redefines the boundaries of cross-chain communication and asset movement. With unparalleled flexibility and scalability, these advanced tools empower developers to build decentralized applications that connect parachains, relay chains, and external networks. By bridging siloed blockchains, Polkadot paves the way for a unified, interoperable ecosystem that accelerates innovation and collaboration.", "outline": [ { "depth": 2, - "title": "Library Comparison", - "anchor": "library-comparison" - }, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 1010, + "words": 128, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:c72d7d30a019fe1db8ab3993f91dfd4f1bdb4a932aaa685d3baaa0578091d5ce", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-toolkit-parachains-e2e-testing", + "title": "E2E Testing on Polkadot SDK Chains", + "slug": "develop-toolkit-parachains-e2e-testing", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-e2e-testing.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/e2e-testing/", + "preview": ":::INSERT_IN_THIS_SECTION:::", + "outline": [ { "depth": 2, "title": "In This Section", @@ -3184,87 +2921,117 @@ } ], "stats": { - "chars": 31726, - "words": 3942, - "headings": 35, - "estimated_token_count_total": 9750 + "chars": 64, + "words": 6, + "headings": 1, + "estimated_token_count_total": 12 }, - "hash": "sha256:1fb7a20bc4a799a771954720428029419ec73afa640e589590c43dd041a7e307", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:cc49fdcc63a43247d80de2f309b9c7501d3054782746d80c003d95f3c43da90d", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-libraries-ethers-js", - "title": "Deploy Contracts to Polkadot Hub with Ethers.js", - "slug": "develop-smart-contracts-libraries-ethers-js", + "id": "develop-toolkit-parachains-fork-chains-chopsticks", + "title": "Chopsticks", + "slug": "develop-toolkit-parachains-fork-chains-chopsticks", "categories": [ - "Smart Contracts", - "Tooling" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-libraries-ethers-js.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/libraries/ethers-js/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-fork-chains-chopsticks.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/fork-chains/chopsticks/", + "preview": "Chopsticks is a powerful tool that lets you create local copies of running Polkadot SDK-based networks. By forking live chains locally, you can safely test features, analyze network behavior, and simulate complex scenarios without affecting production networks.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "What Can I Do with Chopsticks?", + "anchor": "what-can-i-do-with-chopsticks" }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "In This Section", + "anchor": "in-this-section" }, { "depth": 2, - "title": "Project Structure", - "anchor": "project-structure" - }, + "title": "Additional Resources", + "anchor": "additional-resources" + } + ], + "stats": { + "chars": 1495, + "words": 201, + "headings": 3, + "estimated_token_count_total": 291 + }, + "hash": "sha256:b568596033cdf68e60d72bcb7ee62a794def2bd3ff5b3317ef15895f58a12c57", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-toolkit-parachains-fork-chains", + "title": "Fork Chains for Testing", + "slug": "develop-toolkit-parachains-fork-chains", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-fork-chains.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/fork-chains/", + "preview": "Explore tools for forking live blockchain networks. These tools enable you to replicate real-world conditions in a local environment for accurate testing and debugging. They also allow you to analyze network behavior, test new features, and simulate complex scenarios in a controlled environment without affecting production systems.", + "outline": [ { "depth": 2, - "title": "Set Up the Project", - "anchor": "set-up-the-project" + "title": "Why Fork a Live Chain?", + "anchor": "why-fork-a-live-chain" }, { "depth": 2, - "title": "Install Dependencies", - "anchor": "install-dependencies" + "title": "In This Section", + "anchor": "in-this-section" }, { "depth": 2, - "title": "Set Up the Ethers.js Provider", - "anchor": "set-up-the-ethersjs-provider" - }, + "title": "Additional Resources", + "anchor": "additional-resources" + } + ], + "stats": { + "chars": 1269, + "words": 173, + "headings": 3, + "estimated_token_count_total": 183 + }, + "hash": "sha256:d29a845b00b24e03f9877a5331c33619918decf453657969115d5ec18033ba28", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-toolkit-parachains-quickstart-pop-cli", + "title": "Quickstart Parachain Development with Pop CLI", + "slug": "develop-toolkit-parachains-quickstart-pop-cli", + "categories": [ + "Parachains", + "Tooling" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-quickstart-pop-cli.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/quickstart/pop-cli/", + "preview": "[Pop CLI](https://onpop.io/cli/){target=\\_blank} is a powerful command-line tool designed explicitly for rapid parachain development within the Polkadot ecosystem. It addresses essential developer needs by providing streamlined commands to set up development environments, scaffold parachain templates, and manage local blockchain networks.", + "outline": [ { "depth": 2, - "title": "Compile Contracts", - "anchor": "compile-contracts" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 3, - "title": "Install the Revive Library", - "anchor": "install-the-revive-library" + "title": "Install Pop CLI", + "anchor": "install-pop-cli" }, { "depth": 3, - "title": "Sample Storage Smart Contract", - "anchor": "sample-storage-smart-contract" + "title": "Set Up Your Development Environment", + "anchor": "set-up-your-development-environment" }, { "depth": 3, - "title": "Compile the Smart Contract", - "anchor": "compile-the-smart-contract" - }, - { - "depth": 2, - "title": "Deploy the Compiled Contract", - "anchor": "deploy-the-compiled-contract" - }, - { - "depth": 2, - "title": "Interact with the Contract", - "anchor": "interact-with-the-contract" + "title": "Initialize a Project", + "anchor": "initialize-a-project" }, { "depth": 2, @@ -3273,27 +3040,50 @@ } ], "stats": { - "chars": 20464, - "words": 2334, - "headings": 13, - "estimated_token_count_total": 4475 + "chars": 4236, + "words": 610, + "headings": 5, + "estimated_token_count_total": 999 }, - "hash": "sha256:f0cee7ccb3cd294e8f909a220bb63987239ef8155c187a04f8c4864ffdcde288", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:6d6c66430a7302f29113924c5208e64d7c244497e50c61ab2f45c4b5141620e4", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-libraries-viem", - "title": "viem for Polkadot Hub Smart Contracts", - "slug": "develop-smart-contracts-libraries-viem", + "id": "develop-toolkit-parachains-quickstart", + "title": "Quickstart Parachain Development", + "slug": "develop-toolkit-parachains-quickstart", "categories": [ - "Smart Contracts", - "Tooling" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-libraries-viem.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/libraries/viem/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-quickstart.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/quickstart/", + "preview": ":::INSERT_IN_THIS_SECTION:::", + "outline": [ + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 85, + "words": 7, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:91de375b7f822ed56b5e6b4d609d0d36e806d3f77041b4e180b6679b10a3e1c8", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-toolkit-parachains-remote-proxies", + "title": "Remote Proxies", + "slug": "develop-toolkit-parachains-remote-proxies", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-remote-proxies.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/remote-proxies/", + "preview": "!!!warning \"Kusama Implementation Only\" Remote proxies are currently only available on Kusama and its parachains (such as Kusama Asset Hub). This feature is not yet deployed on Polkadot MainNet. The examples and implementations described in this guide are specific to the Kusama ecosystem.", "outline": [ { "depth": 2, @@ -3302,92 +3092,59 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Remote Proxy Architecture", + "anchor": "remote-proxy-architecture" }, { "depth": 2, - "title": "Project Structure", - "anchor": "project-structure" + "title": "Implementation Workflow", + "anchor": "implementation-workflow" }, { "depth": 2, - "title": "Set Up the Project", - "anchor": "set-up-the-project" + "title": "Practical Implementation", + "anchor": "practical-implementation" }, { - "depth": 2, - "title": "Install Dependencies", - "anchor": "install-dependencies" + "depth": 3, + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 2, - "title": "Initialize Project", - "anchor": "initialize-project" + "depth": 3, + "title": "Installation and Setup", + "anchor": "installation-and-setup" }, { - "depth": 2, - "title": "Set Up the Chain Configuration", - "anchor": "set-up-the-chain-configuration" + "depth": 3, + "title": "Implementation Example", + "anchor": "implementation-example" }, { "depth": 2, - "title": "Set Up the viem Client", - "anchor": "set-up-the-viem-client" - }, - { - "depth": 2, - "title": "Set Up a Wallet", - "anchor": "set-up-a-wallet" - }, - { - "depth": 2, - "title": "Sample Smart Contract", - "anchor": "sample-smart-contract" - }, - { - "depth": 2, - "title": "Compile the Contract", - "anchor": "compile-the-contract" - }, - { - "depth": 2, - "title": "Deploy the Contract", - "anchor": "deploy-the-contract" - }, - { - "depth": 2, - "title": "Interact with the Contract", - "anchor": "interact-with-the-contract" - }, - { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Resources", + "anchor": "resources" } ], "stats": { - "chars": 16645, - "words": 1945, - "headings": 14, - "estimated_token_count_total": 3900 + "chars": 9063, + "words": 1113, + "headings": 8, + "estimated_token_count_total": 1863 }, - "hash": "sha256:a7541553a50a250521c0a280f997d614763c643b1028147f3fb61391950bda15", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:7086406b31e7aa9089b221ffaa548ee5540a3d147ec1e93136f481c883f2e434", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-libraries-wagmi", - "title": "Wagmi for Polkadot Hub Smart Contracts", - "slug": "develop-smart-contracts-libraries-wagmi", + "id": "develop-toolkit-parachains-rpc-calls", + "title": "RPC Calls to Polkadot SDK chains.", + "slug": "develop-toolkit-parachains-rpc-calls", "categories": [ - "Smart Contracts", - "Tooling" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-libraries-wagmi.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/libraries/wagmi/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-rpc-calls.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/rpc-calls/", + "preview": "[Remote Procedure Call](https://en.wikipedia.org/wiki/Remote_procedure_call){target=\\_blank} (RPC) interfaces are the primary way to interact programmatically with Polkadot SDK-based parachains and relay chains. RPC calls allow you to query chain state, submit transactions, and monitor network health from external applications or scripts.", "outline": [ { "depth": 2, @@ -3396,72 +3153,85 @@ }, { "depth": 2, - "title": "Set Up the Project", - "anchor": "set-up-the-project" + "title": "How Do RPC Calls Work?", + "anchor": "how-do-rpc-calls-work" }, { "depth": 2, - "title": "Install Dependencies", - "anchor": "install-dependencies" + "title": "Making RPC Calls with Curl", + "anchor": "making-rpc-calls-with-curl" }, { "depth": 2, - "title": "Configure Wagmi for Polkadot Hub", - "anchor": "configure-wagmi-for-polkadot-hub" + "title": "Essential RPC Methods", + "anchor": "essential-rpc-methods" }, { - "depth": 2, - "title": "Set Up the Wagmi Provider", - "anchor": "set-up-the-wagmi-provider" + "depth": 3, + "title": "system_health", + "anchor": "system_health" }, { - "depth": 2, - "title": "Connect a Wallet", - "anchor": "connect-a-wallet" + "depth": 3, + "title": "chain_getBlock", + "anchor": "chain_getblock" }, { - "depth": 2, - "title": "Fetch Blockchain Data", - "anchor": "fetch-blockchain-data" + "depth": 3, + "title": "state_getStorage", + "anchor": "state_getstorage" }, { - "depth": 2, - "title": "Interact with Deployed Contract", - "anchor": "interact-with-deployed-contract" + "depth": 3, + "title": "author_submitExtrinsic", + "anchor": "author_submitextrinsic" + }, + { + "depth": 3, + "title": "state_getMetadata", + "anchor": "state_getmetadata" }, { "depth": 2, - "title": "Integrate Components", - "anchor": "integrate-components" + "title": "Check Available RPC Calls", + "anchor": "check-available-rpc-calls" + }, + { + "depth": 3, + "title": "Using curl", + "anchor": "using-curl" + }, + { + "depth": 3, + "title": "Using Polkadot.js Apps", + "anchor": "using-polkadotjs-apps" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Resources", + "anchor": "resources" } ], "stats": { - "chars": 13604, - "words": 1515, - "headings": 10, - "estimated_token_count_total": 3250 + "chars": 6496, + "words": 909, + "headings": 13, + "estimated_token_count_total": 1870 }, - "hash": "sha256:bc771f912627fa09cad64adab1bc81c052f650d6c5a3b4f0c91883a98f6628da", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:3b766e00e55a224201bc6744386a6dabc7da54ed9199b16abab3b94cff449eca", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-libraries-web3-js", - "title": "Web3.js", - "slug": "develop-smart-contracts-libraries-web3-js", + "id": "develop-toolkit-parachains-spawn-chains-zombienet-write-tests", + "title": "Write Tests", + "slug": "develop-toolkit-parachains-spawn-chains-zombienet-write-tests", "categories": [ - "Smart Contracts", + "Parachains", "Tooling" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-libraries-web3-js.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/libraries/web3-js/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. !!! warning Web3.js has been [sunset](https://blog.chainsafe.io/web3-js-sunset/){target=\\_blank}. You can find guides on using [Ethers.js](/develop/smart-contracts/libraries/ethers-js){target=\\_blank} and [viem](/develop/smart-contracts/libraries/viem){target=\\_blank} in the [Libraries](/develop/smart-contracts/libraries/){target=\\_", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains-zombienet-write-tests.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/spawn-chains/zombienet/write-tests/", + "preview": "Testing is a critical step in blockchain development, ensuring reliability, performance, and security. Zombienet simplifies this process with its intuitive Domain Specific Language (DSL), enabling developers to write natural-language test scripts tailored to their network needs.", "outline": [ { "depth": 2, @@ -3470,242 +3240,188 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Project Structure", - "anchor": "project-structure" - }, - { - "depth": 2, - "title": "Set Up the Project", - "anchor": "set-up-the-project" + "title": "Testing DSL", + "anchor": "testing-dsl" }, { "depth": 2, - "title": "Install Dependencies", - "anchor": "install-dependencies" + "title": "The Test File", + "anchor": "the-test-file" }, { - "depth": 2, - "title": "Set Up the Web3 Provider", - "anchor": "set-up-the-web3-provider" + "depth": 3, + "title": "Name", + "anchor": "name" }, { - "depth": 2, - "title": "Compile Contracts", - "anchor": "compile-contracts" + "depth": 3, + "title": "Assertions", + "anchor": "assertions" }, { - "depth": 2, - "title": "Contract Deployment", - "anchor": "contract-deployment" + "depth": 3, + "title": "Commands", + "anchor": "commands" }, { "depth": 2, - "title": "Interact with the Contract", - "anchor": "interact-with-the-contract" + "title": "Running a Test", + "anchor": "running-a-test" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Example Test Files", + "anchor": "example-test-files" } ], "stats": { - "chars": 13347, - "words": 1586, - "headings": 10, - "estimated_token_count_total": 3033 + "chars": 11297, + "words": 1491, + "headings": 8, + "estimated_token_count_total": 2661 }, - "hash": "sha256:bc87533eaf42a979a0c17f50ecdc668c364889257c7e0d27b81129770660fd53", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:04e85c4cddb58252f8253d78a3924bb56952dac2a3e9a057704a91a0d1f21d75", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-libraries-web3-py", - "title": "Web3.py", - "slug": "develop-smart-contracts-libraries-web3-py", + "id": "develop-toolkit-parachains-spawn-chains-zombienet", + "title": "Zombienet", + "slug": "develop-toolkit-parachains-spawn-chains-zombienet", "categories": [ - "Smart Contracts", - "Tooling" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-libraries-web3-py.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/libraries/web3-py/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains-zombienet.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/spawn-chains/zombienet/", + "preview": "Zombienet is a testing framework that lets you quickly spin up ephemeral blockchain networks for development and testing. With support for multiple deployment targets, such as Kubernetes, Podman, and native environments, Zombienet makes it easy to validate your blockchain implementation in a controlled environment.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Set Up the Project", - "anchor": "set-up-the-project" - }, - { - "depth": 2, - "title": "Set Up the Web3 Provider", - "anchor": "set-up-the-web3-provider" - }, - { - "depth": 2, - "title": "Contract Deployment", - "anchor": "contract-deployment" + "title": "What Can I Do with Zombienet?", + "anchor": "what-can-i-do-with-zombienet" }, { "depth": 2, - "title": "Interact with the Contract", - "anchor": "interact-with-the-contract" + "title": "In This Section", + "anchor": "in-this-section" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 11652, - "words": 1335, - "headings": 6, - "estimated_token_count_total": 2512 + "chars": 1237, + "words": 164, + "headings": 3, + "estimated_token_count_total": 193 }, - "hash": "sha256:5d13a0873a78a9802b06686d7caafbf4d23b6ba1edf7d3518943301f2b0110c4", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:1355969b6b0e723b42815b960c15eb128e4d936d0d707cd66e43820cff765ee3", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-local-development-node", - "title": "Local Development Node", - "slug": "develop-smart-contracts-local-development-node", + "id": "develop-toolkit-parachains-spawn-chains", + "title": "Spawn Networks for Testing", + "slug": "develop-toolkit-parachains-spawn-chains", "categories": [ - "Smart Contracts" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-local-development-node.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/local-development-node/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/spawn-chains/", + "preview": "Testing blockchain networks in a controlled environment is essential for development and validation. The Polkadot ecosystem provides specialized tools that enable you to spawn test networks, helping you verify functionality and catch issues before deploying to production.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Why Spawn a Network?", + "anchor": "why-spawn-a-network" }, { "depth": 2, - "title": "Install the Revive Dev Node and ETH-RPC Adapter", - "anchor": "install-the-revive-dev-node-and-eth-rpc-adapter" + "title": "In This Section", + "anchor": "in-this-section" }, { "depth": 2, - "title": "Run the Local Node", - "anchor": "run-the-local-node" + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 9064, - "words": 1433, - "headings": 4, - "estimated_token_count_total": 2432 + "chars": 1180, + "words": 155, + "headings": 3, + "estimated_token_count_total": 171 }, - "hash": "sha256:809d0ff921587f29045df1d31a5a9fe32ee13fa7b9698aa27ff9f60b2aa7a4d8", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:f11bfd20cb9a0932ce263b2dd763729320261bb25e1fa0039a45ccc609541391", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-overview", - "title": "Smart Contracts Overview", - "slug": "develop-smart-contracts-overview", - "categories": [ - "Basics", - "Smart Contracts" + "id": "develop-toolkit-parachains", + "title": "Parachains", + "slug": "develop-toolkit-parachains", + "categories": [ + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-overview.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/overview/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/", + "preview": "Within the Polkadot ecosystem, you'll find a robust set of development tools that empower developers to build, test, and deploy blockchain applications efficiently. Whether you're designing a custom parachain, testing new features, or validating network configurations, these tools streamline the development process and ensure your blockchain setup is secure and optimized.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Native Smart Contracts", - "anchor": "native-smart-contracts" - }, - { - "depth": 3, - "title": "Introduction", - "anchor": "introduction-2" - }, - { - "depth": 3, - "title": "Smart Contract Development", - "anchor": "smart-contract-development" - }, - { - "depth": 3, - "title": "Technical Architecture", - "anchor": "technical-architecture" - }, - { - "depth": 3, - "title": "Development Tools and Resources", - "anchor": "development-tools-and-resources" - }, - { - "depth": 3, - "title": "Cross-Chain Capabilities", - "anchor": "cross-chain-capabilities" - }, - { - "depth": 3, - "title": "Use Cases", - "anchor": "use-cases" + "title": "Quick Links", + "anchor": "quick-links" }, { "depth": 2, - "title": "Other Smart Contract Environments", - "anchor": "other-smart-contract-environments" - }, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 986, + "words": 136, + "headings": 2, + "estimated_token_count_total": 106 + }, + "hash": "sha256:88dda8aeab06294ccb773d8732d4791b052351ed0b1307d62019a637c9be341a", + "token_estimator": "heuristic-v1" + }, + { + "id": "develop-toolkit", + "title": "Toolkit", + "slug": "develop-toolkit", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit.md", + "html_url": "https://docs.polkadot.com/develop/toolkit/", + "preview": "Explore Polkadot's core development toolkit, designed to support a variety of developers and use cases within the ecosystem. Whether you're building blockchain infrastructure, developing cross-chain applications, or integrating with external services, this section offers essential tools and resources to help you succeed.", + "outline": [ { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "In This Section", + "anchor": "in-this-section" } ], "stats": { - "chars": 6294, - "words": 802, - "headings": 10, - "estimated_token_count_total": 1118 + "chars": 902, + "words": 113, + "headings": 1, + "estimated_token_count_total": 12 }, - "hash": "sha256:0468268436ffdb759cad8390a838d5fba2391118baa8fd8cd494b36397b10329", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:20c667a337791538e3997f1f449bf69b248ccc4cc806e22615075f24fd3f0202", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts-precompiles-interact-with-precompiles", - "title": "Interact with Precompiles", - "slug": "develop-smart-contracts-precompiles-interact-with-precompiles", + "id": "develop", + "title": "Develop", + "slug": "develop", "categories": [ - "Smart Contracts" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts-precompiles-interact-with-precompiles.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/precompiles/interact-with-precompiles/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop.md", + "html_url": "https://docs.polkadot.com/develop/", + "preview": "This guide is a starting point for developers who wish to build in the Polkadot ecosystem. To get the most from this section:", "outline": [ { "depth": 2, @@ -3714,343 +3430,248 @@ }, { "depth": 2, - "title": "Basic Precompile Interaction Pattern", - "anchor": "basic-precompile-interaction-pattern" - }, - { - "depth": 2, - "title": "ECRecover (0x01)", - "anchor": "ecrecover-0x01" - }, - { - "depth": 2, - "title": "SHA-256 (0x02)", - "anchor": "sha-256-0x02" - }, - { - "depth": 2, - "title": "RIPEMD-160 (0x03)", - "anchor": "ripemd-160-0x03" - }, - { - "depth": 2, - "title": "Identity (Data Copy) (0x04)", - "anchor": "identity-data-copy-0x04" - }, - { - "depth": 2, - "title": "Modular Exponentiation (0x05)", - "anchor": "modular-exponentiation-0x05" - }, - { - "depth": 2, - "title": "BN128 Addition (0x06)", - "anchor": "bn128-addition-0x06" + "title": "Development Pathways", + "anchor": "development-pathways" }, { - "depth": 2, - "title": "BN128 Scalar Multiplication (0x07)", - "anchor": "bn128-scalar-multiplication-0x07" + "depth": 3, + "title": "Parachain Developers", + "anchor": "parachain-developers" }, { - "depth": 2, - "title": "BN128 Pairing Check (0x08)", - "anchor": "bn128-pairing-check-0x08" + "depth": 3, + "title": "Smart Contract Developers", + "anchor": "smart-contract-developers" }, { - "depth": 2, - "title": "Blake2F (0x09)", - "anchor": "blake2f-0x09" + "depth": 3, + "title": "Application Developers", + "anchor": "application-developers" }, { "depth": 2, - "title": "Conclusion", - "anchor": "conclusion" + "title": "In This Section", + "anchor": "in-this-section" } ], "stats": { - "chars": 18054, - "words": 2190, - "headings": 12, - "estimated_token_count_total": 3847 + "chars": 6923, + "words": 882, + "headings": 6, + "estimated_token_count_total": 1843 }, - "hash": "sha256:4b705b8dbe9b0ad8d19a897d91f3c64dbc4541297dadacbea2a31b4778e50a46", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:1784f7b9e0552ab893c9d7d252299d53e36b6f57ef57c49cd5e36805399675ab", "token_estimator": "heuristic-v1" }, { - "id": "develop-smart-contracts", - "title": "Smart Contracts", - "slug": "develop-smart-contracts", + "id": "get-support-ai-ready-docs", + "title": "AI Ready Docs", + "slug": "get-support-ai-ready-docs", "categories": [ "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-smart-contracts.md", - "html_url": "https://docs.polkadot.com/develop/smart-contracts/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Polkadot allows scalable execution of smart contracts, offering cross-chain compatibility and lower fees than legacy L1 platforms. Polkadot provides developers with flexibility in building smart contracts, supporting both Solidity contracts executed by the [PolkaVM](/smart-contracts/for-eth-devs/#polkavm){target=\\_blank} (a Polkadot", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-ai-ready-docs.md", + "html_url": "https://docs.polkadot.com/get-support/ai-ready-docs/", + "preview": "Polkadot provides files to make documentation content available in a structure optimized for use with large language models (LLMs) and AI tools. These resources help build AI assistants, power code search, or enable custom tooling trained on Polkadot’s documentation.", "outline": [ { "depth": 2, - "title": "Smart Contract Development Process", - "anchor": "smart-contract-development-process" + "title": "How to Use These Files", + "anchor": "how-to-use-these-files" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Download LLM Files", + "anchor": "download-llm-files" } ], "stats": { - "chars": 1867, - "words": 247, + "chars": 7998, + "words": 825, "headings": 2, - "estimated_token_count_total": 189 + "estimated_token_count_total": 2232 }, - "hash": "sha256:605d2cbb7eabb2ea0fd928bc3ecdf9ee8b095e3dd9643f2b0918fef7b5a3f4a8", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:5a8da69a5cea8bd598ee4d102b9abed5d1a29153802a567e22bb4ee720410b32", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-api-libraries", - "title": "API Libraries", - "slug": "develop-toolkit-api-libraries", + "id": "get-support-explore-resources", + "title": "Subscribe to Updates", + "slug": "get-support-explore-resources", "categories": [ "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/api-libraries/", - "preview": "Explore the powerful API libraries designed for interacting with the Polkadot network. These libraries offer developers versatile tools to build, query, and manage blockchain interactions. Whether you’re working with JavaScript, TypeScript, Python, or RESTful services, they provide the flexibility to efficiently interact with and retrieve data from Polkadot-based chains.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-explore-resources.md", + "html_url": "https://docs.polkadot.com/get-support/explore-resources/", + "preview": "Looking for answers beyond the documentation? These platforms are full of useful content and experienced developers sharing insights.", "outline": [ { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "title": "🧠 Stack Exchange", + "anchor": "stack-exchange" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" - } - ], - "stats": { - "chars": 7299, - "words": 1047, - "headings": 6, - "estimated_token_count_total": 1638 - }, - "hash": "sha256:807cee6869059dd933905d1cf6c76e3b86e02baee3de3113f7e5b4c8697fbd22", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit-api-libraries-dedot", - "title": "Dedot", - "slug": "develop-toolkit-api-libraries-dedot", - "categories": [ - "Tooling", - "Dapps" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries-dedot.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/api-libraries/dedot/", - "preview": "[Dedot](https://github.com/dedotdev/dedot){target=\\_blank} is a next-generation JavaScript client for Polkadot and Polkadot SDK-based blockchains. Designed to elevate the dApp development experience, Dedot is built and optimized to be lightweight and tree-shakable, offering precise types and APIs suggestions for individual Polkadot SDK-based blockchains and [ink! smart contracts](https://use.ink/){target=\\_blank}.", - "outline": [ + "title": "🧵 Reddit: r/Polkadot", + "anchor": "reddit-rpolkadot" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "💬 Discord (Community Threads Only)", + "anchor": "discord-community-threads-only" }, { - "depth": 3, - "title": "Key Features", - "anchor": "key-features" + "depth": 2, + "title": "🎥 YouTube: @PolkadotNetwork", + "anchor": "youtube-polkadotnetwork" }, { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Community-Led Platforms and Ecosystem Updates", + "anchor": "community-led-platforms-and-ecosystem-updates" }, { - "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "depth": 3, + "title": "🔷 X (Twitter): Official Accounts", + "anchor": "x-twitter-official-accounts" }, { "depth": 3, - "title": "Initialize a Client Instance", - "anchor": "initialize-a-client-instance" + "title": "🔁 X (Twitter): Community Accounts", + "anchor": "x-twitter-community-accounts" }, { "depth": 3, - "title": "Enable Type and API Suggestions", - "anchor": "enable-type-and-api-suggestions" + "title": "🗣️ Polkadot Forum", + "anchor": "polkadot-forum" }, { "depth": 3, - "title": "Read On-Chain Data", - "anchor": "read-on-chain-data" + "title": "🧑‍⚖️ Polkassembly: OpenGov", + "anchor": "polkassembly-opengov" }, { "depth": 3, - "title": "Sign and Send Transactions", - "anchor": "sign-and-send-transactions" - }, - { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "📸 Instagram", + "anchor": "instagram" } ], "stats": { - "chars": 8855, - "words": 1100, - "headings": 9, - "estimated_token_count_total": 2300 + "chars": 2456, + "words": 295, + "headings": 10, + "estimated_token_count_total": 579 }, - "hash": "sha256:ba24e31e2ad94fbf1d73f1878da92dd2e1476db00170780bbdf0e65ab18bc961", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:4c33d0ec5026128b3bfdb1dfc1f4b29487404eaa8043071d536e8638356c6e1f", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-api-libraries-papi", - "title": "Polkadot-API", - "slug": "develop-toolkit-api-libraries-papi", + "id": "get-support-get-in-touch", + "title": "Get in Touch", + "slug": "get-support-get-in-touch", "categories": [ - "Tooling", - "Dapps" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries-papi.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/api-libraries/papi/", - "preview": "[Polkadot-API](https://github.com/polkadot-api/polkadot-api){target=\\_blank} (PAPI) is a set of libraries built to be modular, composable, and grounded in a “light-client first” approach. Its primary aim is to equip dApp developers with an extensive toolkit for building fully decentralized applications.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-get-in-touch.md", + "html_url": "https://docs.polkadot.com/get-support/get-in-touch/", + "preview": "Use one of the channels below to get live technical support or ask questions.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Need Help Fast?", + "anchor": "need-help-fast" }, { "depth": 2, - "title": "Get Started", - "anchor": "get-started" - }, - { - "depth": 3, - "title": "API Instantiation", - "anchor": "api-instantiation" - }, - { - "depth": 3, - "title": "Reading Chain Data", - "anchor": "reading-chain-data" + "title": "📱 Telegram: Polkadot Developer Support", + "anchor": "telegram-polkadot-developer-support" }, { - "depth": 3, - "title": "Sending Transactions", - "anchor": "sending-transactions" + "depth": 2, + "title": "🔌 Discord: Polkadot Official Server", + "anchor": "discord-polkadot-official-server" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "🧬 Matrix: Polkadot Developer Support", + "anchor": "matrix-polkadot-developer-support" } ], "stats": { - "chars": 8957, - "words": 1156, - "headings": 6, - "estimated_token_count_total": 1987 + "chars": 1949, + "words": 258, + "headings": 4, + "estimated_token_count_total": 557 }, - "hash": "sha256:2ca93b09d3bb9159bbf53816886a9b242bb3c13b996c51fd52962e049e2d5477", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:993e93b05c8fbdfc2f7510c61ac86bc4c2ff0f03e573695b2f260933c8b62f78", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-api-libraries-polkadart", - "title": "Polkadart", - "slug": "develop-toolkit-api-libraries-polkadart", + "id": "get-support", + "title": "Support", + "slug": "get-support", "categories": [ - "Tooling", - "Dapps" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries-polkadart.md", - "html_url": "https://docs.polkadot.com/reference/tools/polkadart/", - "preview": "Polkadart is the most comprehensive Dart/Flutter SDK for interacting with Polkadot, Substrate, and other compatible blockchain networks. Designed with a Dart-first approach and type-safe APIs, it provides everything developers need to build powerful decentralized applications.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support.md", + "html_url": "https://docs.polkadot.com/get-support/", + "preview": "Use one of the channels below to get live technical support or ask questions.", "outline": [ { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Need More than Just Documentation?", + "anchor": "need-more-than-just-documentation" }, { "depth": 2, - "title": "Get Started", - "anchor": "get-started" - }, - { - "depth": 3, - "title": "Type Generation", - "anchor": "type-generation" - }, - { - "depth": 3, - "title": "Run Generator", - "anchor": "run-generator" - }, - { - "depth": 3, - "title": "Use Generated Types", - "anchor": "use-generated-types" - }, - { - "depth": 3, - "title": "Creating an API Instance", - "anchor": "creating-an-api-instance" - }, - { - "depth": 3, - "title": "Reading Chain Data", - "anchor": "reading-chain-data" - }, - { - "depth": 3, - "title": "Subscribe to New Blocks", - "anchor": "subscribe-to-new-blocks" - }, - { - "depth": 3, - "title": "Send a Transaction", - "anchor": "send-a-transaction" + "title": "What You Can Do Here", + "anchor": "what-you-can-do-here" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Help Us Improve", + "anchor": "help-us-improve" } ], "stats": { - "chars": 5178, - "words": 624, - "headings": 10, - "estimated_token_count_total": 1084 + "chars": 1658, + "words": 244, + "headings": 3, + "estimated_token_count_total": 280 }, - "hash": "sha256:7f533abe61586af8438e350c41b741d74a8edb839f9dc4139bc4619ba3748258", - "last_modified": "2025-10-28T14:15:59+00:00", + "hash": "sha256:5bdc575ac798a971867a15651c2b4d5139bf0b1fe6854d1865deff280ae6d7f6", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-api-libraries-polkadot-js-api", - "title": "Polkadot.js API", - "slug": "develop-toolkit-api-libraries-polkadot-js-api", + "id": "index", + "title": "Polkadot Developer Docs", + "slug": "index", "categories": [ - "Tooling", - "Dapps" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries-polkadot-js-api.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/api-libraries/polkadot-js-api/", - "preview": "!!! warning \"Maintenance Mode Only\" The Polkadot.js API is now in maintenance mode and is no longer actively developed. New projects should use [Dedot](/develop/toolkit/api-libraries/dedot){target=\\_blank} (TypeScript-first API) or [Polkadot API](/develop/toolkit/api-libraries/papi){target=\\_blank} (modern, type-safe API) as actively maintained alternatives.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/index.md", + "html_url": "https://docs.polkadot.com/index/", + "preview": "Explore everything you need to start building on top of Polkadot, a protocol that provides parachains with shared security and interoperability using XCM.", + "outline": [], + "stats": { + "chars": 0, + "words": 0, + "headings": 0, + "estimated_token_count_total": 0 + }, + "hash": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "token_estimator": "heuristic-v1" + }, + { + "id": "nodes-and-validators-run-a-node-bootnode", + "title": "Set Up a Bootnode", + "slug": "nodes-and-validators-run-a-node-bootnode", + "categories": [ + "Infrastructure" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-node-bootnode.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-node/bootnode/", + "preview": "Bootnodes are essential for helping blockchain nodes discover peers and join the network. When a node starts, it needs to find other nodes, and bootnodes provide an initial point of contact. Once connected, a node can expand its peer connections and play its role in the network, like participating as a validator.", "outline": [ { "depth": 2, @@ -4058,68 +3679,65 @@ "anchor": "introduction" }, { - "depth": 3, - "title": "Dynamic API Generation", - "anchor": "dynamic-api-generation" + "depth": 2, + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 3, - "title": "Available API Categories", - "anchor": "available-api-categories" + "depth": 2, + "title": "Accessing the Bootnode", + "anchor": "accessing-the-bootnode" }, { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Node Key", + "anchor": "node-key" }, { "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "title": "Running the Bootnode", + "anchor": "running-the-bootnode" }, { - "depth": 3, - "title": "Creating an API Instance", - "anchor": "creating-an-api-instance" + "depth": 2, + "title": "Testing Bootnode Connection", + "anchor": "testing-bootnode-connection" }, { "depth": 3, - "title": "Reading Chain Data", - "anchor": "reading-chain-data" + "title": "P2P", + "anchor": "p2p" }, { "depth": 3, - "title": "Sending Transactions", - "anchor": "sending-transactions" + "title": "P2P/WS", + "anchor": "p2pws" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "depth": 3, + "title": "P2P/WSS", + "anchor": "p2pwss" } ], "stats": { - "chars": 5042, - "words": 684, + "chars": 4538, + "words": 647, "headings": 9, - "estimated_token_count_total": 1166 + "estimated_token_count_total": 1044 }, - "hash": "sha256:ed3986f30880fefca5975fcdc847c68b4aca65862c63e3002b25391b0521781d", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:d84a5af1a0237a911d25a68c077f508ebbce608f673ef4f9055e8e434daa96b9", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-api-libraries-py-substrate-interface", - "title": "Python Substrate Interface", - "slug": "develop-toolkit-api-libraries-py-substrate-interface", + "id": "nodes-and-validators-run-a-node-full-node", + "title": "Set Up a Node", + "slug": "nodes-and-validators-run-a-node-full-node", "categories": [ - "Tooling", - "Dapps" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries-py-substrate-interface.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/api-libraries/py-substrate-interface/", - "preview": "The [Python Substrate Interface](https://github.com/polkascan/py-substrate-interface){target=\\_blank} is a powerful library that enables interaction with Polkadot SDK-based chains. It provides essential functionality for:", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-node-full-node.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-node/full-node/", + "preview": "Running a node on Polkadot provides direct interaction with the network, enhanced privacy, and full control over RPC requests, transactions, and data queries. As the backbone of the network, nodes ensure decentralized data propagation, transaction validation, and seamless communication across the ecosystem.", "outline": [ { "depth": 2, @@ -4128,57 +3746,64 @@ }, { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Set Up a Node", + "anchor": "set-up-a-node" }, { - "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "depth": 3, + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 3, - "title": "Establishing Connection", - "anchor": "establishing-connection" + "title": "Install and Build the Polkadot Binary", + "anchor": "install-and-build-the-polkadot-binary" }, { "depth": 3, - "title": "Reading Chain State", - "anchor": "reading-chain-state" + "title": "Use Docker", + "anchor": "use-docker" + }, + { + "depth": 2, + "title": "Configure and Run Your Node", + "anchor": "configure-and-run-your-node" }, { "depth": 3, - "title": "Submitting Transactions", - "anchor": "submitting-transactions" + "title": "RPC Configurations", + "anchor": "rpc-configurations" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], + "title": "Sync Your Node", + "anchor": "sync-your-node" + }, + { + "depth": 3, + "title": "Connect to Your Node", + "anchor": "connect-to-your-node" + } + ], "stats": { - "chars": 4302, - "words": 541, - "headings": 7, - "estimated_token_count_total": 942 + "chars": 15947, + "words": 2482, + "headings": 9, + "estimated_token_count_total": 4197 }, - "hash": "sha256:8987fc35cd28602054ee018031f773e2e3837425107c51d0e2ac68a94b86e9c0", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:b83e3f77bd30ac8c8fb00a193bbec33cd641d94f1a37ac611dea32326c3d77b0", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-api-libraries-sidecar", - "title": "Sidecar Rest API", - "slug": "develop-toolkit-api-libraries-sidecar", + "id": "nodes-and-validators-run-a-node-secure-wss", + "title": "Set Up Secure WebSocket", + "slug": "nodes-and-validators-run-a-node-secure-wss", "categories": [ - "Tooling", - "Dapps" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries-sidecar.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/api-libraries/sidecar/", - "preview": "The [Sidecar Rest API](https://github.com/paritytech/substrate-api-sidecar){target=\\_blank} is a service that provides a REST interface for interacting with Polkadot SDK-based blockchains. With this API, developers can easily access a broad range of endpoints for nodes, accounts, transactions, parachains, and more.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-node-secure-wss.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-node/secure-wss/", + "preview": "Ensuring secure WebSocket communication is crucial for maintaining the integrity and security of a Polkadot or Kusama node when interacting with remote clients. This guide walks you through setting up a secure WebSocket (WSS) connection for your node by leveraging SSL encryption with popular web server proxies like nginx or Apache.", "outline": [ { "depth": 2, @@ -4187,52 +3812,54 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Secure a WebSocket Port", + "anchor": "secure-a-websocket-port" }, { - "depth": 2, - "title": "Installation", - "anchor": "installation" + "depth": 3, + "title": "Obtain an SSL Certificate", + "anchor": "obtain-an-ssl-certificate" }, { "depth": 2, - "title": "Usage", - "anchor": "usage" + "title": "Install a Proxy Server", + "anchor": "install-a-proxy-server" }, { "depth": 3, - "title": "Endpoints", - "anchor": "endpoints" + "title": "Use nginx", + "anchor": "use-nginx" + }, + { + "depth": 3, + "title": "Use Apache2", + "anchor": "use-apache2" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Connect to the Node", + "anchor": "connect-to-the-node" } ], "stats": { - "chars": 7309, - "words": 1033, - "headings": 6, - "estimated_token_count_total": 1945 + "chars": 5568, + "words": 774, + "headings": 7, + "estimated_token_count_total": 1280 }, - "hash": "sha256:b8759f61ab57b636228b69d5770c74591998b912cd4596e89eb2ec011da7ef73", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:992082e4ad87348b283f6c37ea886ae0e7bf016852b6470000876f3d169c65a4", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-api-libraries-subxt", - "title": "Subxt Rust API", - "slug": "develop-toolkit-api-libraries-subxt", + "id": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-key-management", + "title": "Validator Key Management", + "slug": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-key-management", "categories": [ - "Tooling", - "Dapps" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-api-libraries-subxt.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/api-libraries/subxt/", - "preview": "Subxt is a Rust library designed to interact with Polkadot SDK-based blockchains. It provides a type-safe interface for submitting transactions, querying on-chain state, and performing other blockchain interactions. By leveraging Rust's strong type system, subxt ensures that your code is validated at compile time, reducing runtime errors and improving reliability.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-onboarding-and-offboarding-key-management.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/onboarding-and-offboarding/key-management/", + "preview": "After setting up your node environment as shown in the [Setup](/nodes-and-validators/run-a-validator/onboarding-and-offboarding/set-up-validator/){target=\\_blank} section, you'll need to configure multiple keys for your validator to operate properly. This includes setting up session keys, which are essential for participating in the consensus process, and configuring a node key that maintains a stable network identity. This guide walks you through the key management process, showing you how to g", "outline": [ { "depth": 2, @@ -4241,201 +3868,140 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Installation", - "anchor": "installation" - }, - { - "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "title": "Set Session Keys", + "anchor": "set-session-keys" }, { "depth": 3, - "title": "Download Chain Metadata", - "anchor": "download-chain-metadata" + "title": "Generate Session Keys", + "anchor": "generate-session-keys" }, { "depth": 3, - "title": "Generate Type-Safe Interfaces", - "anchor": "generate-type-safe-interfaces" + "title": "Submit Transaction to Set Keys", + "anchor": "submit-transaction-to-set-keys" }, { "depth": 3, - "title": "Initialize the Subxt Client", - "anchor": "initialize-the-subxt-client" + "title": "Verify Session Key Setup", + "anchor": "verify-session-key-setup" }, { - "depth": 3, - "title": "Read Chain Data", - "anchor": "read-chain-data" + "depth": 2, + "title": "Set the Node Key", + "anchor": "set-the-node-key" }, { "depth": 3, - "title": "Submit Transactions", - "anchor": "submit-transactions" + "title": "Generate the Node Key", + "anchor": "generate-the-node-key" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "depth": 3, + "title": "Set Node Key", + "anchor": "set-node-key" } ], "stats": { - "chars": 9174, - "words": 1175, - "headings": 10, - "estimated_token_count_total": 2187 + "chars": 8227, + "words": 1183, + "headings": 8, + "estimated_token_count_total": 1840 }, - "hash": "sha256:56269d9ea47f5b4e92cd7d5a1e65ab06d181a9c380f90bb3ef285529b12299f7", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:0fb5a83835aab263c0b9aa886028c8aa8a2d6d0897d7b9fff4b5258835d30dfe", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-integrations-indexers", - "title": "Indexers", - "slug": "develop-toolkit-integrations-indexers", + "id": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-set-up-validator", + "title": "Set Up a Validator", + "slug": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-set-up-validator", "categories": [ - "Tooling", - "Dapps" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-integrations-indexers.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/integrations/indexers/", - "preview": "Blockchain data is inherently sequential and distributed, with information stored chronologically across numerous blocks. While retrieving data from a single block through JSON-RPC API calls is straightforward, more complex queries that span multiple blocks present significant challenges:", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-onboarding-and-offboarding-set-up-validator.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/onboarding-and-offboarding/set-up-validator/", + "preview": "Setting up a Polkadot validator node is essential for securing the network and earning staking rewards. This guide walks you through the technical steps to set up a validator, from installing the necessary software to managing keys and synchronizing your node with the chain.", "outline": [ { "depth": 2, - "title": "The Challenge of Blockchain Data Access", - "anchor": "the-challenge-of-blockchain-data-access" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "What is a Blockchain Indexer?", - "anchor": "what-is-a-blockchain-indexer" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "Indexer Implementations", - "anchor": "indexer-implementations" - } - ], - "stats": { - "chars": 2230, - "words": 302, - "headings": 3, - "estimated_token_count_total": 428 - }, - "hash": "sha256:cfcc76bb24779c9b613f2c046b6f99a0f2529c25fd82287d804f6b945b936227", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit-integrations-oracles", - "title": "Oracles", - "slug": "develop-toolkit-integrations-oracles", - "categories": [ - "Tooling", - "Dapps" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-integrations-oracles.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/integrations/oracles/", - "preview": "Oracles enable blockchains to access external data sources. Since blockchains operate as isolated networks, they cannot natively interact with external systems - this limitation is known as the \"blockchain oracle problem.\" Oracles solves this by extracting data from external sources (like APIs, IoT devices, or other blockchains), validating it, and submitting it on-chain.", - "outline": [ + "title": "Initial Setup", + "anchor": "initial-setup" + }, { - "depth": 2, - "title": "What is a Blockchain Oracle?", - "anchor": "what-is-a-blockchain-oracle" + "depth": 3, + "title": "Install Network Time Protocol Client", + "anchor": "install-network-time-protocol-client" }, { - "depth": 2, - "title": "Oracle Implementations", - "anchor": "oracle-implementations" - } - ], - "stats": { - "chars": 1343, - "words": 181, - "headings": 2, - "estimated_token_count_total": 187 - }, - "hash": "sha256:6d8e01281a5895fd2bc4438b24c170c72a496de0b838626a53e87685aea4aa25", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit-integrations-storage", - "title": "Storage", - "slug": "develop-toolkit-integrations-storage", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-integrations-storage.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/integrations/storage/", - "preview": "Polkadot offers developers a range of decentralized storage solutions to manage dApp data, host front ends, and store large files in a censorship-resistant and resilient manner. These integrations are essential for building fully decentralized applications, ensuring that all components of your dApp, from the front end to the data, are not reliant on centralized servers.", - "outline": [ + "depth": 3, + "title": "Verify Landlock is Activated", + "anchor": "verify-landlock-is-activated" + }, { "depth": 2, - "title": "Key Storage Solutions", - "anchor": "key-storage-solutions" + "title": "Install the Polkadot Binaries", + "anchor": "install-the-polkadot-binaries" }, { - "depth": 2, - "title": "Crust Network", - "anchor": "crust-network" + "depth": 3, + "title": "Install from Official Releases", + "anchor": "install-from-official-releases" }, { "depth": 3, - "title": "Key Features of Crust", - "anchor": "key-features-of-crust" + "title": "Install with Package Managers", + "anchor": "install-with-package-managers" }, { "depth": 3, - "title": "Use Cases", - "anchor": "use-cases" + "title": "Install with Ansible", + "anchor": "install-with-ansible" }, { - "depth": 2, - "title": "IPFS", - "anchor": "ipfs" + "depth": 3, + "title": "Install with Docker", + "anchor": "install-with-docker" }, { "depth": 3, - "title": "Using IPFS with Polkadot", - "anchor": "using-ipfs-with-polkadot" + "title": "Build from Sources", + "anchor": "build-from-sources" }, { "depth": 2, - "title": "Other Solutions", - "anchor": "other-solutions" + "title": "Verify Installation", + "anchor": "verify-installation" } ], "stats": { - "chars": 4369, - "words": 642, - "headings": 7, - "estimated_token_count_total": 847 + "chars": 11921, + "words": 1678, + "headings": 12, + "estimated_token_count_total": 2592 }, - "hash": "sha256:a206dd86fc3d80aed22384000839ca0c9c75c69ad461abd9810d96c03cf6a3bd", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:d2c1c91734bc8185057d8eeec6829ea91e0316f7ba884c5dc3922a5e5778815e", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-integrations-transaction-construction", - "title": "Transaction Construction", - "slug": "develop-toolkit-integrations-transaction-construction", + "id": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-start-validating", + "title": "Start Validating", + "slug": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-start-validating", "categories": [ - "Uncategorized" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-integrations-transaction-construction.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/integrations/transaction-construction/", - "preview": "This page will discuss the transaction format in Polkadot and how to create, sign, and broadcast transactions, as well as highlight some of the commands and tools available for integrators.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-onboarding-and-offboarding-start-validating.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/onboarding-and-offboarding/start-validating/", + "preview": "After configuring your node keys as shown in the [Key Management](/nodes-and-validators/run-a-validator/onboarding-and-offboarding/key-management/){target=\\_blank} section and ensuring your system is set up, you're ready to begin the validator setup process. This guide will walk you through choosing a network, synchronizing your node with the blockchain, bonding your DOT tokens, and starting your validator.", "outline": [ { "depth": 2, @@ -4444,196 +4010,130 @@ }, { "depth": 2, - "title": "Transaction Format", - "anchor": "transaction-format" + "title": "Choose a Network", + "anchor": "choose-a-network" }, { - "depth": 3, - "title": "Mode and Metadata Hash", - "anchor": "mode-and-metadata-hash" + "depth": 2, + "title": "Synchronize Chain Data", + "anchor": "synchronize-chain-data" }, { "depth": 3, - "title": "Serialized Transactions and Metadata", - "anchor": "serialized-transactions-and-metadata" + "title": "Database Snapshot Services", + "anchor": "database-snapshot-services" + }, + { + "depth": 2, + "title": "Bond DOT", + "anchor": "bond-dot" }, { "depth": 3, - "title": "Transaction Flow", - "anchor": "transaction-flow" + "title": "Bonding DOT on Polkadot.js Apps", + "anchor": "bonding-dot-on-polkadotjs-apps" }, { "depth": 2, - "title": "Polkadot-JS Tools", - "anchor": "polkadot-js-tools" + "title": "Validate", + "anchor": "validate" }, { "depth": 3, - "title": "Creating a Transaction, Signing, and Submitting", - "anchor": "creating-a-transaction-signing-and-submitting" + "title": "Verify Sync via Telemetry", + "anchor": "verify-sync-via-telemetry" }, { - "depth": 2, - "title": "Txwrapper", - "anchor": "txwrapper" + "depth": 3, + "title": "Activate using Polkadot.js Apps", + "anchor": "activate-using-polkadotjs-apps" }, { "depth": 3, - "title": "Creating a Transaction, Signing, and Submitting", - "anchor": "creating-a-transaction-signing-and-submitting-2" + "title": "Monitor Validation Status and Slots", + "anchor": "monitor-validation-status-and-slots" }, { "depth": 2, - "title": "Additional Libraries for Submitting a Transaction", - "anchor": "additional-libraries-for-submitting-a-transaction" - } - ], - "stats": { - "chars": 27671, - "words": 2949, - "headings": 10, - "estimated_token_count_total": 6280 - }, - "hash": "sha256:9b03477d13a285fced6bf845c3827084f790a626989dc2c09ef9ff53643045f4", - "last_modified": "2025-10-28T14:42:13+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit-integrations", - "title": "Integrations", - "slug": "develop-toolkit-integrations", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-integrations.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/integrations/", - "preview": "Polkadot offers a wide range of integrations that allow developers to enhance their decentralized applications (dApps) and leverage the full capabilities of the ecosystem. Whether you’re looking to extend your application’s functionality, integrate with other chains, or access specialized services, these integrations provide the tools and resources you need to build efficiently and effectively. Explore the available options to find the solutions that best suit your development needs.", - "outline": [ + "title": "Run a Validator Using Systemd", + "anchor": "run-a-validator-using-systemd" + }, { - "depth": 2, - "title": "Key Integration Solutions", - "anchor": "key-integration-solutions" + "depth": 3, + "title": "Create the Systemd Service File", + "anchor": "create-the-systemd-service-file" }, { - "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "depth": 3, + "title": "Run the Service", + "anchor": "run-the-service" } ], "stats": { - "chars": 988, - "words": 135, - "headings": 2, - "estimated_token_count_total": 92 + "chars": 15821, + "words": 2446, + "headings": 13, + "estimated_token_count_total": 3861 }, - "hash": "sha256:62c5ad101282227f79eac0e30a3ba9ce3ae1bf9e358bd58c0b17ef45db29c2ff", - "last_modified": "2025-10-28T14:15:59+00:00", + "hash": "sha256:c74cfa542fe7a5235b81120f0004576aea83e0d35458201689b68d87f2969749", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-interoperability", - "title": "Interoperability", - "slug": "develop-toolkit-interoperability", + "id": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-stop-validating", + "title": "Stop Validating", + "slug": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-stop-validating", "categories": [ - "Uncategorized" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-interoperability.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/interoperability/", - "preview": "Polkadot's XCM tooling ecosystem redefines the boundaries of cross-chain communication and asset movement. With unparalleled flexibility and scalability, these advanced tools empower developers to build decentralized applications that connect parachains, relay chains, and external networks. By bridging siloed blockchains, Polkadot paves the way for a unified, interoperable ecosystem that accelerates innovation and collaboration.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-onboarding-and-offboarding-stop-validating.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/onboarding-and-offboarding/stop-validating/", + "preview": "If you're ready to stop validating on Polkadot, there are essential steps to ensure a smooth transition while protecting your funds and account integrity. Whether you're taking a break for maintenance or unbonding entirely, you'll need to chill your validator, purge session keys, and unbond your tokens. This guide explains how to use Polkadot's tools and extrinsics to safely withdraw from validation activities, safeguarding your account's future usability.", "outline": [ { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 1010, - "words": 128, - "headings": 1, - "estimated_token_count_total": 12 - }, - "hash": "sha256:966ec1bcc014a454f6b837b503025d9fb89c30f6a65d0aaec82ea5ff976e53a9", - "last_modified": "2025-10-28T14:15:59+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit-parachains-e2e-testing", - "title": "E2E Testing on Polkadot SDK Chains", - "slug": "develop-toolkit-parachains-e2e-testing", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-e2e-testing.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/e2e-testing/", - "preview": ":::INSERT_IN_THIS_SECTION:::", - "outline": [ + "title": "Introduction", + "anchor": "introduction" + }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 64, - "words": 6, - "headings": 1, - "estimated_token_count_total": 12 - }, - "hash": "sha256:47328231d6ff4dc52cd93aaf1baf5d0bc2d9fc372f3d79339d87aafa0dabd1b8", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit-parachains-fork-chains-chopsticks", - "title": "Chopsticks", - "slug": "develop-toolkit-parachains-fork-chains-chopsticks", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-fork-chains-chopsticks.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/fork-chains/chopsticks/", - "preview": "Chopsticks is a powerful tool that lets you create local copies of running Polkadot SDK-based networks. By forking live chains locally, you can safely test features, analyze network behavior, and simulate complex scenarios without affecting production networks.", - "outline": [ + "title": "Pause Versus Stop", + "anchor": "pause-versus-stop" + }, { "depth": 2, - "title": "What Can I Do with Chopsticks?", - "anchor": "what-can-i-do-with-chopsticks" + "title": "Chill Validator", + "anchor": "chill-validator" }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "title": "Purge Validator Session Keys", + "anchor": "purge-validator-session-keys" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Unbond Your Tokens", + "anchor": "unbond-your-tokens" } ], "stats": { - "chars": 1495, - "words": 201, - "headings": 3, - "estimated_token_count_total": 291 + "chars": 3230, + "words": 500, + "headings": 5, + "estimated_token_count_total": 629 }, - "hash": "sha256:2c77cfb38bb2e466a8f56dabbb706fcd2e90cf1634fc9beb7f0ee95a75735653", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:0d6db361bfa7a3022849bbe39989bfdac0429537498d7f534adadec131afca98", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains-fork-chains-chopsticks-get-started", - "title": "Get Started", - "slug": "develop-toolkit-parachains-fork-chains-chopsticks-get-started", + "id": "nodes-and-validators-run-a-validator-operational-tasks-general-management", + "title": "General Management", + "slug": "nodes-and-validators-run-a-validator-operational-tasks-general-management", "categories": [ - "Parachains", - "Tooling" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-fork-chains-chopsticks-get-started.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/fork-chains/chopsticks/get-started/", - "preview": "[Chopsticks](https://github.com/AcalaNetwork/chopsticks/){target=\\_blank}, developed by the [Acala Foundation](https://github.com/AcalaNetwork){target=\\_blank}, is a versatile tool tailored for developers working on Polkadot SDK-based blockchains. With Chopsticks, you can fork live chains locally, replay blocks to analyze extrinsics, and simulate complex scenarios like XCM interactions all without deploying to a live network.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-operational-tasks-general-management.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/operational-tasks/general-management/", + "preview": "Validator performance is pivotal in maintaining the security and stability of the Polkadot network. As a validator, optimizing your setup ensures efficient transaction processing, minimizes latency, and maintains system reliability during high-demand periods. Proper configuration and proactive monitoring also help mitigate risks like slashing and service interruptions.", "outline": [ { "depth": 2, @@ -4642,81 +4142,83 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Configuration Optimization", + "anchor": "configuration-optimization" }, { - "depth": 2, - "title": "Install Chopsticks", - "anchor": "install-chopsticks" + "depth": 3, + "title": "Deactivate Simultaneous Multithreading", + "anchor": "deactivate-simultaneous-multithreading" }, { "depth": 3, - "title": "Global Installation", - "anchor": "global-installation" + "title": "Deactivate Automatic NUMA Balancing", + "anchor": "deactivate-automatic-numa-balancing" }, { "depth": 3, - "title": "Local Installation", - "anchor": "local-installation" + "title": "Spectre and Meltdown Mitigations", + "anchor": "spectre-and-meltdown-mitigations" }, { "depth": 2, - "title": "Configure Chopsticks", - "anchor": "configure-chopsticks" + "title": "Monitor Your Node", + "anchor": "monitor-your-node" }, { "depth": 3, - "title": "Configuration File", - "anchor": "configuration-file" + "title": "Environment Setup", + "anchor": "environment-setup" }, { "depth": 3, - "title": "CLI Flags", - "anchor": "cli-flags" + "title": "Install and Configure Prometheus", + "anchor": "install-and-configure-prometheus" }, { - "depth": 2, - "title": "WebSocket Commands", - "anchor": "websocket-commands" + "depth": 3, + "title": "Start Prometheus", + "anchor": "start-prometheus" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 10894, - "words": 1330, - "headings": 10, - "estimated_token_count_total": 2614 - }, - "hash": "sha256:4325cdd697814b8043db808da3dee86d3d9c6fc7dd523aae7fe8914d59d1b39c", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit-parachains-light-clients", - "title": "develop-toolkit-parachains-light-clients", - "slug": "develop-toolkit-parachains-light-clients", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-fork-chains.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/fork-chains/", - "preview": "Explore tools for forking live blockchain networks. These tools enable you to replicate real-world conditions in a local environment for accurate testing and debugging. They also allow you to analyze network behavior, test new features, and simulate complex scenarios in a controlled environment without affecting production systems.", - "outline": [ + "depth": 3, + "title": "Install and Configure Grafana", + "anchor": "install-and-configure-grafana" + }, { - "depth": 2, - "title": "Why Fork a Live Chain?", - "anchor": "why-fork-a-live-chain" + "depth": 3, + "title": "Install and Configure Alertmanager", + "anchor": "install-and-configure-alertmanager" }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "title": "Secure Your Validator", + "anchor": "secure-your-validator" + }, + { + "depth": 3, + "title": "Key Management", + "anchor": "key-management" + }, + { + "depth": 3, + "title": "Signing Outside the Client", + "anchor": "signing-outside-the-client" + }, + { + "depth": 3, + "title": "Secure-Validator Mode", + "anchor": "secure-validator-mode" + }, + { + "depth": 3, + "title": "Linux Best Practices", + "anchor": "linux-best-practices" + }, + { + "depth": 3, + "title": "Validator Best Practices", + "anchor": "validator-best-practices" }, { "depth": 2, @@ -4725,26 +4227,24 @@ } ], "stats": { - "chars": 1269, - "words": 173, - "headings": 3, - "estimated_token_count_total": 183 + "chars": 26673, + "words": 3357, + "headings": 18, + "estimated_token_count_total": 5866 }, - "hash": "sha256:1284c42be692167e01bcc44e2e134ec20615402675fac26df246c00aa1588d80", - "last_modified": "2025-10-28T14:15:59+00:00", + "hash": "sha256:81eb0fe77f05155f1ec0511cd066120fc9994961e9d91e21b6666377e65b4586", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains-polkadot-omni-node", - "title": "Polkadot Omni Node", - "slug": "develop-toolkit-parachains-polkadot-omni-node", + "id": "nodes-and-validators-run-a-validator-operational-tasks-pause-validating", + "title": "Pause Validating", + "slug": "nodes-and-validators-run-a-validator-operational-tasks-pause-validating", "categories": [ - "Parachains", - "Tooling" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-polkadot-omni-node.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/polkadot-omni-node/", - "preview": "The [`polkadot-omni-node`](https://crates.io/crates/polkadot-omni-node/0.7.0){target=\\_blank} crate is a versatile, pre-built binary designed to simplify running parachains in the Polkadot ecosystem. Unlike traditional node binaries that are tightly coupled to specific runtime code, the `polkadot-omni-node` operates using an external [chain specification](/polkadot-protocol/glossary#chain-specification){target=\\_blank} file, allowing it to adapt dynamically to different parachains.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-operational-tasks-pause-validating.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/operational-tasks/pause-validating/", + "preview": "If you need to temporarily stop participating in Polkadot staking activities without fully unbonding your funds, chilling your account allows you to do so efficiently. Chilling removes your node from active validation or nomination in the next era while keeping your funds bonded, making it ideal for planned downtimes or temporary pauses.", "outline": [ { "depth": 2, @@ -4753,67 +4253,49 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Install Polkadot Omni Node", - "anchor": "install-polkadot-omni-node" + "title": "Chilling Your Node", + "anchor": "chilling-your-node" }, { "depth": 2, - "title": "Obtain Chain Specifications", - "anchor": "obtain-chain-specifications" + "title": "Staking Election Timing Considerations", + "anchor": "staking-election-timing-considerations" }, { "depth": 2, - "title": "Run a Parachain Full Node", - "anchor": "run-a-parachain-full-node" + "title": "Chilling as a Nominator", + "anchor": "chilling-as-a-nominator" }, { "depth": 2, - "title": "Interact with the Node", - "anchor": "interact-with-the-node" + "title": "Chilling as a Validator", + "anchor": "chilling-as-a-validator" }, { "depth": 2, - "title": "Parachain Compatibility", - "anchor": "parachain-compatibility" - }, - { - "depth": 3, - "title": "Required Runtime APIs", - "anchor": "required-runtime-apis" - }, - { - "depth": 3, - "title": "Required Pallets", - "anchor": "required-pallets" + "title": "Chill Other", + "anchor": "chill-other" } ], "stats": { - "chars": 8916, - "words": 1165, - "headings": 9, - "estimated_token_count_total": 2018 + "chars": 4439, + "words": 679, + "headings": 6, + "estimated_token_count_total": 861 }, - "hash": "sha256:49866761ef638dd0683bb5558f5319b9568ff136295b3359580a6f478172c73f", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:1af153570ce57bd5b52d08493a300996765686f2a6d04519a2e0aa91191612c1", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains-quickstart-pop-cli", - "title": "Quickstart Parachain Development with Pop CLI", - "slug": "develop-toolkit-parachains-quickstart-pop-cli", + "id": "nodes-and-validators-run-a-validator-operational-tasks-upgrade-your-node", + "title": "Upgrade a Validator Node", + "slug": "nodes-and-validators-run-a-validator-operational-tasks-upgrade-your-node", "categories": [ - "Parachains", - "Tooling" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-quickstart-pop-cli.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/quickstart/pop-cli/", - "preview": "[Pop CLI](https://onpop.io/cli/){target=\\_blank} is a powerful command-line tool designed explicitly for rapid parachain development within the Polkadot ecosystem. It addresses essential developer needs by providing streamlined commands to set up development environments, scaffold parachain templates, and manage local blockchain networks.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-operational-tasks-upgrade-your-node.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/operational-tasks/upgrade-your-node/", + "preview": "Upgrading a Polkadot validator node is essential for staying current with network updates and maintaining optimal performance. This guide covers routine and extended maintenance scenarios, including software upgrades and major server changes. Following these steps, you can manage session keys and transition smoothly between servers without risking downtime, slashing, or network disruptions. The process requires strategic planning, especially if you need to perform long-lead maintenance, ensuring", "outline": [ { "depth": 2, @@ -4821,46 +4303,55 @@ "anchor": "introduction" }, { - "depth": 3, - "title": "Install Pop CLI", - "anchor": "install-pop-cli" + "depth": 2, + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 3, - "title": "Set Up Your Development Environment", - "anchor": "set-up-your-development-environment" + "depth": 2, + "title": "Session Keys", + "anchor": "session-keys" }, { - "depth": 3, - "title": "Initialize a Project", - "anchor": "initialize-a-project" + "depth": 2, + "title": "Keystore", + "anchor": "keystore" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Upgrade Using Backup Validator", + "anchor": "upgrade-using-backup-validator" + }, + { + "depth": 3, + "title": "Session `N`", + "anchor": "session-n" + }, + { + "depth": 3, + "title": "Session `N+3`", + "anchor": "session-n3" } ], "stats": { - "chars": 4236, - "words": 610, - "headings": 5, - "estimated_token_count_total": 999 + "chars": 5650, + "words": 851, + "headings": 7, + "estimated_token_count_total": 1185 }, - "hash": "sha256:6d6c66430a7302f29113924c5208e64d7c244497e50c61ab2f45c4b5141620e4", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:888230b128d8c648c4f06a18d3b1d1b06dd1bf22a0de4add1f28210ffccb2549", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains-remote-proxies", - "title": "Remote Proxies", - "slug": "develop-toolkit-parachains-remote-proxies", + "id": "nodes-and-validators-run-a-validator-requirements", + "title": "Validator Requirements", + "slug": "nodes-and-validators-run-a-validator-requirements", "categories": [ - "Uncategorized" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-remote-proxies.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/remote-proxies/", - "preview": "!!!warning \"Kusama Implementation Only\" Remote proxies are currently only available on Kusama and its parachains (such as Kusama Asset Hub). This feature is not yet deployed on Polkadot MainNet. The examples and implementations described in this guide are specific to the Kusama ecosystem.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-requirements.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/requirements/", + "preview": "Running a validator in the Polkadot ecosystem is essential for maintaining network security and decentralization. Validators are responsible for validating transactions and adding new blocks to the chain, ensuring the system operates smoothly. In return for their services, validators earn rewards. However, the role comes with inherent risks, such as slashing penalties for misbehavior or technical failures. If you’re new to validation, starting on Kusama provides a lower-stakes environment to gai", "outline": [ { "depth": 2, @@ -4869,60 +4360,44 @@ }, { "depth": 2, - "title": "Remote Proxy Architecture", - "anchor": "remote-proxy-architecture" - }, - { - "depth": 2, - "title": "Implementation Workflow", - "anchor": "implementation-workflow" - }, - { - "depth": 2, - "title": "Practical Implementation", - "anchor": "practical-implementation" - }, - { - "depth": 3, "title": "Prerequisites", "anchor": "prerequisites" }, { - "depth": 3, - "title": "Installation and Setup", - "anchor": "installation-and-setup" + "depth": 2, + "title": "Minimum Hardware Requirements", + "anchor": "minimum-hardware-requirements" }, { - "depth": 3, - "title": "Implementation Example", - "anchor": "implementation-example" + "depth": 2, + "title": "VPS Provider List", + "anchor": "vps-provider-list" }, { "depth": 2, - "title": "Resources", - "anchor": "resources" + "title": "Minimum Bond Requirement", + "anchor": "minimum-bond-requirement" } ], "stats": { - "chars": 9063, - "words": 1113, - "headings": 8, - "estimated_token_count_total": 1863 + "chars": 6842, + "words": 944, + "headings": 5, + "estimated_token_count_total": 1485 }, - "hash": "sha256:7086406b31e7aa9089b221ffaa548ee5540a3d147ec1e93136f481c883f2e434", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:46435b97c37ef6798d2c75c69df31c5e5f07e04b218c370ec5af6b1838d43aac", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains-rpc-calls", - "title": "RPC Calls to Polkadot SDK chains.", - "slug": "develop-toolkit-parachains-rpc-calls", + "id": "nodes-and-validators-run-a-validator-staking-mechanics-offenses-and-slashes", + "title": "Offenses and Slashes", + "slug": "nodes-and-validators-run-a-validator-staking-mechanics-offenses-and-slashes", "categories": [ - "Uncategorized" + "Infrastructure" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-rpc-calls.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/rpc-calls/", - "preview": "[Remote Procedure Call](https://en.wikipedia.org/wiki/Remote_procedure_call){target=\\_blank} (RPC) interfaces are the primary way to interact programmatically with Polkadot SDK-based parachains and relay chains. RPC calls allow you to query chain state, submit transactions, and monitor network health from external applications or scripts.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-staking-mechanics-offenses-and-slashes.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/staking-mechanics/offenses-and-slashes/", + "preview": "In Polkadot's Nominated Proof of Stake (NPoS) system, validator misconduct is deterred through a combination of slashing, disabling, and reputation penalties. Validators and nominators who stake tokens face consequences for validator misbehavior, which range from token slashes to restrictions on network participation.", "outline": [ { "depth": 2, @@ -4931,86 +4406,115 @@ }, { "depth": 2, - "title": "How Do RPC Calls Work?", - "anchor": "how-do-rpc-calls-work" + "title": "Offenses", + "anchor": "offenses" }, { - "depth": 2, - "title": "Making RPC Calls with Curl", - "anchor": "making-rpc-calls-with-curl" + "depth": 3, + "title": "Invalid Votes", + "anchor": "invalid-votes" + }, + { + "depth": 3, + "title": "Equivocations", + "anchor": "equivocations" }, { "depth": 2, - "title": "Essential RPC Methods", - "anchor": "essential-rpc-methods" + "title": "Penalties", + "anchor": "penalties" }, { "depth": 3, - "title": "system_health", - "anchor": "system_health" + "title": "Slashing", + "anchor": "slashing" }, { "depth": 3, - "title": "chain_getBlock", - "anchor": "chain_getblock" + "title": "Disabling", + "anchor": "disabling" }, { "depth": 3, - "title": "state_getStorage", - "anchor": "state_getstorage" + "title": "Reputation Changes", + "anchor": "reputation-changes" }, { "depth": 3, - "title": "author_submitExtrinsic", - "anchor": "author_submitextrinsic" + "title": "Penalties by Offense", + "anchor": "penalties-by-offense" + } + ], + "stats": { + "chars": 15427, + "words": 2103, + "headings": 9, + "estimated_token_count_total": 3409 + }, + "hash": "sha256:abe6bedab04f463ec07f554977b8d6355a5d2fad9bcda01cbe58568152295daa", + "token_estimator": "heuristic-v1" + }, + { + "id": "nodes-and-validators-run-a-validator-staking-mechanics-rewards", + "title": "Rewards Payout", + "slug": "nodes-and-validators-run-a-validator-staking-mechanics-rewards", + "categories": [ + "Infrastructure" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-staking-mechanics-rewards.md", + "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/staking-mechanics/rewards/", + "preview": "Understanding how rewards are distributed to validators and nominators is essential for network participants. In Polkadot and Kusama, validators earn rewards based on their era points, which are accrued through actions like block production and parachain validation.", + "outline": [ + { + "depth": 2, + "title": "Introduction", + "anchor": "introduction" }, { - "depth": 3, - "title": "state_getMetadata", - "anchor": "state_getmetadata" + "depth": 2, + "title": "Era Points", + "anchor": "era-points" }, { "depth": 2, - "title": "Check Available RPC Calls", - "anchor": "check-available-rpc-calls" + "title": "Reward Variance", + "anchor": "reward-variance" }, { - "depth": 3, - "title": "Using curl", - "anchor": "using-curl" + "depth": 2, + "title": "Payout Scheme", + "anchor": "payout-scheme" }, { - "depth": 3, - "title": "Using Polkadot.js Apps", - "anchor": "using-polkadotjs-apps" + "depth": 2, + "title": "Running Multiple Validators", + "anchor": "running-multiple-validators" }, { "depth": 2, - "title": "Resources", - "anchor": "resources" + "title": "Nominators and Validator Payments", + "anchor": "nominators-and-validator-payments" } ], "stats": { - "chars": 6496, - "words": 909, - "headings": 13, - "estimated_token_count_total": 1870 + "chars": 10976, + "words": 1753, + "headings": 6, + "estimated_token_count_total": 2588 }, - "hash": "sha256:3b766e00e55a224201bc6744386a6dabc7da54ed9199b16abab3b94cff449eca", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:d5d6d72eb2cf10f624d84c65f2274f7df90acb5d071bf170bc8eae8d98a810a5", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains-spawn-chains-zombienet-get-started", - "title": "Get Started", - "slug": "develop-toolkit-parachains-spawn-chains-zombienet-get-started", + "id": "parachains-customize-runtime-add-existing-pallets", + "title": "Add an Existing Pallet to the Runtime", + "slug": "parachains-customize-runtime-add-existing-pallets", "categories": [ - "Parachains", - "Tooling" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains-zombienet-get-started.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/spawn-chains/zombienet/get-started/", - "preview": "Zombienet is a robust testing framework designed for Polkadot SDK-based blockchain networks. It enables developers to efficiently deploy and test ephemeral blockchain environments on platforms like Kubernetes, Podman, and native setups. With its simple and versatile CLI, Zombienet provides an all-in-one solution for spawning networks, running tests, and validating performance.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-existing-pallets.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/add-existing-pallets/", + "preview": "The [Polkadot SDK Parachain Template](https://github.com/paritytech/polkadot-sdk-parachain-template){target=\\_blank} provides a functional runtime that includes default [FRAME](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html){target=\\_blank} development modules ([pallets](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/pallet/index.html){target=\\_blank}) to help you get started building a custo", "outline": [ { "depth": 2, @@ -5019,63 +4523,63 @@ }, { "depth": 2, - "title": "Install Zombienet", - "anchor": "install-zombienet" + "title": "Check Prerequisites", + "anchor": "check-prerequisites" }, { "depth": 2, - "title": "Providers", - "anchor": "providers" + "title": "Add an Existing Polkadot SDK Pallet to Your Runtime", + "anchor": "add-an-existing-polkadot-sdk-pallet-to-your-runtime" }, { "depth": 3, - "title": "Kubernetes", - "anchor": "kubernetes" + "title": "Add an Existing Pallet as a Dependency", + "anchor": "add-an-existing-pallet-as-a-dependency" }, { "depth": 3, - "title": "Podman", - "anchor": "podman" + "title": "Enable Standard Library Features", + "anchor": "enable-standard-library-features" }, { "depth": 3, - "title": "Local Provider", - "anchor": "local-provider" + "title": "Review the Config Trait", + "anchor": "review-the-config-trait" }, { - "depth": 2, - "title": "Configure Zombienet", - "anchor": "configure-zombienet" + "depth": 3, + "title": "Implement the Config Trait", + "anchor": "implement-the-config-trait" }, { "depth": 3, - "title": "Configuration Files", - "anchor": "configuration-files" + "title": "Add to Runtime Construct", + "anchor": "add-to-runtime-construct" }, { "depth": 3, - "title": "CLI Usage", - "anchor": "cli-usage" + "title": "Verify the Runtime Compiles", + "anchor": "verify-the-runtime-compiles" }, { - "depth": 3, - "title": "Settings", - "anchor": "settings" + "depth": 2, + "title": "Run Your Chain Locally", + "anchor": "run-your-chain-locally" }, { "depth": 3, - "title": "Relay Chain Configuration", - "anchor": "relay-chain-configuration" + "title": "Generate a Chain Specification", + "anchor": "generate-a-chain-specification" }, { "depth": 3, - "title": "Parachain Configuration", - "anchor": "parachain-configuration" + "title": "Start the Parachain Node", + "anchor": "start-the-parachain-node" }, { "depth": 3, - "title": "XCM Configuration", - "anchor": "xcm-configuration" + "title": "Interact with the Pallet", + "anchor": "interact-with-the-pallet" }, { "depth": 2, @@ -5084,27 +4588,24 @@ } ], "stats": { - "chars": 41636, - "words": 4599, + "chars": 11924, + "words": 1585, "headings": 14, - "estimated_token_count_total": 9871 + "estimated_token_count_total": 2724 }, - "hash": "sha256:0d7e04fd952cc9d5bd8cdbfd87cc4004c5f95e896a16bc7f89dfc4caeac8f371", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:93d123cbaaccc2515b4a70be8e1327b4f75b1051d16c5e3daf5a2035af7b7ca3", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains-spawn-chains-zombienet-write-tests", - "title": "Write Tests", - "slug": "develop-toolkit-parachains-spawn-chains-zombienet-write-tests", + "id": "parachains-customize-runtime-add-pallet-instances", + "title": "Add Multiple Pallet Instances", + "slug": "parachains-customize-runtime-add-pallet-instances", "categories": [ - "Parachains", - "Tooling" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains-zombienet-write-tests.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/spawn-chains/zombienet/write-tests/", - "preview": "Testing is a critical step in blockchain development, ensuring reliability, performance, and security. Zombienet simplifies this process with its intuitive Domain Specific Language (DSL), enabling developers to write natural-language test scripts tailored to their network needs.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-pallet-instances.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/add-pallet-instances/", + "preview": "The [Polkadot SDK Parachain Template](https://github.com/paritytech/polkadot-sdk-parachain-template){target=\\_blank} provides a solid foundation for building custom parachains. While most pallets are typically included as single instances within a runtime, some scenarios benefit from running multiple instances of the same pallet with different configurations. This approach lets you reuse pallet logic without reimplementing it, enabling diverse functionality from a single codebase.", "outline": [ { "depth": 2, @@ -5113,217 +4614,277 @@ }, { "depth": 2, - "title": "Testing DSL", - "anchor": "testing-dsl" + "title": "Check Prerequisites", + "anchor": "check-prerequisites" }, { "depth": 2, - "title": "The Test File", - "anchor": "the-test-file" + "title": "Understanding Instantiable Pallets", + "anchor": "understanding-instantiable-pallets" }, { "depth": 3, - "title": "Name", - "anchor": "name" + "title": "Identifying an Instantiable Pallet", + "anchor": "identifying-an-instantiable-pallet" }, { "depth": 3, - "title": "Assertions", - "anchor": "assertions" + "title": "How Instance Generics Work", + "anchor": "how-instance-generics-work" + }, + { + "depth": 2, + "title": "Add Multiple Instances of a Pallet to Your Runtime", + "anchor": "add-multiple-instances-of-a-pallet-to-your-runtime" }, { "depth": 3, - "title": "Commands", - "anchor": "commands" + "title": "Add the Pallet as a Dependency", + "anchor": "add-the-pallet-as-a-dependency" + }, + { + "depth": 3, + "title": "Enable Standard Library Features", + "anchor": "enable-standard-library-features" + }, + { + "depth": 3, + "title": "Review the Config Trait", + "anchor": "review-the-config-trait" + }, + { + "depth": 3, + "title": "Define Pallet Parameters", + "anchor": "define-pallet-parameters" + }, + { + "depth": 3, + "title": "Create Instance Type Definitions", + "anchor": "create-instance-type-definitions" + }, + { + "depth": 3, + "title": "Implement Config Trait for First Instance", + "anchor": "implement-config-trait-for-first-instance" + }, + { + "depth": 3, + "title": "Implement Config Trait for Second Instance", + "anchor": "implement-config-trait-for-second-instance" + }, + { + "depth": 3, + "title": "Add Instances to Runtime Construct", + "anchor": "add-instances-to-runtime-construct" + }, + { + "depth": 3, + "title": "Verify the Runtime Compiles", + "anchor": "verify-the-runtime-compiles" }, { "depth": 2, - "title": "Running a Test", - "anchor": "running-a-test" + "title": "Run Your Chain Locally", + "anchor": "run-your-chain-locally" + }, + { + "depth": 3, + "title": "Generate a Chain Specification", + "anchor": "generate-a-chain-specification" + }, + { + "depth": 3, + "title": "Start the Parachain Node", + "anchor": "start-the-parachain-node" + }, + { + "depth": 3, + "title": "Interact with Both Pallet Instances", + "anchor": "interact-with-both-pallet-instances" + }, + { + "depth": 3, + "title": "Test Instance Independence", + "anchor": "test-instance-independence" }, { "depth": 2, - "title": "Example Test Files", - "anchor": "example-test-files" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 11297, - "words": 1491, - "headings": 8, - "estimated_token_count_total": 2661 + "chars": 17923, + "words": 2203, + "headings": 21, + "estimated_token_count_total": 3811 }, - "hash": "sha256:04e85c4cddb58252f8253d78a3924bb56952dac2a3e9a057704a91a0d1f21d75", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:d83e574726c524fa017236eb5e3b8a0676d598be4da1ce4fe25a60141baeee49", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains-spawn-chains-zombienet", - "title": "Zombienet", - "slug": "develop-toolkit-parachains-spawn-chains-zombienet", + "id": "parachains-customize-runtime-add-smart-contract-functionality", + "title": "Add Smart Contract Functionality", + "slug": "parachains-customize-runtime-add-smart-contract-functionality", "categories": [ - "Uncategorized" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains-zombienet.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/spawn-chains/zombienet/", - "preview": "Zombienet is a testing framework that lets you quickly spin up ephemeral blockchain networks for development and testing. With support for multiple deployment targets, such as Kubernetes, Podman, and native environments, Zombienet makes it easy to validate your blockchain implementation in a controlled environment.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/add-smart-contract-functionality/", + "preview": "When building your custom blockchain with the Polkadot SDK, you can add smart contract capabilities through specialized pallets. These pallets enable users to deploy and execute smart contracts, enhancing your chain's programmability and allowing developers to build decentralized applications on your network.", "outline": [ { "depth": 2, - "title": "What Can I Do with Zombienet?", - "anchor": "what-can-i-do-with-zombienet" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Download LLM Files", - "anchor": "download-llm-files" - } - ], - "stats": { - "chars": 7659, - "words": 777, - "headings": 2, - "estimated_token_count_total": 2073 - }, - "hash": "sha256:9836ab7da420e9ca8196da77dc3ff8198cb3b622548842d0505c0aa043a5f02e", - "last_modified": "2025-10-28T14:42:13+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "get-support-explore-resources", - "title": "Subscribe to Updates", - "slug": "get-support-explore-resources", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-explore-resources.md", - "html_url": "https://docs.polkadot.com/get-support/explore-resources/", - "preview": "Looking for answers beyond the documentation? These platforms are full of useful content and experienced developers sharing insights.", - "outline": [ + "title": "pallet-revive", + "anchor": "pallet-revive" + }, { - "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" - } - ], - "stats": { - "chars": 1237, - "words": 164, - "headings": 3, - "estimated_token_count_total": 193 - }, - "hash": "sha256:4c33d0ec5026128b3bfdb1dfc1f4b29487404eaa8043071d536e8638356c6e1f", - "last_modified": "2025-10-28T14:42:13+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit-parachains-spawn-chains", - "title": "Spawn Networks for Testing", - "slug": "develop-toolkit-parachains-spawn-chains", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/spawn-chains/", - "preview": "Testing blockchain networks in a controlled environment is essential for development and validation. The Polkadot ecosystem provides specialized tools that enable you to spawn test networks, helping you verify functionality and catch issues before deploying to production.", - "outline": [ + "depth": 3, + "title": "Core Components", + "anchor": "core-components" + }, + { + "depth": 3, + "title": "Supported Languages and Compilers", + "anchor": "supported-languages-and-compilers" + }, + { + "depth": 3, + "title": "How It Works", + "anchor": "how-it-works" + }, + { + "depth": 3, + "title": "Key Benefits", + "anchor": "key-benefits" + }, + { + "depth": 3, + "title": "Implementation Examples", + "anchor": "implementation-examples" + }, { "depth": 2, - "title": "Why Spawn a Network?", - "anchor": "why-spawn-a-network" + "title": "Frontier", + "anchor": "frontier" + }, + { + "depth": 3, + "title": "Integration Options", + "anchor": "integration-options" + }, + { + "depth": 3, + "title": "EVM Execution Only", + "anchor": "evm-execution-only" + }, + { + "depth": 3, + "title": "Full Ethereum Compatibility", + "anchor": "full-ethereum-compatibility" + }, + { + "depth": 3, + "title": "Key Benefits", + "anchor": "key-benefits-2" + }, + { + "depth": 3, + "title": "Implementation Examples", + "anchor": "implementation-examples-2" }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "title": "pallet-contracts (Legacy)", + "anchor": "pallet-contracts-legacy" + }, + { + "depth": 3, + "title": "Implementation Example", + "anchor": "implementation-example" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 1180, - "words": 155, - "headings": 3, - "estimated_token_count_total": 171 + "chars": 6655, + "words": 833, + "headings": 16, + "estimated_token_count_total": 1631 }, - "hash": "sha256:993e93b05c8fbdfc2f7510c61ac86bc4c2ff0f03e573695b2f260933c8b62f78", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:6297bb5e0809fdd0585d6170054599f7ab4a3ce7c687ad03ae43092057c493b7", "token_estimator": "heuristic-v1" }, { - "id": "develop-toolkit-parachains", - "title": "Parachains", - "slug": "develop-toolkit-parachains", + "id": "parachains-customize-runtime-pallet-development-add-pallet-to-runtime", + "title": "Add Pallets to the Runtime", + "slug": "parachains-customize-runtime-pallet-development-add-pallet-to-runtime", "categories": [ - "Uncategorized" + "Basics", + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/parachains/", - "preview": "Within the Polkadot ecosystem, you'll find a robust set of development tools that empower developers to build, test, and deploy blockchain applications efficiently. Whether you're designing a custom parachain, testing new features, or validating network configurations, these tools streamline the development process and ensure your blockchain setup is secure and optimized.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-add-pallet-to-runtime.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/", + "preview": "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.", "outline": [ { "depth": 2, - "title": "Quick Links", - "anchor": "quick-links" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 986, - "words": 136, - "headings": 2, - "estimated_token_count_total": 106 - }, - "hash": "sha256:d84a5af1a0237a911d25a68c077f508ebbce608f673ef4f9055e8e434daa96b9", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "develop-toolkit", - "title": "Toolkit", - "slug": "develop-toolkit", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit.md", - "html_url": "https://docs.polkadot.com/develop/toolkit/", - "preview": "Explore Polkadot's core development toolkit, designed to support a variety of developers and use cases within the ecosystem. Whether you're building blockchain infrastructure, developing cross-chain applications, or integrating with external services, this section offers essential tools and resources to help you succeed.", - "outline": [ + "title": "Add the Pallets as Dependencies", + "anchor": "add-the-pallets-as-dependencies" + }, + { + "depth": 3, + "title": "Update the Runtime Configuration", + "anchor": "update-the-runtime-configuration" + }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "title": "Recompile the Runtime", + "anchor": "recompile-the-runtime" + }, + { + "depth": 2, + "title": "Run Your Chain Locally", + "anchor": "run-your-chain-locally" + }, + { + "depth": 2, + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 902, - "words": 113, - "headings": 1, - "estimated_token_count_total": 12 + "chars": 13091, + "words": 1522, + "headings": 6, + "estimated_token_count_total": 3091 }, - "hash": "sha256:abd9f939f68b068a18567b875c9f7e11d102c54fc02ca0e6ee8041c539061ed0", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:87add0ae178e4970601a27efccadb58eff1375d19819201034ba2829914f1cd5", "token_estimator": "heuristic-v1" }, { - "id": "develop", - "title": "Develop", - "slug": "develop", + "id": "parachains-customize-runtime-pallet-development-benchmark-pallet", + "title": "Benchmarking FRAME Pallets", + "slug": "parachains-customize-runtime-pallet-development-benchmark-pallet", "categories": [ - "Uncategorized" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop.md", - "html_url": "https://docs.polkadot.com/develop/", - "preview": "This guide is a starting point for developers who wish to build in the Polkadot ecosystem. To get the most from this section:", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-benchmark-pallet.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/benchmark-pallet/", + "preview": "Benchmarking is a critical component of developing efficient and secure blockchain runtimes. In the Polkadot ecosystem, accurately benchmarking your custom pallets ensures that each extrinsic has a precise [weight](/reference/glossary/#weight){target=\\_blank}, representing its computational and storage demands. This process is vital for maintaining the blockchain's performance and preventing potential vulnerabilities, such as Denial of Service (DoS) attacks.", "outline": [ { "depth": 2, @@ -5332,298 +4893,215 @@ }, { "depth": 2, - "title": "Development Pathways", - "anchor": "development-pathways" + "title": "The Case for Benchmarking", + "anchor": "the-case-for-benchmarking" }, { "depth": 3, - "title": "Parachain Developers", - "anchor": "parachain-developers" + "title": "Benchmarking and Weight", + "anchor": "benchmarking-and-weight" + }, + { + "depth": 2, + "title": "Benchmarking Process", + "anchor": "benchmarking-process" }, { "depth": 3, - "title": "Smart Contract Developers", - "anchor": "smart-contract-developers" + "title": "Prepare Your Environment", + "anchor": "prepare-your-environment" }, { "depth": 3, - "title": "Application Developers", - "anchor": "application-developers" + "title": "Write Benchmark Tests", + "anchor": "write-benchmark-tests" + }, + { + "depth": 3, + "title": "Add Benchmarks to Runtime", + "anchor": "add-benchmarks-to-runtime" + }, + { + "depth": 3, + "title": "Run Benchmarks", + "anchor": "run-benchmarks" }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 6923, - "words": 882, - "headings": 6, - "estimated_token_count_total": 1843 + "chars": 14715, + "words": 1879, + "headings": 9, + "estimated_token_count_total": 3338 }, - "hash": "sha256:0b43b452e9d709cb324bf51fd88c2fed8e6249534a7c2b852e1bd36bcb9b981a", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:915bc91edd56cdedd516e871dbe450d70c9f99fb467cc00ff231ea3a74f61d96", "token_estimator": "heuristic-v1" }, { - "id": "get-support-ai-ready-docs", - "title": "AI Ready Docs", - "slug": "get-support-ai-ready-docs", + "id": "parachains-customize-runtime-pallet-development-create-a-pallet", + "title": "Create a Custom Pallet", + "slug": "parachains-customize-runtime-pallet-development-create-a-pallet", "categories": [ - "Uncategorized" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-ai-ready-docs.md", - "html_url": "https://docs.polkadot.com/get-support/ai-ready-docs/", - "preview": "Polkadot provides files to make documentation content available in a structure optimized for use with large language models (LLMs) and AI tools. These resources help build AI assistants, power code search, or enable custom tooling trained on Polkadot’s documentation.", - "outline": [ - { + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-create-a-pallet.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/create-a-pallet/", + "preview": "[Framework for Runtime Aggregation of Modular Entities (FRAME)](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html){target=\\_blank} provides a powerful set of tools for blockchain development through modular components called [pallets](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/pallet/index.html){target=\\_blank}. These Rust-based runtime modules allow you to build custom blockchain functional", + "outline": [ + { "depth": 2, - "title": "How to Use These Files", - "anchor": "how-to-use-these-files" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Download LLM Files", - "anchor": "download-llm-files" - } - ], - "stats": { - "chars": 7998, - "words": 825, - "headings": 2, - "estimated_token_count_total": 2232 - }, - "hash": "sha256:1090b02689df5f4c59bb83f9c81436718d06e46f3b615bc655fef3c7b6c9fb02", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "get-support-explore-resources", - "title": "Subscribe to Updates", - "slug": "get-support-explore-resources", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-explore-resources.md", - "html_url": "https://docs.polkadot.com/get-support/explore-resources/", - "preview": "Looking for answers beyond the documentation? These platforms are full of useful content and experienced developers sharing insights.", - "outline": [ + "title": "Prerequisites", + "anchor": "prerequisites" + }, { "depth": 2, - "title": "🧠 Stack Exchange", - "anchor": "stack-exchange" + "title": "Core Pallet Components", + "anchor": "core-pallet-components" }, { "depth": 2, - "title": "🧵 Reddit: r/Polkadot", - "anchor": "reddit-rpolkadot" + "title": "Create the Pallet Project", + "anchor": "create-the-pallet-project" }, { "depth": 2, - "title": "💬 Discord (Community Threads Only)", - "anchor": "discord-community-threads-only" + "title": "Configure Dependencies", + "anchor": "configure-dependencies" }, { "depth": 2, - "title": "🎥 YouTube: @PolkadotNetwork", - "anchor": "youtube-polkadotnetwork" + "title": "Initialize the Pallet Structure", + "anchor": "initialize-the-pallet-structure" }, { "depth": 2, - "title": "Verify Installation", - "anchor": "verify-installation" - } - ], - "stats": { - "chars": 11883, - "words": 1662, - "headings": 12, - "estimated_token_count_total": 2559 - }, - "hash": "sha256:0857a9e83aefc6d3f04e8cb320ab82d35211bbd73d2eb2614cf7b97f8e6d36b9", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "infrastructure-running-a-validator-onboarding-and-offboarding-start-validating", - "title": "Start Validating", - "slug": "infrastructure-running-a-validator-onboarding-and-offboarding-start-validating", - "categories": [ - "Infrastructure" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/infrastructure-running-a-validator-onboarding-and-offboarding-start-validating.md", - "html_url": "https://docs.polkadot.com/infrastructure/running-a-validator/onboarding-and-offboarding/start-validating/", - "preview": "After configuring your node keys as shown in the [Key Management](/infrastructure/running-a-validator/onboarding-and-offboarding/key-management){target=\\_blank} section and ensuring your system is set up, you're ready to begin the validator setup process. This guide will walk you through choosing a network, synchronizing your node with the blockchain, bonding your DOT tokens, and starting your validator.", - "outline": [ + "title": "Configure the Pallet", + "anchor": "configure-the-pallet" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Define Events", + "anchor": "define-events" }, { "depth": 2, - "title": "Choose a Network", - "anchor": "choose-a-network" + "title": "Define Errors", + "anchor": "define-errors" }, { "depth": 2, - "title": "Synchronize Chain Data", - "anchor": "synchronize-chain-data" + "title": "Add Storage Items", + "anchor": "add-storage-items" + }, + { + "depth": 2, + "title": "Configure Genesis State", + "anchor": "configure-genesis-state" + }, + { + "depth": 2, + "title": "Implement Dispatchable Functions", + "anchor": "implement-dispatchable-functions" }, { "depth": 3, - "title": "🔷 X (Twitter): Official Accounts", - "anchor": "x-twitter-official-accounts" + "title": "Dispatchable Function Details", + "anchor": "dispatchable-function-details" + }, + { + "depth": 2, + "title": "Verify Pallet Compilation", + "anchor": "verify-pallet-compilation" + }, + { + "depth": 2, + "title": "Add the Pallet to Your Runtime", + "anchor": "add-the-pallet-to-your-runtime" }, { "depth": 3, - "title": "🔁 X (Twitter): Community Accounts", - "anchor": "x-twitter-community-accounts" + "title": "Add Runtime Dependency", + "anchor": "add-runtime-dependency" }, { "depth": 3, - "title": "🗣️ Polkadot Forum", - "anchor": "polkadot-forum" + "title": "Implement the Config Trait", + "anchor": "implement-the-config-trait" }, { "depth": 3, - "title": "🧑‍⚖️ Polkassembly: OpenGov", - "anchor": "polkassembly-opengov" + "title": "Add to Runtime Construct", + "anchor": "add-to-runtime-construct" }, { "depth": 3, - "title": "📸 Instagram", - "anchor": "instagram" - } - ], - "stats": { - "chars": 2456, - "words": 295, - "headings": 10, - "estimated_token_count_total": 579 - }, - "hash": "sha256:e2567b7d5377c87984622cf93afe4bd8cedf46b80597736cf53f26b5f31c5065", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "get-support-get-in-touch", - "title": "Get in Touch", - "slug": "get-support-get-in-touch", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support-get-in-touch.md", - "html_url": "https://docs.polkadot.com/get-support/get-in-touch/", - "preview": "Use one of the channels below to get live technical support or ask questions.", - "outline": [ + "title": "Configure Genesis for Your Runtime", + "anchor": "configure-genesis-for-your-runtime" + }, { - "depth": 2, - "title": "Need Help Fast?", - "anchor": "need-help-fast" + "depth": 3, + "title": "Verify Runtime Compilation", + "anchor": "verify-runtime-compilation" }, { "depth": 2, - "title": "📱 Telegram: Polkadot Developer Support", - "anchor": "telegram-polkadot-developer-support" + "title": "Run Your Chain Locally", + "anchor": "run-your-chain-locally" }, { - "depth": 2, - "title": "🔌 Discord: Polkadot Official Server", - "anchor": "discord-polkadot-official-server" + "depth": 3, + "title": "Generate a Chain Specification", + "anchor": "generate-a-chain-specification" }, { - "depth": 2, - "title": "🧬 Matrix: Polkadot Developer Support", - "anchor": "matrix-polkadot-developer-support" - } - ], - "stats": { - "chars": 1949, - "words": 258, - "headings": 4, - "estimated_token_count_total": 557 - }, - "hash": "sha256:9ab570299106336e5d75923b876247e8eb4a71851a77e84d68e0335e9da5e0a8", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "get-support", - "title": "Support", - "slug": "get-support", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/get-support.md", - "html_url": "https://docs.polkadot.com/get-support/", - "preview": "Use one of the channels below to get live technical support or ask questions.", - "outline": [ + "depth": 3, + "title": "Start the Parachain Node", + "anchor": "start-the-parachain-node" + }, { "depth": 2, - "title": "Need More than Just Documentation?", - "anchor": "need-more-than-just-documentation" + "title": "Interact with Your Pallet", + "anchor": "interact-with-your-pallet" }, { "depth": 2, - "title": "What You Can Do Here", - "anchor": "what-you-can-do-here" + "title": "Key Takeaways", + "anchor": "key-takeaways" }, { "depth": 2, - "title": "Help Us Improve", - "anchor": "help-us-improve" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 1658, - "words": 244, - "headings": 3, - "estimated_token_count_total": 280 - }, - "hash": "sha256:a7b5239c3be0341ced8f28146e240ff6061fded2e71094bd586beeb024684a50", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "index", - "title": "Polkadot Developer Docs", - "slug": "index", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/index.md", - "html_url": "https://docs.polkadot.com/index/", - "preview": "Explore everything you need to start building on top of Polkadot, a protocol that provides parachains with shared security and interoperability using XCM.", - "outline": [], - "stats": { - "chars": 0, - "words": 0, - "headings": 0, - "estimated_token_count_total": 0 + "chars": 26671, + "words": 3041, + "headings": 26, + "estimated_token_count_total": 6113 }, - "hash": "sha256:97655248c65e816fdf3d85dab4ace7ca0c145c50f671c25c24627cfd7660c7a6", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:607e283aaa1295de0af191d97de7f6f87afb722c601a447821fde6a09b97f1af", "token_estimator": "heuristic-v1" }, { - "id": "infrastructure-running-a-validator-operational-tasks-upgrade-your-node", - "title": "Upgrade a Validator Node", - "slug": "infrastructure-running-a-validator-operational-tasks-upgrade-your-node", + "id": "parachains-customize-runtime-pallet-development-mock-runtime", + "title": "Mock Your Runtime", + "slug": "parachains-customize-runtime-pallet-development-mock-runtime", "categories": [ - "Infrastructure" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/infrastructure-running-a-validator-operational-tasks-upgrade-your-node.md", - "html_url": "https://docs.polkadot.com/infrastructure/running-a-validator/operational-tasks/upgrade-your-node/", - "preview": "Upgrading a Polkadot validator node is essential for staying current with network updates and maintaining optimal performance. This guide covers routine and extended maintenance scenarios, including software upgrades and major server changes. Following these steps, you can manage session keys and transition smoothly between servers without risking downtime, slashing, or network disruptions. The process requires strategic planning, especially if you need to perform long-lead maintenance, ensuring", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-mock-runtime.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/mock-runtime/", + "preview": "Testing is a critical part of pallet development. Before integrating your pallet into a full runtime, you need a way to test its functionality in isolation. A mock runtime provides a minimal, simulated blockchain environment where you can verify your pallet's logic without the overhead of running a full node.", "outline": [ { "depth": 2, @@ -5637,99 +5115,79 @@ }, { "depth": 2, - "title": "Session Keys", - "anchor": "session-keys" + "title": "Understand Mock Runtimes", + "anchor": "understand-mock-runtimes" }, { "depth": 2, - "title": "Keystore", - "anchor": "keystore" + "title": "Create the Mock Runtime Module", + "anchor": "create-the-mock-runtime-module" }, { "depth": 2, - "title": "Upgrade Using Backup Validator", - "anchor": "upgrade-using-backup-validator" + "title": "Set Up Basic Mock", + "anchor": "set-up-basic-mock" }, { - "depth": 3, - "title": "Session `N`", - "anchor": "session-n" + "depth": 2, + "title": "Implement Essential Configuration", + "anchor": "implement-essential-configuration" }, - { - "depth": 3, - "title": "Session `N+3`", - "anchor": "session-n3" - } - ], - "stats": { - "chars": 5624, - "words": 842, - "headings": 7, - "estimated_token_count_total": 1167 - }, - "hash": "sha256:b2e8abce15fc9df106a5e972f28c64f606f9dd50ba3a256093eb53bdd5126224", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "infrastructure-running-a-validator-requirements", - "title": "Validator Requirements", - "slug": "infrastructure-running-a-validator-requirements", - "categories": [ - "Infrastructure" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/infrastructure-running-a-validator-requirements.md", - "html_url": "https://docs.polkadot.com/infrastructure/running-a-validator/requirements/", - "preview": "Running a validator in the Polkadot ecosystem is essential for maintaining network security and decentralization. Validators are responsible for validating transactions and adding new blocks to the chain, ensuring the system operates smoothly. In return for their services, validators earn rewards. However, the role comes with inherent risks, such as slashing penalties for misbehavior or technical failures. If you’re new to validation, starting on Kusama provides a lower-stakes environment to gai", - "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Implement Your Pallet's Configuration", + "anchor": "implement-your-pallets-configuration" }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Configure Genesis Storage", + "anchor": "configure-genesis-storage" + }, + { + "depth": 3, + "title": "Basic Test Environment", + "anchor": "basic-test-environment" + }, + { + "depth": 3, + "title": "Custom Genesis Configurations", + "anchor": "custom-genesis-configurations" }, { "depth": 2, - "title": "Minimum Hardware Requirements", - "anchor": "minimum-hardware-requirements" + "title": "Verify Mock Compilation", + "anchor": "verify-mock-compilation" }, { "depth": 2, - "title": "VPS Provider List", - "anchor": "vps-provider-list" + "title": "Key Takeaways", + "anchor": "key-takeaways" }, { "depth": 2, - "title": "Minimum Bond Requirement", - "anchor": "minimum-bond-requirement" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 6838, - "words": 940, - "headings": 5, - "estimated_token_count_total": 1477 + "chars": 11766, + "words": 1369, + "headings": 13, + "estimated_token_count_total": 2514 }, - "hash": "sha256:76500d1d63f4205a84f0bc5b7f9aec945781127d41c32927280ac74bc14f0296", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:dd784a5d2daebb9a885fe09f6a967e6c84958d96ddb38d8366eabe9d860fa539", "token_estimator": "heuristic-v1" }, { - "id": "infrastructure-staking-mechanics-offenses-and-slashes", - "title": "Offenses and Slashes", - "slug": "infrastructure-staking-mechanics-offenses-and-slashes", + "id": "parachains-customize-runtime-pallet-development-pallet-testing", + "title": "Pallet Unit Testing", + "slug": "parachains-customize-runtime-pallet-development-pallet-testing", "categories": [ - "Infrastructure" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/infrastructure-staking-mechanics-offenses-and-slashes.md", - "html_url": "https://docs.polkadot.com/infrastructure/staking-mechanics/offenses-and-slashes/", - "preview": "In Polkadot's Nominated Proof of Stake (NPoS) system, validator misconduct is deterred through a combination of slashing, disabling, and reputation penalties. Validators and nominators who stake tokens face consequences for validator misbehavior, which range from token slashes to restrictions on network participation.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/pallet-testing/", + "preview": "Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation.", "outline": [ { "depth": 2, @@ -5738,119 +5196,125 @@ }, { "depth": 2, - "title": "Offenses", - "anchor": "offenses" + "title": "Prerequisites", + "anchor": "prerequisites" + }, + { + "depth": 2, + "title": "Understanding FRAME Testing Tools", + "anchor": "understanding-frame-testing-tools" }, { "depth": 3, - "title": "Invalid Votes", - "anchor": "invalid-votes" + "title": "Assertion Macros", + "anchor": "assertion-macros" }, { "depth": 3, - "title": "Equivocations", - "anchor": "equivocations" + "title": "System Pallet Test Helpers", + "anchor": "system-pallet-test-helpers" + }, + { + "depth": 3, + "title": "Origin Types", + "anchor": "origin-types" }, { "depth": 2, - "title": "Penalties", - "anchor": "penalties" + "title": "Create the Tests Module", + "anchor": "create-the-tests-module" }, { - "depth": 3, - "title": "Slashing", - "anchor": "slashing" + "depth": 2, + "title": "Set Up the Test Module", + "anchor": "set-up-the-test-module" + }, + { + "depth": 2, + "title": "Write Your First Test", + "anchor": "write-your-first-test" }, { "depth": 3, - "title": "Disabling", - "anchor": "disabling" + "title": "Test Basic Increment", + "anchor": "test-basic-increment" + }, + { + "depth": 2, + "title": "Test Error Conditions", + "anchor": "test-error-conditions" }, { "depth": 3, - "title": "Reputation Changes", - "anchor": "reputation-changes" + "title": "Test Overflow Protection", + "anchor": "test-overflow-protection" }, { "depth": 3, - "title": "Penalties by Offense", - "anchor": "penalties-by-offense" - } - ], - "stats": { - "chars": 15427, - "words": 2103, - "headings": 9, - "estimated_token_count_total": 3409 - }, - "hash": "sha256:abe6bedab04f463ec07f554977b8d6355a5d2fad9bcda01cbe58568152295daa", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "infrastructure-staking-mechanics-rewards-payout", - "title": "Rewards Payout", - "slug": "infrastructure-staking-mechanics-rewards-payout", - "categories": [ - "Infrastructure" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/infrastructure-staking-mechanics-rewards-payout.md", - "html_url": "https://docs.polkadot.com/infrastructure/staking-mechanics/rewards-payout/", - "preview": "Understanding how rewards are distributed to validators and nominators is essential for network participants. In Polkadot and Kusama, validators earn rewards based on their era points, which are accrued through actions like block production and parachain validation.", - "outline": [ + "title": "Test Underflow Protection", + "anchor": "test-underflow-protection" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Test Access Control", + "anchor": "test-access-control" }, { - "depth": 2, - "title": "Era Points", - "anchor": "era-points" + "depth": 3, + "title": "Test Root-Only Access", + "anchor": "test-root-only-access" }, { "depth": 2, - "title": "Reward Variance", - "anchor": "reward-variance" + "title": "Test Event Emission", + "anchor": "test-event-emission" + }, + { + "depth": 3, + "title": "Test Event Data", + "anchor": "test-event-data" }, { "depth": 2, - "title": "Payout Scheme", - "anchor": "payout-scheme" + "title": "Test Genesis Configuration", + "anchor": "test-genesis-configuration" + }, + { + "depth": 3, + "title": "Test Genesis Setup", + "anchor": "test-genesis-setup" }, { "depth": 2, - "title": "Running Multiple Validators", - "anchor": "running-multiple-validators" + "title": "Run All Tests", + "anchor": "run-all-tests" }, { "depth": 2, - "title": "Nominators and Validator Payments", - "anchor": "nominators-and-validator-payments" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 11070, - "words": 1764, - "headings": 6, - "estimated_token_count_total": 2617 + "chars": 24230, + "words": 2405, + "headings": 21, + "estimated_token_count_total": 5344 }, - "hash": "sha256:7d43408276d811c96b7b081a7b9f4d884893282a230b564c9eb3be2fc7857565", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:91981098cfa2fc26c44b817041ce5cda73c50567972407bee491cc17c45b386c", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-node-bootnode", - "title": "Set Up a Bootnode", - "slug": "nodes-and-validators-run-a-node-bootnode", + "id": "parachains-customize-runtime", + "title": "Overview of FRAME", + "slug": "parachains-customize-runtime", "categories": [ - "Infrastructure" + "Basics", + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-node-bootnode.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-node/bootnode/", - "preview": "Bootnodes are essential for helping blockchain nodes discover peers and join the network. When a node starts, it needs to find other nodes, and bootnodes provide an initial point of contact. Once connected, a node can expand its peer connections and play its role in the network, like participating as a validator.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime.md", + "html_url": "https://docs.polkadot.com/parachains/customize-runtime/", + "preview": "A blockchain runtime is more than just a fixed set of rules—it's a dynamic foundation that you can shape to match your specific needs. With Polkadot SDK's [FRAME (Framework for Runtime Aggregation of Modularized Entities)](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\\_blank}, customizing your runtime is straightforward and modular. Instead of building everything from scratch, you combine pre-built pallets with your own custom logic to create a run", "outline": [ { "depth": 2, @@ -5859,467 +5323,359 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Understanding Your Runtime", + "anchor": "understanding-your-runtime" }, { "depth": 2, - "title": "Accessing the Bootnode", - "anchor": "accessing-the-bootnode" + "title": "Runtime Architecture", + "anchor": "runtime-architecture" }, { "depth": 2, - "title": "Node Key", - "anchor": "node-key" + "title": "Building Blocks: Pallets", + "anchor": "building-blocks-pallets" }, { - "depth": 2, - "title": "Running the Bootnode", - "anchor": "running-the-bootnode" + "depth": 3, + "title": "Pre-Built Pallets vs. Custom Pallets", + "anchor": "pre-built-pallets-vs-custom-pallets" }, { - "depth": 2, - "title": "Testing Bootnode Connection", - "anchor": "testing-bootnode-connection" + "depth": 3, + "title": "Pallet Structure", + "anchor": "pallet-structure" }, { - "depth": 3, - "title": "P2P", - "anchor": "p2p" + "depth": 2, + "title": "How Runtime Customization Works", + "anchor": "how-runtime-customization-works" }, { - "depth": 3, - "title": "P2P/WS", - "anchor": "p2pws" + "depth": 2, + "title": "Starting Templates", + "anchor": "starting-templates" }, { - "depth": 3, - "title": "P2P/WSS", - "anchor": "p2pwss" + "depth": 2, + "title": "Key Customization Scenarios", + "anchor": "key-customization-scenarios" } ], "stats": { - "chars": 4538, - "words": 647, + "chars": 8236, + "words": 1101, "headings": 9, - "estimated_token_count_total": 1044 + "estimated_token_count_total": 1828 }, - "hash": "sha256:d84a5af1a0237a911d25a68c077f508ebbce608f673ef4f9055e8e434daa96b9", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:ad58d1c942b567acc4519abc35c0a049ab3e04711c2a49089ceba6324a5aa7ea", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-node-full-node", - "title": "Set Up a Node", - "slug": "nodes-and-validators-run-a-node-full-node", + "id": "parachains-get-started", + "title": "Get Started with Parachain Development", + "slug": "parachains-get-started", "categories": [ - "Infrastructure" + "Basics", + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-node-full-node.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-node/full-node/", - "preview": "Running a node on Polkadot provides direct interaction with the network, enhanced privacy, and full control over RPC requests, transactions, and data queries. As the backbone of the network, nodes ensure decentralized data propagation, transaction validation, and seamless communication across the ecosystem.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-get-started.md", + "html_url": "https://docs.polkadot.com/parachains/get-started/", + "preview": "The following sections provide practical recipes for building parachains on Polkadot—each focused on specific development scenarios with step-by-step, hands-on examples.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Quick Start Guides", + "anchor": "quick-start-guides" }, { "depth": 2, - "title": "Set Up a Node", - "anchor": "set-up-a-node" - }, - { - "depth": 3, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 3, - "title": "Install and Build the Polkadot Binary", - "anchor": "install-and-build-the-polkadot-binary" - }, - { - "depth": 3, - "title": "Use Docker", - "anchor": "use-docker" + "title": "Launch a Simple Parachain", + "anchor": "launch-a-simple-parachain" }, { "depth": 2, - "title": "Configure and Run Your Node", - "anchor": "configure-and-run-your-node" + "title": "Customize Your Runtime", + "anchor": "customize-your-runtime" }, { "depth": 3, - "title": "RPC Configurations", - "anchor": "rpc-configurations" + "title": "Pallet Development", + "anchor": "pallet-development" }, { "depth": 2, - "title": "Sync Your Node", - "anchor": "sync-your-node" + "title": "Testing", + "anchor": "testing" }, - { - "depth": 3, - "title": "Connect to Your Node", - "anchor": "connect-to-your-node" - } - ], - "stats": { - "chars": 15947, - "words": 2482, - "headings": 9, - "estimated_token_count_total": 4197 - }, - "hash": "sha256:b83e3f77bd30ac8c8fb00a193bbec33cd641d94f1a37ac611dea32326c3d77b0", - "last_modified": "2025-10-28T14:42:13+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "nodes-and-validators-run-a-node-secure-wss", - "title": "Set Up Secure WebSocket", - "slug": "nodes-and-validators-run-a-node-secure-wss", - "categories": [ - "Infrastructure" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-node-secure-wss.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-node/secure-wss/", - "preview": "Ensuring secure WebSocket communication is crucial for maintaining the integrity and security of a Polkadot or Kusama node when interacting with remote clients. This guide walks you through setting up a secure WebSocket (WSS) connection for your node by leveraging SSL encryption with popular web server proxies like nginx or Apache.", - "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Runtime Upgrades and Maintenance", + "anchor": "runtime-upgrades-and-maintenance" }, { "depth": 2, - "title": "Secure a WebSocket Port", - "anchor": "secure-a-websocket-port" - }, - { - "depth": 3, - "title": "Obtain an SSL Certificate", - "anchor": "obtain-an-ssl-certificate" + "title": "Interoperability", + "anchor": "interoperability" }, { "depth": 2, - "title": "Install a Proxy Server", - "anchor": "install-a-proxy-server" - }, - { - "depth": 3, - "title": "Use nginx", - "anchor": "use-nginx" - }, - { - "depth": 3, - "title": "Use Apache2", - "anchor": "use-apache2" + "title": "Integrations", + "anchor": "integrations" }, { "depth": 2, - "title": "Connect to the Node", - "anchor": "connect-to-the-node" + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 5568, - "words": 774, - "headings": 7, - "estimated_token_count_total": 1280 + "chars": 7941, + "words": 631, + "headings": 9, + "estimated_token_count_total": 2292 }, - "hash": "sha256:992082e4ad87348b283f6c37ea886ae0e7bf016852b6470000876f3d169c65a4", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:759ed27cf3d473445e33141089b652082c42a2c59eb822d6b506146fd9555e13", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-key-management", - "title": "Validator Key Management", - "slug": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-key-management", + "id": "parachains-install-polkadot-sdk", + "title": "Install Polkadot SDK", + "slug": "parachains-install-polkadot-sdk", "categories": [ - "Infrastructure" + "Basics", + "Tooling" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-onboarding-and-offboarding-key-management.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/onboarding-and-offboarding/key-management/", - "preview": "After setting up your node environment as shown in the [Setup](/nodes-and-validators/run-a-validator/onboarding-and-offboarding/set-up-validator/){target=\\_blank} section, you'll need to configure multiple keys for your validator to operate properly. This includes setting up session keys, which are essential for participating in the consensus process, and configuring a node key that maintains a stable network identity. This guide walks you through the key management process, showing you how to g", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md", + "html_url": "https://docs.polkadot.com/parachains/install-polkadot-sdk/", + "preview": "This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts:", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Install Dependencies: macOS", + "anchor": "install-dependencies-macos" }, { - "depth": 2, - "title": "Set Session Keys", - "anchor": "set-session-keys" + "depth": 3, + "title": "Before You Begin {: #before-you-begin-mac-os }", + "anchor": "before-you-begin-before-you-begin-mac-os" }, { "depth": 3, - "title": "Generate Session Keys", - "anchor": "generate-session-keys" + "title": "Install Homebrew", + "anchor": "install-homebrew" }, { "depth": 3, - "title": "Submit Transaction to Set Keys", - "anchor": "submit-transaction-to-set-keys" + "title": "Support for Apple Silicon", + "anchor": "support-for-apple-silicon" }, { "depth": 3, - "title": "Verify Session Key Setup", - "anchor": "verify-session-key-setup" + "title": "Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os }", + "anchor": "install-required-packages-and-rust-install-required-packages-and-rust-mac-os" }, { "depth": 2, - "title": "Set the Node Key", - "anchor": "set-the-node-key" + "title": "Install Dependencies: Linux", + "anchor": "install-dependencies-linux" }, { "depth": 3, - "title": "Generate the Node Key", - "anchor": "generate-the-node-key" + "title": "Before You Begin {: #before-you-begin-linux }", + "anchor": "before-you-begin-before-you-begin-linux" }, { "depth": 3, - "title": "Set Node Key", - "anchor": "set-node-key" - } - ], - "stats": { - "chars": 8227, - "words": 1183, - "headings": 8, - "estimated_token_count_total": 1840 - }, - "hash": "sha256:0fb5a83835aab263c0b9aa886028c8aa8a2d6d0897d7b9fff4b5258835d30dfe", - "last_modified": "2025-10-28T14:42:13+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-set-up-validator", - "title": "Set Up a Validator", - "slug": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-set-up-validator", - "categories": [ - "Infrastructure" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-onboarding-and-offboarding-set-up-validator.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/onboarding-and-offboarding/set-up-validator/", - "preview": "Setting up a Polkadot validator node is essential for securing the network and earning staking rewards. This guide walks you through the technical steps to set up a validator, from installing the necessary software to managing keys and synchronizing your node with the chain.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Install Required Packages and Rust {: #install-required-packages-and-rust-linux }", + "anchor": "install-required-packages-and-rust-install-required-packages-and-rust-linux" }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Install Dependencies: Windows (WSL)", + "anchor": "install-dependencies-windows-wsl" }, { - "depth": 2, - "title": "Initial Setup", - "anchor": "initial-setup" + "depth": 3, + "title": "Before You Begin {: #before-you-begin-windows-wls }", + "anchor": "before-you-begin-before-you-begin-windows-wls" }, { "depth": 3, - "title": "Install Network Time Protocol Client", - "anchor": "install-network-time-protocol-client" + "title": "Set Up Windows Subsystem for Linux", + "anchor": "set-up-windows-subsystem-for-linux" }, { "depth": 3, - "title": "Verify Landlock is Activated", - "anchor": "verify-landlock-is-activated" + "title": "Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls }", + "anchor": "install-required-packages-and-rust-install-required-packages-and-rust-windows-wls" }, { "depth": 2, - "title": "Install the Polkadot Binaries", - "anchor": "install-the-polkadot-binaries" + "title": "Build the Polkadot SDK", + "anchor": "build-the-polkadot-sdk" }, { "depth": 3, - "title": "Install from Official Releases", - "anchor": "install-from-official-releases" + "title": "Clone the Polkadot SDK", + "anchor": "clone-the-polkadot-sdk" }, { "depth": 3, - "title": "Install with Package Managers", - "anchor": "install-with-package-managers" + "title": "Compile the Polkadot SDK", + "anchor": "compile-the-polkadot-sdk" }, { "depth": 3, - "title": "Install with Ansible", - "anchor": "install-with-ansible" + "title": "Verify the Build", + "anchor": "verify-the-build" + }, + { + "depth": 2, + "title": "Optional: Run the Kitchensink Node", + "anchor": "optional-run-the-kitchensink-node" }, { "depth": 3, - "title": "Install with Docker", - "anchor": "install-with-docker" + "title": "Run the Kitchensink Node in Development Mode", + "anchor": "run-the-kitchensink-node-in-development-mode" }, { "depth": 3, - "title": "Build from Sources", - "anchor": "build-from-sources" + "title": "Interact with the Kitchensink Node", + "anchor": "interact-with-the-kitchensink-node" }, { "depth": 2, - "title": "Verify Installation", - "anchor": "verify-installation" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 11921, - "words": 1678, - "headings": 12, - "estimated_token_count_total": 2592 + "chars": 16051, + "words": 2312, + "headings": 20, + "estimated_token_count_total": 3345 }, - "hash": "sha256:d2c1c91734bc8185057d8eeec6829ea91e0316f7ba884c5dc3922a5e5778815e", - "last_modified": "2025-10-28T14:42:13+00:00", + "hash": "sha256:a52c05b623f3780f14be3a5f36b3d79a6c1965c2fbfd6864b512a9a70c47cd60", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-start-validating", - "title": "Start Validating", - "slug": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-start-validating", + "id": "parachains-integrations-indexers", + "title": "Indexers", + "slug": "parachains-integrations-indexers", "categories": [ - "Infrastructure" + "Tooling", + "Dapps" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-onboarding-and-offboarding-start-validating.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/onboarding-and-offboarding/start-validating/", - "preview": "After configuring your node keys as shown in the [Key Management](/nodes-and-validators/run-a-validator/onboarding-and-offboarding/key-management/){target=\\_blank} section and ensuring your system is set up, you're ready to begin the validator setup process. This guide will walk you through choosing a network, synchronizing your node with the blockchain, bonding your DOT tokens, and starting your validator.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-indexers.md", + "html_url": "https://docs.polkadot.com/parachains/integrations/indexers/", + "preview": "Blockchain data is inherently sequential and distributed, with information stored chronologically across numerous blocks. While retrieving data from a single block through JSON-RPC API calls is straightforward, more complex queries that span multiple blocks present significant challenges:", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Choose a Network", - "anchor": "choose-a-network" - }, - { - "depth": 2, - "title": "Synchronize Chain Data", - "anchor": "synchronize-chain-data" - }, - { - "depth": 3, - "title": "Database Snapshot Services", - "anchor": "database-snapshot-services" + "title": "The Challenge of Blockchain Data Access", + "anchor": "the-challenge-of-blockchain-data-access" }, { "depth": 2, - "title": "Bond DOT", - "anchor": "bond-dot" - }, - { - "depth": 3, - "title": "Bonding DOT on Polkadot.js Apps", - "anchor": "bonding-dot-on-polkadotjs-apps" + "title": "What is a Blockchain Indexer?", + "anchor": "what-is-a-blockchain-indexer" }, { "depth": 2, - "title": "Validate", - "anchor": "validate" - }, - { - "depth": 3, - "title": "Verify Sync via Telemetry", - "anchor": "verify-sync-via-telemetry" - }, - { - "depth": 3, - "title": "Activate using Polkadot.js Apps", - "anchor": "activate-using-polkadotjs-apps" - }, - { - "depth": 3, - "title": "Monitor Validation Status and Slots", - "anchor": "monitor-validation-status-and-slots" - }, - { - "depth": 2, - "title": "Run a Validator Using Systemd", - "anchor": "run-a-validator-using-systemd" - }, - { - "depth": 3, - "title": "Create the Systemd Service File", - "anchor": "create-the-systemd-service-file" - }, - { - "depth": 3, - "title": "Run the Service", - "anchor": "run-the-service" + "title": "Indexer Implementations", + "anchor": "indexer-implementations" } ], "stats": { - "chars": 15821, - "words": 2446, - "headings": 13, - "estimated_token_count_total": 3861 + "chars": 2230, + "words": 302, + "headings": 3, + "estimated_token_count_total": 428 }, - "hash": "sha256:a4235e8d590033d5d54434143e0a5e23603c53ae70d4f0a9ebfe4ca9442baa8d", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:cfcc76bb24779c9b613f2c046b6f99a0f2529c25fd82287d804f6b945b936227", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-stop-validating", - "title": "Stop Validating", - "slug": "nodes-and-validators-run-a-validator-onboarding-and-offboarding-stop-validating", + "id": "parachains-integrations-oracles", + "title": "Oracles", + "slug": "parachains-integrations-oracles", "categories": [ - "Infrastructure" + "Tooling", + "Dapps" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-onboarding-and-offboarding-stop-validating.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/onboarding-and-offboarding/stop-validating/", - "preview": "If you're ready to stop validating on Polkadot, there are essential steps to ensure a smooth transition while protecting your funds and account integrity. Whether you're taking a break for maintenance or unbonding entirely, you'll need to chill your validator, purge session keys, and unbond your tokens. This guide explains how to use Polkadot's tools and extrinsics to safely withdraw from validation activities, safeguarding your account's future usability.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-oracles.md", + "html_url": "https://docs.polkadot.com/parachains/integrations/oracles/", + "preview": "Oracles enable blockchains to access external data sources. Since blockchains operate as isolated networks, they cannot natively interact with external systems - this limitation is known as the \"blockchain oracle problem.\" Oracles solves this by extracting data from external sources (like APIs, IoT devices, or other blockchains), validating it, and submitting it on-chain.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "What is a Blockchain Oracle?", + "anchor": "what-is-a-blockchain-oracle" }, { "depth": 2, - "title": "Pause Versus Stop", - "anchor": "pause-versus-stop" - }, + "title": "Oracle Implementations", + "anchor": "oracle-implementations" + } + ], + "stats": { + "chars": 1343, + "words": 181, + "headings": 2, + "estimated_token_count_total": 245 + }, + "hash": "sha256:6d8e01281a5895fd2bc4438b24c170c72a496de0b838626a53e87685aea4aa25", + "token_estimator": "heuristic-v1" + }, + { + "id": "parachains-integrations-wallets", + "title": "Wallets", + "slug": "parachains-integrations-wallets", + "categories": [ + "Tooling", + "Dapps" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-wallets.md", + "html_url": "https://docs.polkadot.com/parachains/integrations/wallets/", + "preview": "A wallet serves as your gateway to interacting with blockchain networks. Rather than storing funds, wallets secure your private keys, controlling access to your blockchain assets. Your private key provides complete control over all permitted transactions on your blockchain account, making it essential to keep it secure.", + "outline": [ { "depth": 2, - "title": "Chill Validator", - "anchor": "chill-validator" + "title": "What is a Blockchain Wallet?", + "anchor": "what-is-a-blockchain-wallet" }, { "depth": 2, - "title": "Purge Validator Session Keys", - "anchor": "purge-validator-session-keys" + "title": "Hot Wallets", + "anchor": "hot-wallets" }, { "depth": 2, - "title": "Unbond Your Tokens", - "anchor": "unbond-your-tokens" + "title": "Cold Wallets", + "anchor": "cold-wallets" } ], "stats": { - "chars": 3230, - "words": 500, - "headings": 5, - "estimated_token_count_total": 629 + "chars": 2921, + "words": 401, + "headings": 3, + "estimated_token_count_total": 633 }, - "hash": "sha256:0d6db361bfa7a3022849bbe39989bfdac0429537498d7f534adadec131afca98", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:62c5ad101282227f79eac0e30a3ba9ce3ae1bf9e358bd58c0b17ef45db29c2ff", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-validator-operational-tasks-general-management", - "title": "General Management", - "slug": "nodes-and-validators-run-a-validator-operational-tasks-general-management", + "id": "parachains-interoperability-channels-between-parachains", + "title": "Opening HRMP Channels Between Parachains", + "slug": "parachains-interoperability-channels-between-parachains", "categories": [ - "Infrastructure" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-operational-tasks-general-management.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/operational-tasks/general-management/", - "preview": "Validator performance is pivotal in maintaining the security and stability of the Polkadot network. As a validator, optimizing your setup ensures efficient transaction processing, minimizes latency, and maintains system reliability during high-demand periods. Proper configuration and proactive monitoring also help mitigate risks like slashing and service interruptions.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-channels-between-parachains.md", + "html_url": "https://docs.polkadot.com/parachains/interoperability/channels-between-parachains/", + "preview": "For establishing communication channels between parachains on the Polkadot network using the Horizontal Relay-routed Message Passing (HRMP) protocol, the following steps are required:", "outline": [ { "depth": 2, @@ -6328,110 +5684,121 @@ }, { "depth": 2, - "title": "Configuration Optimization", - "anchor": "configuration-optimization" + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 3, - "title": "Deactivate Simultaneous Multithreading", - "anchor": "deactivate-simultaneous-multithreading" + "depth": 2, + "title": "Procedure to Initiate an HRMP Channel", + "anchor": "procedure-to-initiate-an-hrmp-channel" }, { "depth": 3, - "title": "Deactivate Automatic NUMA Balancing", - "anchor": "deactivate-automatic-numa-balancing" + "title": "Fund Sender Sovereign Account", + "anchor": "fund-sender-sovereign-account" }, { "depth": 3, - "title": "Spectre and Meltdown Mitigations", - "anchor": "spectre-and-meltdown-mitigations" - }, - { - "depth": 2, - "title": "Monitor Your Node", - "anchor": "monitor-your-node" + "title": "Create Channel Opening Extrinsic", + "anchor": "create-channel-opening-extrinsic" }, { "depth": 3, - "title": "Environment Setup", - "anchor": "environment-setup" + "title": "Craft and Submit the XCM Message from the Sender", + "anchor": "craft-and-submit-the-xcm-message-from-the-sender" }, { - "depth": 3, - "title": "Install and Configure Prometheus", - "anchor": "install-and-configure-prometheus" + "depth": 2, + "title": "Procedure to Accept an HRMP Channel", + "anchor": "procedure-to-accept-an-hrmp-channel" }, { "depth": 3, - "title": "Start Prometheus", - "anchor": "start-prometheus" + "title": "Fund Receiver Sovereign Account", + "anchor": "fund-receiver-sovereign-account" }, { "depth": 3, - "title": "Install and Configure Grafana", - "anchor": "install-and-configure-grafana" + "title": "Create Channel Accepting Extrinsic", + "anchor": "create-channel-accepting-extrinsic" }, { "depth": 3, - "title": "Install and Configure Alertmanager", - "anchor": "install-and-configure-alertmanager" - }, + "title": "Craft and Submit the XCM Message from the Receiver", + "anchor": "craft-and-submit-the-xcm-message-from-the-receiver" + } + ], + "stats": { + "chars": 10934, + "words": 1549, + "headings": 10, + "estimated_token_count_total": 2285 + }, + "hash": "sha256:b8de1228b9976765accd18ff724038bed6f2449367f500bc3177ab2a053abe63", + "token_estimator": "heuristic-v1" + }, + { + "id": "parachains-interoperability-channels-with-system-parachains", + "title": "Opening HRMP Channels with System Parachains", + "slug": "parachains-interoperability-channels-with-system-parachains", + "categories": [ + "Parachains" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-channels-with-system-parachains.md", + "html_url": "https://docs.polkadot.com/parachains/interoperability/channels-with-system-parachains/", + "preview": "While establishing Horizontal Relay-routed Message Passing (HRMP) channels between regular parachains involves a two-step request and acceptance procedure, opening channels with system parachains follows a more straightforward approach.", + "outline": [ { "depth": 2, - "title": "Secure Your Validator", - "anchor": "secure-your-validator" + "title": "Introduction", + "anchor": "introduction" }, { - "depth": 3, - "title": "Key Management", - "anchor": "key-management" + "depth": 2, + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 3, - "title": "Signing Outside the Client", - "anchor": "signing-outside-the-client" + "depth": 2, + "title": "Procedure to Establish an HRMP Channel", + "anchor": "procedure-to-establish-an-hrmp-channel" }, { "depth": 3, - "title": "Secure-Validator Mode", - "anchor": "secure-validator-mode" + "title": "Fund Parachain Sovereign Account", + "anchor": "fund-parachain-sovereign-account" }, { "depth": 3, - "title": "Linux Best Practices", - "anchor": "linux-best-practices" + "title": "Create Establish Channel with System Extrinsic", + "anchor": "create-establish-channel-with-system-extrinsic" }, { "depth": 3, - "title": "Validator Best Practices", - "anchor": "validator-best-practices" - }, - { - "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Craft and Submit the XCM Message", + "anchor": "craft-and-submit-the-xcm-message" } ], "stats": { - "chars": 26673, - "words": 3357, - "headings": 18, - "estimated_token_count_total": 5866 + "chars": 7203, + "words": 889, + "headings": 6, + "estimated_token_count_total": 1427 }, - "hash": "sha256:81eb0fe77f05155f1ec0511cd066120fc9994961e9d91e21b6666377e65b4586", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:b501d99c464fb049d46676827b6a325a195c90617becc4a7db305441c115350a", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-validator-operational-tasks-pause-validating", - "title": "Pause Validating", - "slug": "nodes-and-validators-run-a-validator-operational-tasks-pause-validating", + "id": "parachains-interoperability-get-started", + "title": "Introduction to XCM", + "slug": "parachains-interoperability-get-started", "categories": [ - "Infrastructure" + "Basics", + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-operational-tasks-pause-validating.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/operational-tasks/pause-validating/", - "preview": "If you need to temporarily stop participating in Polkadot staking activities without fully unbonding your funds, chilling your account allows you to do so efficiently. Chilling removes your node from active validation or nomination in the next era while keeping your funds bonded, making it ideal for planned downtimes or temporary pauses.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-get-started.md", + "html_url": "https://docs.polkadot.com/parachains/interoperability/get-started/", + "preview": "Polkadot’s unique value lies in its ability to enable interoperability between parachains and other blockchain systems. At the core of this capability is XCM (Cross-Consensus Messaging)—a flexible messaging format that facilitates communication and collaboration between independent consensus systems.", "outline": [ { "depth": 2, @@ -6440,50 +5807,54 @@ }, { "depth": 2, - "title": "Chilling Your Node", - "anchor": "chilling-your-node" + "title": "Messaging Format", + "anchor": "messaging-format" }, { "depth": 2, - "title": "Staking Election Timing Considerations", - "anchor": "staking-election-timing-considerations" + "title": "The Four Principles of XCM", + "anchor": "the-four-principles-of-xcm" }, { "depth": 2, - "title": "Chilling as a Nominator", - "anchor": "chilling-as-a-nominator" + "title": "The XCM Tech Stack", + "anchor": "the-xcm-tech-stack" }, { "depth": 2, - "title": "Chilling as a Validator", - "anchor": "chilling-as-a-validator" + "title": "Core Functionalities of XCM", + "anchor": "core-functionalities-of-xcm" }, { "depth": 2, - "title": "Chill Other", - "anchor": "chill-other" + "title": "XCM Example", + "anchor": "xcm-example" + }, + { + "depth": 2, + "title": "Overview", + "anchor": "overview" } ], "stats": { - "chars": 4439, - "words": 679, - "headings": 6, - "estimated_token_count_total": 861 + "chars": 7450, + "words": 974, + "headings": 7, + "estimated_token_count_total": 1501 }, - "hash": "sha256:1af153570ce57bd5b52d08493a300996765686f2a6d04519a2e0aa91191612c1", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:3b26606dd5310c4b8ade5d05270ebf1e06f59afcda4ca2b985e07948215a197e", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-validator-operational-tasks-upgrade-your-node", - "title": "Upgrade a Validator Node", - "slug": "nodes-and-validators-run-a-validator-operational-tasks-upgrade-your-node", + "id": "parachains-launch-a-parachain-deploy-to-polkadot", + "title": "Deploy on Polkadot", + "slug": "parachains-launch-a-parachain-deploy-to-polkadot", "categories": [ - "Infrastructure" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-operational-tasks-upgrade-your-node.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/operational-tasks/upgrade-your-node/", - "preview": "Upgrading a Polkadot validator node is essential for staying current with network updates and maintaining optimal performance. This guide covers routine and extended maintenance scenarios, including software upgrades and major server changes. Following these steps, you can manage session keys and transition smoothly between servers without risking downtime, slashing, or network disruptions. The process requires strategic planning, especially if you need to perform long-lead maintenance, ensuring", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-launch-a-parachain-deploy-to-polkadot.md", + "html_url": "https://docs.polkadot.com/parachains/launch-a-parachain/deploy-to-polkadot/", + "preview": "Previously, you learned how to [choose and set up a parachain template](/parachains/launch-a-parachain/choose-a-template/){target=\\_blank}. Now, you'll take the next step towards a production-like environment by deploying your parachain to the Polkadot TestNet. Deploying to a TestNet is a crucial step for validating your parachain's functionality and preparing it for eventual MainNet deployment.", "outline": [ { "depth": 2, @@ -6492,102 +5863,64 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Session Keys", - "anchor": "session-keys" + "title": "Get Started with an Account and Tokens", + "anchor": "get-started-with-an-account-and-tokens" }, { "depth": 2, - "title": "Keystore", - "anchor": "keystore" + "title": "Reserve a Parachain Identifier", + "anchor": "reserve-a-parachain-identifier" }, { "depth": 2, - "title": "Upgrade Using Backup Validator", - "anchor": "upgrade-using-backup-validator" - }, - { - "depth": 3, - "title": "Session `N`", - "anchor": "session-n" + "title": "Generate Custom Keys for Your Collators", + "anchor": "generate-custom-keys-for-your-collators" }, - { - "depth": 3, - "title": "Session `N+3`", - "anchor": "session-n3" - } - ], - "stats": { - "chars": 5650, - "words": 851, - "headings": 7, - "estimated_token_count_total": 1185 - }, - "hash": "sha256:888230b128d8c648c4f06a18d3b1d1b06dd1bf22a0de4add1f28210ffccb2549", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "nodes-and-validators-run-a-validator-requirements", - "title": "Validator Requirements", - "slug": "nodes-and-validators-run-a-validator-requirements", - "categories": [ - "Infrastructure" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-requirements.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/requirements/", - "preview": "Running a validator in the Polkadot ecosystem is essential for maintaining network security and decentralization. Validators are responsible for validating transactions and adding new blocks to the chain, ensuring the system operates smoothly. In return for their services, validators earn rewards. However, the role comes with inherent risks, such as slashing penalties for misbehavior or technical failures. If you’re new to validation, starting on Kusama provides a lower-stakes environment to gai", - "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Generate the Chain Specification", + "anchor": "generate-the-chain-specification" }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Export Required Files", + "anchor": "export-required-files" }, { "depth": 2, - "title": "Minimum Hardware Requirements", - "anchor": "minimum-hardware-requirements" + "title": "Register a Parathread", + "anchor": "register-a-parathread" }, { "depth": 2, - "title": "VPS Provider List", - "anchor": "vps-provider-list" + "title": "Start the Collator Node", + "anchor": "start-the-collator-node" }, { "depth": 2, - "title": "Minimum Bond Requirement", - "anchor": "minimum-bond-requirement" + "title": "Producing Blocks", + "anchor": "producing-blocks" } ], "stats": { - "chars": 6842, - "words": 944, - "headings": 5, - "estimated_token_count_total": 1485 + "chars": 14404, + "words": 2116, + "headings": 9, + "estimated_token_count_total": 3296 }, - "hash": "sha256:46435b97c37ef6798d2c75c69df31c5e5f07e04b218c370ec5af6b1838d43aac", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:fde940bced4380fc01b1840907059d03f6d47b6cb54bf78c95269ac57adbc99e", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-validator-staking-mechanics-offenses-and-slashes", - "title": "Offenses and Slashes", - "slug": "nodes-and-validators-run-a-validator-staking-mechanics-offenses-and-slashes", + "id": "parachains-launch-a-parachain-obtain-coretime", + "title": "Obtain Coretime", + "slug": "parachains-launch-a-parachain-obtain-coretime", "categories": [ - "Infrastructure" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-staking-mechanics-offenses-and-slashes.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/staking-mechanics/offenses-and-slashes/", - "preview": "In Polkadot's Nominated Proof of Stake (NPoS) system, validator misconduct is deterred through a combination of slashing, disabling, and reputation penalties. Validators and nominators who stake tokens face consequences for validator misbehavior, which range from token slashes to restrictions on network participation.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-launch-a-parachain-obtain-coretime.md", + "html_url": "https://docs.polkadot.com/parachains/launch-a-parachain/obtain-coretime/", + "preview": "After deploying a parachain to Paseo in the [Deploy on Polkadot](/parachains/launch-a-parachain/deploy-to-polkadot/){target=\\_blank} tutorial, the next critical step is obtaining coretime. Coretime is the mechanism through which validation resources are allocated from the relay chain to your parachain. Your parachain can only produce and finalize blocks on the relay chain by obtaining coretime.", "outline": [ { "depth": 2, @@ -6596,65 +5929,80 @@ }, { "depth": 2, - "title": "Offenses", - "anchor": "offenses" + "title": "Prerequisites", + "anchor": "prerequisites" + }, + { + "depth": 2, + "title": "Order On-Demand Coretime", + "anchor": "order-on-demand-coretime" }, { "depth": 3, - "title": "Invalid Votes", - "anchor": "invalid-votes" + "title": "On-Demand Extrinsics", + "anchor": "on-demand-extrinsics" }, { "depth": 3, - "title": "Equivocations", - "anchor": "equivocations" + "title": "Place an On-Demand Order", + "anchor": "place-an-on-demand-order" }, { "depth": 2, - "title": "Penalties", - "anchor": "penalties" + "title": "Purchase Bulk Coretime", + "anchor": "purchase-bulk-coretime" }, { "depth": 3, - "title": "Slashing", - "anchor": "slashing" + "title": "Connect Your Wallet to RegionX", + "anchor": "connect-your-wallet-to-regionx" }, { "depth": 3, - "title": "Disabling", - "anchor": "disabling" + "title": "Obtain Coretime Chain Funds", + "anchor": "obtain-coretime-chain-funds" }, { "depth": 3, - "title": "Reputation Changes", - "anchor": "reputation-changes" + "title": "Purchase a Core", + "anchor": "purchase-a-core" }, { "depth": 3, - "title": "Penalties by Offense", - "anchor": "penalties-by-offense" + "title": "Verify Your Purchase", + "anchor": "verify-your-purchase" + }, + { + "depth": 3, + "title": "Assign Your Parachain to the Core", + "anchor": "assign-your-parachain-to-the-core" + }, + { + "depth": 2, + "title": "Next Steps", + "anchor": "next-steps" } ], "stats": { - "chars": 15427, - "words": 2103, - "headings": 9, - "estimated_token_count_total": 3409 + "chars": 9049, + "words": 1345, + "headings": 12, + "estimated_token_count_total": 2103 }, - "hash": "sha256:abe6bedab04f463ec07f554977b8d6355a5d2fad9bcda01cbe58568152295daa", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:15154f211753665d9af70dc81d15ceb3f0954e3febf9282c68c0074881d620c6", "token_estimator": "heuristic-v1" }, { - "id": "nodes-and-validators-run-a-validator-staking-mechanics-rewards", - "title": "Rewards Payout", - "slug": "nodes-and-validators-run-a-validator-staking-mechanics-rewards", + "id": "parachains-launch-a-parachain-set-up-the-parachain-template", + "title": "Set Up the Polkadot SDK Parachain Template", + "slug": "parachains-launch-a-parachain-set-up-the-parachain-template", "categories": [ - "Infrastructure" + "Basics", + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/nodes-and-validators-run-a-validator-staking-mechanics-rewards.md", - "html_url": "https://docs.polkadot.com/nodes-and-validators/run-a-validator/staking-mechanics/rewards/", - "preview": "Understanding how rewards are distributed to validators and nominators is essential for network participants. In Polkadot and Kusama, validators earn rewards based on their era points, which are accrued through actions like block production and parachain validation.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-launch-a-parachain-set-up-the-parachain-template.md", + "html_url": "https://docs.polkadot.com/parachains/launch-a-parachain/set-up-the-parachain-template/", + "preview": "The [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\\_blank} includes several [templates](/parachains/customize-runtime/#starting-templates){target=\\_blank} designed to help you quickly start building your own blockchain. Each template offers a different level of configuration, from minimal setups to feature-rich environments, allowing you to choose the foundation that best fits your project's needs.", "outline": [ { "depth": 2, @@ -6663,115 +6011,48 @@ }, { "depth": 2, - "title": "Era Points", - "anchor": "era-points" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "Reward Variance", - "anchor": "reward-variance" + "title": "Polkadot SDK Utility Tools", + "anchor": "polkadot-sdk-utility-tools" }, { "depth": 2, - "title": "Payout Scheme", - "anchor": "payout-scheme" + "title": "Clone the Template", + "anchor": "clone-the-template" }, { "depth": 2, - "title": "Running Multiple Validators", - "anchor": "running-multiple-validators" + "title": "Explore the Project Structure", + "anchor": "explore-the-project-structure" }, { "depth": 2, - "title": "Nominators and Validator Payments", - "anchor": "nominators-and-validator-payments" - } - ], - "stats": { - "chars": 10976, - "words": 1753, - "headings": 6, - "estimated_token_count_total": 2588 - }, - "hash": "sha256:d5d6d72eb2cf10f624d84c65f2274f7df90acb5d071bf170bc8eae8d98a810a5", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-customize-runtime-add-existing-pallets", - "title": "Add an Existing Pallet to the Runtime", - "slug": "parachains-customize-runtime-add-existing-pallets", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-existing-pallets.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/add-existing-pallets/", - "preview": "The [Polkadot SDK Parachain Template](https://github.com/paritytech/polkadot-sdk-parachain-template){target=\\_blank} provides a functional runtime that includes default [FRAME](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html){target=\\_blank} development modules ([pallets](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/pallet/index.html){target=\\_blank}) to help you get started building a custo", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Compile the Runtime", + "anchor": "compile-the-runtime" }, { "depth": 2, - "title": "Check Prerequisites", - "anchor": "check-prerequisites" + "title": "Verify the Build", + "anchor": "verify-the-build" }, { "depth": 2, - "title": "Add an Existing Polkadot SDK Pallet to Your Runtime", - "anchor": "add-an-existing-polkadot-sdk-pallet-to-your-runtime" - }, - { - "depth": 3, - "title": "Add an Existing Pallet as a Dependency", - "anchor": "add-an-existing-pallet-as-a-dependency" - }, - { - "depth": 3, - "title": "Enable Standard Library Features", - "anchor": "enable-standard-library-features" - }, - { - "depth": 3, - "title": "Review the Config Trait", - "anchor": "review-the-config-trait" - }, - { - "depth": 3, - "title": "Implement the Config Trait", - "anchor": "implement-the-config-trait" - }, - { - "depth": 3, - "title": "Add to Runtime Construct", - "anchor": "add-to-runtime-construct" - }, - { - "depth": 3, - "title": "Verify the Runtime Compiles", - "anchor": "verify-the-runtime-compiles" + "title": "Run the Node Locally", + "anchor": "run-the-node-locally" }, { "depth": 2, - "title": "Run Your Chain Locally", - "anchor": "run-your-chain-locally" - }, - { - "depth": 3, - "title": "Generate a Chain Specification", - "anchor": "generate-a-chain-specification" - }, - { - "depth": 3, - "title": "Start the Parachain Node", - "anchor": "start-the-parachain-node" + "title": "Interact with the Node", + "anchor": "interact-with-the-node" }, { - "depth": 3, - "title": "Interact with the Pallet", - "anchor": "interact-with-the-pallet" + "depth": 2, + "title": "Stop the Node", + "anchor": "stop-the-node" }, { "depth": 2, @@ -6780,25 +6061,24 @@ } ], "stats": { - "chars": 11924, - "words": 1585, - "headings": 14, - "estimated_token_count_total": 2724 + "chars": 10591, + "words": 1510, + "headings": 11, + "estimated_token_count_total": 2377 }, - "hash": "sha256:93d123cbaaccc2515b4a70be8e1327b4f75b1051d16c5e3daf5a2035af7b7ca3", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:1277261cb3de71cac194f26e765124ea9f3e09cffdcd94bb717965a11cb7f374", "token_estimator": "heuristic-v1" }, { - "id": "parachains-customize-runtime-add-pallet-instances", - "title": "Add Multiple Pallet Instances", - "slug": "parachains-customize-runtime-add-pallet-instances", + "id": "parachains-runtime-maintenance-runtime-upgrades", + "title": "Runtime Upgrades", + "slug": "parachains-runtime-maintenance-runtime-upgrades", "categories": [ "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-pallet-instances.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/add-pallet-instances/", - "preview": "The [Polkadot SDK Parachain Template](https://github.com/paritytech/polkadot-sdk-parachain-template){target=\\_blank} provides a solid foundation for building custom parachains. While most pallets are typically included as single instances within a runtime, some scenarios benefit from running multiple instances of the same pallet with different configurations. This approach lets you reuse pallet logic without reimplementing it, enabling diverse functionality from a single codebase.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-runtime-maintenance-runtime-upgrades.md", + "html_url": "https://docs.polkadot.com/parachains/runtime-maintenance/runtime-upgrades/", + "preview": "One of the defining features of Polkadot SDK-based blockchains is the ability to perform forkless runtime upgrades. Unlike traditional blockchains, which require hard forks and node coordination for upgrades, Polkadot networks enable seamless updates without network disruption.", "outline": [ { "depth": 2, @@ -6807,125 +6087,115 @@ }, { "depth": 2, - "title": "Check Prerequisites", - "anchor": "check-prerequisites" - }, - { - "depth": 2, - "title": "Understanding Instantiable Pallets", - "anchor": "understanding-instantiable-pallets" + "title": "How Runtime Upgrades Work", + "anchor": "how-runtime-upgrades-work" }, { "depth": 3, - "title": "Identifying an Instantiable Pallet", - "anchor": "identifying-an-instantiable-pallet" + "title": "Runtime Versioning", + "anchor": "runtime-versioning" }, { "depth": 3, - "title": "How Instance Generics Work", - "anchor": "how-instance-generics-work" + "title": "Accessing the Runtime Version", + "anchor": "accessing-the-runtime-version" }, { "depth": 2, - "title": "Add Multiple Instances of a Pallet to Your Runtime", - "anchor": "add-multiple-instances-of-a-pallet-to-your-runtime" - }, - { - "depth": 3, - "title": "Add the Pallet as a Dependency", - "anchor": "add-the-pallet-as-a-dependency" - }, + "title": "Storage Migrations", + "anchor": "storage-migrations" + } + ], + "stats": { + "chars": 5837, + "words": 811, + "headings": 5, + "estimated_token_count_total": 1161 + }, + "hash": "sha256:ec31270001a6cd9d0a8ecb7974ad161d5c1ef4d3023d5a6af9fbc5a6ca46cbca", + "token_estimator": "heuristic-v1" + }, + { + "id": "parachains-runtime-maintenance-storage-migrations", + "title": "Storage Migrations", + "slug": "parachains-runtime-maintenance-storage-migrations", + "categories": [ + "Parachains" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-runtime-maintenance-storage-migrations.md", + "html_url": "https://docs.polkadot.com/parachains/runtime-maintenance/storage-migrations/", + "preview": "Storage migrations are a crucial part of the runtime upgrade process. They allow you to update the [storage items](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.storage.html){target=\\_blank} of your blockchain, adapting to changes in the runtime. Whenever you change the encoding or data types used to represent data in storage, you'll need to provide a storage migration to ensure the runtime can correctly interpret the existing stored values in the new runtime", + "outline": [ { - "depth": 3, - "title": "Enable Standard Library Features", - "anchor": "enable-standard-library-features" + "depth": 2, + "title": "Introduction", + "anchor": "introduction" }, { - "depth": 3, - "title": "Review the Config Trait", - "anchor": "review-the-config-trait" + "depth": 2, + "title": "Storage Migration Scenarios", + "anchor": "storage-migration-scenarios" }, { - "depth": 3, - "title": "Define Pallet Parameters", - "anchor": "define-pallet-parameters" + "depth": 2, + "title": "Implement Storage Migrations", + "anchor": "implement-storage-migrations" }, { "depth": 3, - "title": "Create Instance Type Definitions", - "anchor": "create-instance-type-definitions" + "title": "Core Migration Function", + "anchor": "core-migration-function" }, { "depth": 3, - "title": "Implement Config Trait for First Instance", - "anchor": "implement-config-trait-for-first-instance" + "title": "Migration Testing Hooks", + "anchor": "migration-testing-hooks" }, { "depth": 3, - "title": "Implement Config Trait for Second Instance", - "anchor": "implement-config-trait-for-second-instance" + "title": "Migration Structure", + "anchor": "migration-structure" }, { "depth": 3, - "title": "Add Instances to Runtime Construct", - "anchor": "add-instances-to-runtime-construct" + "title": "Migration Organization", + "anchor": "migration-organization" }, { "depth": 3, - "title": "Verify the Runtime Compiles", - "anchor": "verify-the-runtime-compiles" + "title": "Scheduling Migrations", + "anchor": "scheduling-migrations" }, { "depth": 2, - "title": "Run Your Chain Locally", - "anchor": "run-your-chain-locally" - }, - { - "depth": 3, - "title": "Generate a Chain Specification", - "anchor": "generate-a-chain-specification" - }, - { - "depth": 3, - "title": "Start the Parachain Node", - "anchor": "start-the-parachain-node" - }, - { - "depth": 3, - "title": "Interact with Both Pallet Instances", - "anchor": "interact-with-both-pallet-instances" - }, - { - "depth": 3, - "title": "Test Instance Independence", - "anchor": "test-instance-independence" + "title": "Single-Block Migrations", + "anchor": "single-block-migrations" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Multi Block Migrations", + "anchor": "multi-block-migrations" } ], "stats": { - "chars": 17923, - "words": 2203, - "headings": 21, - "estimated_token_count_total": 3811 + "chars": 18500, + "words": 2363, + "headings": 10, + "estimated_token_count_total": 4014 }, - "hash": "sha256:d83e574726c524fa017236eb5e3b8a0676d598be4da1ce4fe25a60141baeee49", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:55dc252fdecf1590048ce8d009b822e90231442abe81e9593cf1635944a31336", "token_estimator": "heuristic-v1" }, { - "id": "parachains-customize-runtime-add-smart-contract-functionality", - "title": "Add Smart Contract Functionality", - "slug": "parachains-customize-runtime-add-smart-contract-functionality", + "id": "parachains-runtime-maintenance-unlock-parachains", + "title": "Unlock a Parachain", + "slug": "parachains-runtime-maintenance-unlock-parachains", "categories": [ "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/add-smart-contract-functionality/", - "preview": "When building your custom blockchain with the Polkadot SDK, you have the flexibility to add smart contract capabilities through specialized pallets. These pallets allow blockchain users to deploy and execute smart contracts, enhancing your chain's functionality and programmability.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-runtime-maintenance-unlock-parachains.md", + "html_url": "https://docs.polkadot.com/parachains/runtime-maintenance/unlock-parachains/", + "preview": "Parachain locks are a critical security mechanism in the Polkadot ecosystem designed to maintain decentralization during the parachain lifecycle. These locks prevent potential centralization risks that could emerge during the early stages of parachain operation.", "outline": [ { "depth": 2, @@ -6934,41 +6204,50 @@ }, { "depth": 2, - "title": "EVM Smart Contracts", - "anchor": "evm-smart-contracts" + "title": "Check If the Parachain Is Locked", + "anchor": "check-if-the-parachain-is-locked" }, { "depth": 2, - "title": "Wasm Smart Contracts", - "anchor": "wasm-smart-contracts" + "title": "How to Unlock a Parachain", + "anchor": "how-to-unlock-a-parachain" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "depth": 3, + "title": "Prepare the Unlock Call", + "anchor": "prepare-the-unlock-call" + }, + { + "depth": 3, + "title": "Fund the Sovereign Account", + "anchor": "fund-the-sovereign-account" + }, + { + "depth": 3, + "title": "Craft and Submit the XCM", + "anchor": "craft-and-submit-the-xcm" } ], "stats": { - "chars": 3865, - "words": 521, - "headings": 4, - "estimated_token_count_total": 901 + "chars": 9232, + "words": 1276, + "headings": 6, + "estimated_token_count_total": 2028 }, - "hash": "sha256:f56a32d5323c371f084833b4e647f21e1d76ad242d8c4e4826bcaed467acc7cf", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:e408d05199cc184fc6fe8bb212efb3c9aa6cb79258977e07566692176c912def", "token_estimator": "heuristic-v1" }, { - "id": "parachains-customize-runtime-pallet-development-add-pallet-to-runtime", - "title": "Add Pallets to the Runtime", - "slug": "parachains-customize-runtime-pallet-development-add-pallet-to-runtime", + "id": "parachains-testing-fork-a-parachain", + "title": "Get Started", + "slug": "parachains-testing-fork-a-parachain", "categories": [ - "Basics", - "Parachains" + "Parachains", + "Tooling" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-add-pallet-to-runtime.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/add-pallet-to-runtime/", - "preview": "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.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-testing-fork-a-parachain.md", + "html_url": "https://docs.polkadot.com/parachains/testing/fork-a-parachain/", + "preview": "[Chopsticks](https://github.com/AcalaNetwork/chopsticks/){target=\\_blank}, developed by the [Acala Foundation](https://github.com/AcalaNetwork){target=\\_blank}, is a versatile tool tailored for developers working on Polkadot SDK-based blockchains. With Chopsticks, you can fork live chains locally, replay blocks to analyze extrinsics, and simulate complex scenarios like XCM interactions all without deploying to a live network.", "outline": [ { "depth": 2, @@ -6977,90 +6256,43 @@ }, { "depth": 2, - "title": "Add the Pallets as Dependencies", - "anchor": "add-the-pallets-as-dependencies" + "title": "Prerequisites", + "anchor": "prerequisites" }, - { - "depth": 3, - "title": "Update the Runtime Configuration", - "anchor": "update-the-runtime-configuration" - }, - { - "depth": 2, - "title": "Recompile the Runtime", - "anchor": "recompile-the-runtime" - }, - { - "depth": 2, - "title": "Run Your Chain Locally", - "anchor": "run-your-chain-locally" - }, - { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 13091, - "words": 1522, - "headings": 6, - "estimated_token_count_total": 3091 - }, - "hash": "sha256:87add0ae178e4970601a27efccadb58eff1375d19819201034ba2829914f1cd5", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-customize-runtime-pallet-development-benchmark-pallet", - "title": "Benchmarking FRAME Pallets", - "slug": "parachains-customize-runtime-pallet-development-benchmark-pallet", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-benchmark-pallet.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/benchmark-pallet/", - "preview": "Benchmarking is a critical component of developing efficient and secure blockchain runtimes. In the Polkadot ecosystem, accurately benchmarking your custom pallets ensures that each extrinsic has a precise [weight](/reference/glossary/#weight){target=\\_blank}, representing its computational and storage demands. This process is vital for maintaining the blockchain's performance and preventing potential vulnerabilities, such as Denial of Service (DoS) attacks.", - "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Install Chopsticks", + "anchor": "install-chopsticks" }, { - "depth": 2, - "title": "The Case for Benchmarking", - "anchor": "the-case-for-benchmarking" + "depth": 3, + "title": "Global Installation", + "anchor": "global-installation" }, { "depth": 3, - "title": "Benchmarking and Weight", - "anchor": "benchmarking-and-weight" + "title": "Local Installation", + "anchor": "local-installation" }, { "depth": 2, - "title": "Benchmarking Process", - "anchor": "benchmarking-process" - }, - { - "depth": 3, - "title": "Prepare Your Environment", - "anchor": "prepare-your-environment" + "title": "Configure Chopsticks", + "anchor": "configure-chopsticks" }, { "depth": 3, - "title": "Write Benchmark Tests", - "anchor": "write-benchmark-tests" + "title": "Configuration File", + "anchor": "configuration-file" }, { "depth": 3, - "title": "Add Benchmarks to Runtime", - "anchor": "add-benchmarks-to-runtime" + "title": "CLI Flags", + "anchor": "cli-flags" }, { - "depth": 3, - "title": "Run Benchmarks", - "anchor": "run-benchmarks" + "depth": 2, + "title": "WebSocket Commands", + "anchor": "websocket-commands" }, { "depth": 2, @@ -7069,25 +6301,25 @@ } ], "stats": { - "chars": 14715, - "words": 1879, - "headings": 9, - "estimated_token_count_total": 3338 + "chars": 10894, + "words": 1330, + "headings": 10, + "estimated_token_count_total": 2614 }, - "hash": "sha256:915bc91edd56cdedd516e871dbe450d70c9f99fb467cc00ff231ea3a74f61d96", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:4325cdd697814b8043db808da3dee86d3d9c6fc7dd523aae7fe8914d59d1b39c", "token_estimator": "heuristic-v1" }, { - "id": "parachains-customize-runtime-pallet-development-create-a-pallet", - "title": "Create a Custom Pallet", - "slug": "parachains-customize-runtime-pallet-development-create-a-pallet", + "id": "parachains-testing-run-a-parachain-network", + "title": "Get Started", + "slug": "parachains-testing-run-a-parachain-network", "categories": [ - "Parachains" + "Parachains", + "Tooling" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-create-a-pallet.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/create-a-pallet/", - "preview": "[Framework for Runtime Aggregation of Modular Entities (FRAME)](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html){target=\\_blank} provides a powerful set of tools for blockchain development through modular components called [pallets](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/pallet/index.html){target=\\_blank}. These Rust-based runtime modules allow you to build custom blockchain functional", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-testing-run-a-parachain-network.md", + "html_url": "https://docs.polkadot.com/parachains/testing/run-a-parachain-network/", + "preview": "Zombienet is a robust testing framework designed for Polkadot SDK-based blockchain networks. It enables developers to efficiently deploy and test ephemeral blockchain environments on platforms like Kubernetes, Podman, and native setups. With its simple and versatile CLI, Zombienet provides an all-in-one solution for spawning networks, running tests, and validating performance.", "outline": [ { "depth": 2, @@ -7096,123 +6328,63 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Core Pallet Components", - "anchor": "core-pallet-components" - }, - { - "depth": 2, - "title": "Create the Pallet Project", - "anchor": "create-the-pallet-project" - }, - { - "depth": 2, - "title": "Configure Dependencies", - "anchor": "configure-dependencies" - }, - { - "depth": 2, - "title": "Initialize the Pallet Structure", - "anchor": "initialize-the-pallet-structure" - }, - { - "depth": 2, - "title": "Configure the Pallet", - "anchor": "configure-the-pallet" - }, - { - "depth": 2, - "title": "Define Events", - "anchor": "define-events" - }, - { - "depth": 2, - "title": "Define Errors", - "anchor": "define-errors" - }, - { - "depth": 2, - "title": "Add Storage Items", - "anchor": "add-storage-items" + "title": "Install Zombienet", + "anchor": "install-zombienet" }, { "depth": 2, - "title": "Configure Genesis State", - "anchor": "configure-genesis-state" + "title": "Providers", + "anchor": "providers" }, { - "depth": 2, - "title": "Implement Dispatchable Functions", - "anchor": "implement-dispatchable-functions" + "depth": 3, + "title": "Kubernetes", + "anchor": "kubernetes" }, { "depth": 3, - "title": "Dispatchable Function Details", - "anchor": "dispatchable-function-details" + "title": "Podman", + "anchor": "podman" }, { - "depth": 2, - "title": "Verify Pallet Compilation", - "anchor": "verify-pallet-compilation" + "depth": 3, + "title": "Local Provider", + "anchor": "local-provider" }, { "depth": 2, - "title": "Add the Pallet to Your Runtime", - "anchor": "add-the-pallet-to-your-runtime" - }, - { - "depth": 3, - "title": "Add Runtime Dependency", - "anchor": "add-runtime-dependency" + "title": "Configure Zombienet", + "anchor": "configure-zombienet" }, { "depth": 3, - "title": "Implement the Config Trait", - "anchor": "implement-the-config-trait" + "title": "Configuration Files", + "anchor": "configuration-files" }, { "depth": 3, - "title": "Add to Runtime Construct", - "anchor": "add-to-runtime-construct" + "title": "CLI Usage", + "anchor": "cli-usage" }, { "depth": 3, - "title": "Configure Genesis for Your Runtime", - "anchor": "configure-genesis-for-your-runtime" + "title": "Settings", + "anchor": "settings" }, { "depth": 3, - "title": "Verify Runtime Compilation", - "anchor": "verify-runtime-compilation" - }, - { - "depth": 2, - "title": "Run Your Chain Locally", - "anchor": "run-your-chain-locally" + "title": "Relay Chain Configuration", + "anchor": "relay-chain-configuration" }, { "depth": 3, - "title": "Generate a Chain Specification", - "anchor": "generate-a-chain-specification" + "title": "Parachain Configuration", + "anchor": "parachain-configuration" }, { "depth": 3, - "title": "Start the Parachain Node", - "anchor": "start-the-parachain-node" - }, - { - "depth": 2, - "title": "Interact with Your Pallet", - "anchor": "interact-with-your-pallet" - }, - { - "depth": 2, - "title": "Key Takeaways", - "anchor": "key-takeaways" + "title": "XCM Configuration", + "anchor": "xcm-configuration" }, { "depth": 2, @@ -7221,24 +6393,25 @@ } ], "stats": { - "chars": 26671, - "words": 3041, - "headings": 26, - "estimated_token_count_total": 6113 + "chars": 41636, + "words": 4599, + "headings": 14, + "estimated_token_count_total": 9871 }, - "hash": "sha256:607e283aaa1295de0af191d97de7f6f87afb722c601a447821fde6a09b97f1af", + "hash": "sha256:0d7e04fd952cc9d5bd8cdbfd87cc4004c5f95e896a16bc7f89dfc4caeac8f371", "token_estimator": "heuristic-v1" }, { - "id": "parachains-customize-runtime-pallet-development-mock-runtime", - "title": "Mock Your Runtime", - "slug": "parachains-customize-runtime-pallet-development-mock-runtime", + "id": "polkadot-protocol-architecture-parachains-consensus", + "title": "Parachain Consensus", + "slug": "polkadot-protocol-architecture-parachains-consensus", "categories": [ + "Polkadot Protocol", "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-mock-runtime.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/mock-runtime/", - "preview": "Testing is a critical part of pallet development. Before integrating your pallet into a full runtime, you need a way to test its functionality in isolation. A mock runtime provides a minimal, simulated blockchain environment where you can verify your pallet's logic without the overhead of running a full node.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-parachains-consensus.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/parachains/consensus/", + "preview": "Parachains are independent blockchains built with the Polkadot SDK, designed to leverage Polkadot’s relay chain for shared security and transaction finality. These specialized chains operate as part of Polkadot’s execution sharding model, where each parachain manages its own state and transactions while relying on the relay chain for validation and consensus.", "outline": [ { "depth": 2, @@ -7247,58 +6420,18 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Understand Mock Runtimes", - "anchor": "understand-mock-runtimes" + "title": "The Role of Collators", + "anchor": "the-role-of-collators" }, { "depth": 2, - "title": "Create the Mock Runtime Module", - "anchor": "create-the-mock-runtime-module" + "title": "Consensus and Validation", + "anchor": "consensus-and-validation" }, { - "depth": 2, - "title": "Set Up Basic Mock", - "anchor": "set-up-basic-mock" - }, - { - "depth": 2, - "title": "Implement Essential Configuration", - "anchor": "implement-essential-configuration" - }, - { - "depth": 2, - "title": "Implement Your Pallet's Configuration", - "anchor": "implement-your-pallets-configuration" - }, - { - "depth": 2, - "title": "Configure Genesis Storage", - "anchor": "configure-genesis-storage" - }, - { - "depth": 3, - "title": "Basic Test Environment", - "anchor": "basic-test-environment" - }, - { - "depth": 3, - "title": "Custom Genesis Configurations", - "anchor": "custom-genesis-configurations" - }, - { - "depth": 2, - "title": "Verify Mock Compilation", - "anchor": "verify-mock-compilation" - }, - { - "depth": 2, - "title": "Key Takeaways", - "anchor": "key-takeaways" + "depth": 3, + "title": "Path of a Parachain Block", + "anchor": "path-of-a-parachain-block" }, { "depth": 2, @@ -7307,24 +6440,26 @@ } ], "stats": { - "chars": 11766, - "words": 1369, - "headings": 13, - "estimated_token_count_total": 2514 + "chars": 6150, + "words": 790, + "headings": 5, + "estimated_token_count_total": 1125 }, - "hash": "sha256:dd784a5d2daebb9a885fe09f6a967e6c84958d96ddb38d8366eabe9d860fa539", + "hash": "sha256:9875239c6071033a37a0f67fabca5a6e840c4a287620309f47b4f29c5a95a1cb", "token_estimator": "heuristic-v1" }, { - "id": "parachains-customize-runtime-pallet-development-pallet-testing", - "title": "Pallet Unit Testing", - "slug": "parachains-customize-runtime-pallet-development-pallet-testing", + "id": "polkadot-protocol-architecture-parachains-overview", + "title": "Overview", + "slug": "polkadot-protocol-architecture-parachains-overview", "categories": [ + "Basics", + "Polkadot Protocol", "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/pallet-testing/", - "preview": "Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-parachains-overview.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/parachains/overview/", + "preview": "A [_parachain_](/polkadot-protocol/glossary#parachain){target=\\_blank} is a coherent, application-specific blockchain that derives security from its respective relay chain. Parachains on Polkadot are each their own separate, fully functioning blockchain. The primary difference between a parachain and a regular, \"solo\" blockchain is that the relay chain verifies the state of all parachains that are connected to it. In many ways, parachains can be thought of as a [\"cynical\" rollup](#cryptoeconomic", "outline": [ { "depth": 2, @@ -7333,98 +6468,126 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" - }, - { - "depth": 2, - "title": "Understanding FRAME Testing Tools", - "anchor": "understanding-frame-testing-tools" - }, - { - "depth": 3, - "title": "Assertion Macros", - "anchor": "assertion-macros" - }, - { - "depth": 3, - "title": "System Pallet Test Helpers", - "anchor": "system-pallet-test-helpers" - }, - { - "depth": 3, - "title": "Origin Types", - "anchor": "origin-types" + "title": "Coherent Systems", + "anchor": "coherent-systems" }, { "depth": 2, - "title": "Create the Tests Module", - "anchor": "create-the-tests-module" + "title": "Flexible Ecosystem", + "anchor": "flexible-ecosystem" }, { "depth": 2, - "title": "Set Up the Test Module", - "anchor": "set-up-the-test-module" + "title": "State Transition Functions (Runtimes)", + "anchor": "state-transition-functions-runtimes" }, { "depth": 2, - "title": "Write Your First Test", - "anchor": "write-your-first-test" + "title": "Shared Security: Validated by the Relay Chain", + "anchor": "shared-security-validated-by-the-relay-chain" }, { "depth": 3, - "title": "Test Basic Increment", - "anchor": "test-basic-increment" + "title": "Cryptoeconomic Security: ELVES Protocol", + "anchor": "cryptoeconomic-security-elves-protocol" }, { "depth": 2, - "title": "Test Error Conditions", - "anchor": "test-error-conditions" - }, - { - "depth": 3, - "title": "Test Overflow Protection", - "anchor": "test-overflow-protection" - }, - { - "depth": 3, - "title": "Test Underflow Protection", - "anchor": "test-underflow-protection" + "title": "Interoperability", + "anchor": "interoperability" }, { "depth": 2, - "title": "Test Access Control", - "anchor": "test-access-control" - }, - { - "depth": 3, - "title": "Test Root-Only Access", - "anchor": "test-root-only-access" - }, + "title": "Where to Go Next", + "anchor": "where-to-go-next" + } + ], + "stats": { + "chars": 9561, + "words": 1321, + "headings": 8, + "estimated_token_count_total": 1861 + }, + "hash": "sha256:932c12e1af939698279ede2eacb2190e1f56119582adf2064d6cf86f7a4f3e3c", + "token_estimator": "heuristic-v1" + }, + { + "id": "polkadot-protocol-architecture-parachains", + "title": "Parachains", + "slug": "polkadot-protocol-architecture-parachains", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-parachains.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/parachains/", + "preview": "Discover how parachains secure their networks and reach consensus by harnessing Polkadot’s relay chain and its robust validator framework. This integrated architecture ensures shared security and seamless coordination across the entire ecosystem.", + "outline": [ { "depth": 2, - "title": "Test Event Emission", - "anchor": "test-event-emission" - }, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 725, + "words": 93, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:3b9160b166d9b42b124f3b07eb26bdc5499fbbace6f951095009a5eee7fccbb6", + "token_estimator": "heuristic-v1" + }, + { + "id": "polkadot-protocol-architecture-polkadot-chain", + "title": "The Polkadot Relay Chain", + "slug": "polkadot-protocol-architecture-polkadot-chain", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-polkadot-chain.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/", + "preview": "Discover the central role of the Polkadot relay chain in securing the network and fostering interoperability. As the backbone of Polkadot, the relay chain provides shared security and ensures consensus across the ecosystem. It empowers parachains with flexible coretime allocation, enabling them to purchase blockspace on demand, ensuring efficiency and scalability for diverse blockchain applications.", + "outline": [ { - "depth": 3, - "title": "Test Event Data", - "anchor": "test-event-data" - }, + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 481, + "words": 63, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:c29356358f095b0d413e4c6525146b3f1b0b900853aada2168e7e55cd8dd6641", + "token_estimator": "heuristic-v1" + }, + { + "id": "polkadot-protocol-architecture-system-chains-coretime", + "title": "Coretime Chain", + "slug": "polkadot-protocol-architecture-system-chains-coretime", + "categories": [ + "Polkadot Protocol" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains-coretime.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/coretime/", + "preview": "The Coretime system chain facilitates the allocation, procurement, sale, and scheduling of bulk [coretime](/reference/glossary/#coretime){target=\\_blank}, enabling tasks (such as [parachains](/reference/glossary/#parachain){target=\\_blank}) to utilize the computation and security provided by Polkadot.", + "outline": [ { "depth": 2, - "title": "Test Genesis Configuration", - "anchor": "test-genesis-configuration" + "title": "Introduction", + "anchor": "introduction" }, { - "depth": 3, - "title": "Test Genesis Setup", - "anchor": "test-genesis-setup" + "depth": 2, + "title": "Bulk Coretime Assignment", + "anchor": "bulk-coretime-assignment" }, { "depth": 2, - "title": "Run All Tests", - "anchor": "run-all-tests" + "title": "On Demand Coretime", + "anchor": "on-demand-coretime" }, { "depth": 2, @@ -7433,26 +6596,25 @@ } ], "stats": { - "chars": 20165, - "words": 2088, - "headings": 21, - "estimated_token_count_total": 4495 + "chars": 5279, + "words": 772, + "headings": 4, + "estimated_token_count_total": 1230 }, -<<<<<<< HEAD - "hash": "sha256:d61a71c863db6badccac283198b01add19703bb69706666c7a43c4ce18c98601", + "hash": "sha256:8d186fa56ccbbf4b6c85cffc5521b9a99a20e9517f3b4a435730745803cbf2e8", "token_estimator": "heuristic-v1" }, { - "id": "parachains-customize-runtime", - "title": "Overview of FRAME", - "slug": "parachains-customize-runtime", + "id": "polkadot-protocol-architecture-system-chains-overview", + "title": "Overview of Polkadot's System Chains", + "slug": "polkadot-protocol-architecture-system-chains-overview", "categories": [ "Basics", - "Parachains" + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime.md", - "html_url": "https://docs.polkadot.com/parachains/customize-runtime/", - "preview": "A blockchain runtime is more than just a fixed set of rules—it's a dynamic foundation that you can shape to match your specific needs. With Polkadot SDK's [FRAME (Framework for Runtime Aggregation of Modularized Entities)](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\\_blank}, customizing your runtime is straightforward and modular. Instead of building everything from scratch, you combine pre-built pallets with your own custom logic to create a run", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains-overview.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/overview/", + "preview": "Polkadot's relay chain is designed to secure parachains and facilitate seamless inter-chain communication. However, resource-intensive—tasks like governance, asset management, and bridging are more efficiently handled by system parachains. These specialized chains offload functionality from the relay chain, leveraging Polkadot's parallel execution model to improve performance and scalability. By distributing key functionalities across system parachains, Polkadot can maximize its relay chain's bl", "outline": [ { "depth": 2, @@ -7461,328 +6623,317 @@ }, { "depth": 2, - "title": "Understanding Your Runtime", - "anchor": "understanding-your-runtime" + "title": "System Chains", + "anchor": "system-chains" }, { "depth": 2, - "title": "Runtime Architecture", - "anchor": "runtime-architecture" + "title": "Existing System Chains", + "anchor": "existing-system-chains" }, { - "depth": 2, - "title": "Building Blocks: Pallets", - "anchor": "building-blocks-pallets" + "depth": 3, + "title": "Asset Hub", + "anchor": "asset-hub" }, { "depth": 3, - "title": "Pre-Built Pallets vs. Custom Pallets", - "anchor": "pre-built-pallets-vs-custom-pallets" + "title": "Collectives", + "anchor": "collectives" }, { "depth": 3, - "title": "Pallet Structure", - "anchor": "pallet-structure" + "title": "Bridge Hub", + "anchor": "bridge-hub" }, { - "depth": 2, - "title": "How Runtime Customization Works", - "anchor": "how-runtime-customization-works" + "depth": 3, + "title": "People Chain", + "anchor": "people-chain" }, { - "depth": 2, - "title": "Starting Templates", - "anchor": "starting-templates" + "depth": 3, + "title": "Coretime Chain", + "anchor": "coretime-chain" }, { - "depth": 2, - "title": "Key Customization Scenarios", - "anchor": "key-customization-scenarios" + "depth": 3, + "title": "Encointer", + "anchor": "encointer" } ], "stats": { - "chars": 8236, - "words": 1101, + "chars": 7727, + "words": 1105, "headings": 9, - "estimated_token_count_total": 1828 + "estimated_token_count_total": 1643 }, - "hash": "sha256:ad58d1c942b567acc4519abc35c0a049ab3e04711c2a49089ceba6324a5aa7ea", -======= - "hash": "sha256:8568dfa238b9a649a4e6e60510625c2e7879b76a93187b0b8b8dccf6bc467ae6", - "last_modified": "2025-10-28T14:42:14+00:00", ->>>>>>> staging/product-ia + "hash": "sha256:100377787627052a29bd1173270b5ad307639b828c331e71c85d4c00bc5692d8", "token_estimator": "heuristic-v1" }, { - "id": "parachains-get-started", - "title": "Get Started with Parachain Development", - "slug": "parachains-get-started", + "id": "polkadot-protocol-architecture-system-chains", + "title": "System Chains", + "slug": "polkadot-protocol-architecture-system-chains", "categories": [ - "Basics", - "Parachains" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-get-started.md", - "html_url": "https://docs.polkadot.com/parachains/get-started/", - "preview": "The following sections provide practical recipes for building parachains on Polkadot—each focused on specific development scenarios with step-by-step, hands-on examples.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/", + "preview": "Explore the critical roles Polkadot’s system chains play in enhancing the network’s efficiency and scalability. From managing on-chain assets with the Asset Hub to enabling seamless Web3 integration through the Bridge Hub and facilitating coretime operations with the Coretime chain, each system chain is designed to offload specialized tasks from the relay chain, optimizing the entire ecosystem.", "outline": [ { "depth": 2, - "title": "Quick Start Guides", - "anchor": "quick-start-guides" - }, - { - "depth": 2, - "title": "Launch a Simple Parachain", - "anchor": "launch-a-simple-parachain" - }, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 929, + "words": 124, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:6ef13c197dd1865fcc1a405d67486f1d053534d576bb32fe47a442fd2c11b6cd", + "token_estimator": "heuristic-v1" + }, + { + "id": "polkadot-protocol-architecture", + "title": "Architecture", + "slug": "polkadot-protocol-architecture", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/", + "preview": "Explore Polkadot's architecture, including the relay chain, parachains, and system chains, and discover the role each component plays in the broader ecosystem.", + "outline": [ { "depth": 2, - "title": "Customize Your Runtime", - "anchor": "customize-your-runtime" - }, - { - "depth": 3, - "title": "Pallet Development", - "anchor": "pallet-development" + "title": "A Brief Look at Polkadot’s Chain Ecosystem", + "anchor": "a-brief-look-at-polkadots-chain-ecosystem" }, { "depth": 2, - "title": "Testing", - "anchor": "testing" - }, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 990, + "words": 132, + "headings": 2, + "estimated_token_count_total": 177 + }, + "hash": "sha256:ffda04c93c70ec7204be28b642fa6e51f6bf9436d4792ecd25136696683f0902", + "token_estimator": "heuristic-v1" + }, + { + "id": "polkadot-protocol-onchain-governance", + "title": "On-Chain Governance", + "slug": "polkadot-protocol-onchain-governance", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-onchain-governance.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/onchain-governance/", + "preview": "Polkadot's on-chain governance system, OpenGov, enables decentralized decision-making across the network. It empowers stakeholders to propose, vote on, and enact changes with transparency and efficiency. This system ensures that governance is both flexible and inclusive, allowing developers to integrate custom governance solutions and mechanisms within the network. Understanding how OpenGov functions is crucial for anyone looking to engage with Polkadot’s decentralized ecosystem, whether you’re", + "outline": [ { "depth": 2, - "title": "Runtime Upgrades and Maintenance", - "anchor": "runtime-upgrades-and-maintenance" + "title": "Start Building Governance Solutions", + "anchor": "start-building-governance-solutions" }, { "depth": 2, - "title": "Interoperability", - "anchor": "interoperability" - }, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 2114, + "words": 285, + "headings": 2, + "estimated_token_count_total": 233 + }, + "hash": "sha256:58fd5c8c092ee748c2979164f985a67071a6ccb88492e79cdad536363364c858", + "token_estimator": "heuristic-v1" + }, + { + "id": "polkadot-protocol-parachain-basics-blocks-transactions-fees", + "title": "Blocks, Transactions, and Fees", + "slug": "polkadot-protocol-parachain-basics-blocks-transactions-fees", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-blocks-transactions-fees.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/blocks-transactions-fees/", + "preview": "Discover the inner workings of Polkadot’s blocks and transactions, including their structure, processing, and lifecycle within the network. Learn how blocks are authored, validated, and finalized, ensuring seamless operation and consensus across the ecosystem. Dive into the various types of transactions—signed, unsigned, and inherent—and understand how they are constructed, submitted, and validated.", + "outline": [ { "depth": 2, - "title": "Integrations", - "anchor": "integrations" - }, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 788, + "words": 105, + "headings": 1, + "estimated_token_count_total": 12 + }, + "hash": "sha256:235f33cdb64494815dbb3eb58ea98c69935098684e1b34b6d15356bc54b082ea", + "token_estimator": "heuristic-v1" + }, + { + "id": "polkadot-protocol-parachain-basics", + "title": "Parachain Basics", + "slug": "polkadot-protocol-parachain-basics", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/", + "preview": "This section equips developers with the essential knowledge to create, deploy, and enhance applications and blockchains within the Polkadot ecosystem. Gain a comprehensive understanding of Polkadot’s foundational components, including accounts, balances, and transactions, as well as advanced topics like data encoding and cryptographic methods. Mastering these concepts is vital for building robust and secure applications on Polkadot.", + "outline": [ { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "In This Section", + "anchor": "in-this-section" } ], "stats": { - "chars": 7941, - "words": 631, - "headings": 9, - "estimated_token_count_total": 2292 + "chars": 998, + "words": 130, + "headings": 1, + "estimated_token_count_total": 12 }, - "hash": "sha256:759ed27cf3d473445e33141089b652082c42a2c59eb822d6b506146fd9555e13", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:1514316acba1e9bba82ae1c82b09481e9d03d286e6f5d93b66e5a85fd4be7bca", "token_estimator": "heuristic-v1" }, { - "id": "parachains-install-polkadot-sdk", - "title": "Install Polkadot SDK", - "slug": "parachains-install-polkadot-sdk", + "id": "polkadot-protocol-smart-contract-basics-evm-vs-polkavm", + "title": "EVM vs PolkaVM", + "slug": "polkadot-protocol-smart-contract-basics-evm-vs-polkavm", "categories": [ "Basics", - "Tooling" + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md", - "html_url": "https://docs.polkadot.com/parachains/install-polkadot-sdk/", - "preview": "This guide provides step-by-step instructions for installing the Polkadot SDK on macOS, Linux, and Windows. The installation process consists of two main parts:", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics-evm-vs-polkavm.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/evm-vs-polkavm/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", "outline": [ { "depth": 2, - "title": "Part 1: Install Dependencies", - "anchor": "part-1-install-dependencies" + "title": "Introduction", + "anchor": "introduction" + }, + { + "depth": 2, + "title": "Core Virtual Machine Architecture", + "anchor": "core-virtual-machine-architecture" }, { "depth": 3, - "title": "macOS", - "anchor": "macos" + "title": "High-Level Architecture Comparison", + "anchor": "high-level-architecture-comparison" + }, + { + "depth": 2, + "title": "Gas Model", + "anchor": "gas-model" }, { "depth": 3, - "title": "Linux", - "anchor": "linux" + "title": "Dynamic Gas Value Scaling", + "anchor": "dynamic-gas-value-scaling" }, { "depth": 3, - "title": "Windows (WSL)", - "anchor": "windows-wsl" + "title": "Multi-Dimensional Resource Metering", + "anchor": "multi-dimensional-resource-metering" }, { "depth": 2, - "title": "Part 2: Build the Polkadot SDK", - "anchor": "part-2-build-the-polkadot-sdk" + "title": "Memory Management", + "anchor": "memory-management" }, { "depth": 3, - "title": "Clone the Polkadot SDK", - "anchor": "clone-the-polkadot-sdk" + "title": "Current Memory Limits", + "anchor": "current-memory-limits" }, { - "depth": 3, - "title": "Compile the Polkadot SDK", - "anchor": "compile-the-polkadot-sdk" + "depth": 2, + "title": "Account Management - Existential Deposit", + "anchor": "account-management-existential-deposit" }, { "depth": 3, - "title": "Verify the Build", - "anchor": "verify-the-build" + "title": "Account Management Comparison", + "anchor": "account-management-comparison" }, { "depth": 2, - "title": "Optional: Run the Kitchensink Node", - "anchor": "optional-run-the-kitchensink-node" + "title": "Contract Deployment", + "anchor": "contract-deployment" + }, + { + "depth": 2, + "title": "Solidity and YUL IR Translation Incompatibilities", + "anchor": "solidity-and-yul-ir-translation-incompatibilities" }, { "depth": 3, - "title": "Run the Kitchensink Node in Development Mode", - "anchor": "run-the-kitchensink-node-in-development-mode" + "title": "Contract Code Structure", + "anchor": "contract-code-structure" }, { "depth": 3, - "title": "Interact with the Kitchensink Node", - "anchor": "interact-with-the-kitchensink-node" + "title": "Solidity-Specific Differences", + "anchor": "solidity-specific-differences" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 15587, - "words": 2258, - "headings": 12, - "estimated_token_count_total": 3216 - }, - "hash": "sha256:2ee5656f749b4bca445172f2bc66c7fc39af40ff173626662ae4c399f49cf909", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-integrations-indexers", - "title": "Indexers", - "slug": "parachains-integrations-indexers", - "categories": [ - "Tooling", - "Dapps" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-indexers.md", - "html_url": "https://docs.polkadot.com/parachains/integrations/indexers/", - "preview": "Blockchain data is inherently sequential and distributed, with information stored chronologically across numerous blocks. While retrieving data from a single block through JSON-RPC API calls is straightforward, more complex queries that span multiple blocks present significant challenges:", - "outline": [ - { - "depth": 2, - "title": "The Challenge of Blockchain Data Access", - "anchor": "the-challenge-of-blockchain-data-access" - }, - { - "depth": 2, - "title": "What is a Blockchain Indexer?", - "anchor": "what-is-a-blockchain-indexer" - }, - { - "depth": 2, - "title": "Indexer Implementations", - "anchor": "indexer-implementations" - } - ], - "stats": { - "chars": 2230, - "words": 302, - "headings": 3, - "estimated_token_count_total": 428 - }, - "hash": "sha256:cfcc76bb24779c9b613f2c046b6f99a0f2529c25fd82287d804f6b945b936227", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-integrations-oracles", - "title": "Oracles", - "slug": "parachains-integrations-oracles", - "categories": [ - "Tooling", - "Dapps" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-oracles.md", - "html_url": "https://docs.polkadot.com/parachains/integrations/oracles/", - "preview": "Oracles enable blockchains to access external data sources. Since blockchains operate as isolated networks, they cannot natively interact with external systems - this limitation is known as the \"blockchain oracle problem.\" Oracles solves this by extracting data from external sources (like APIs, IoT devices, or other blockchains), validating it, and submitting it on-chain.", - "outline": [ - { - "depth": 2, - "title": "What is a Blockchain Oracle?", - "anchor": "what-is-a-blockchain-oracle" + "depth": 3, + "title": "YUL Function Translation Differences", + "anchor": "yul-function-translation-differences" }, { - "depth": 2, - "title": "Oracle Implementations", - "anchor": "oracle-implementations" - } - ], - "stats": { - "chars": 1343, - "words": 181, - "headings": 2, - "estimated_token_count_total": 245 - }, - "hash": "sha256:6d8e01281a5895fd2bc4438b24c170c72a496de0b838626a53e87685aea4aa25", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-integrations-wallets", - "title": "Wallets", - "slug": "parachains-integrations-wallets", - "categories": [ - "Tooling", - "Dapps" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-wallets.md", - "html_url": "https://docs.polkadot.com/parachains/integrations/wallets/", - "preview": "A wallet serves as your gateway to interacting with blockchain networks. Rather than storing funds, wallets secure your private keys, controlling access to your blockchain assets. Your private key provides complete control over all permitted transactions on your blockchain account, making it essential to keep it secure.", - "outline": [ - { - "depth": 2, - "title": "What is a Blockchain Wallet?", - "anchor": "what-is-a-blockchain-wallet" + "depth": 3, + "title": "Unsupported Operations", + "anchor": "unsupported-operations" }, { - "depth": 2, - "title": "Hot Wallets", - "anchor": "hot-wallets" + "depth": 3, + "title": "Compilation Pipeline Considerations", + "anchor": "compilation-pipeline-considerations" }, { - "depth": 2, - "title": "Cold Wallets", - "anchor": "cold-wallets" + "depth": 3, + "title": "Memory Pointer Limitations", + "anchor": "memory-pointer-limitations" } ], "stats": { - "chars": 2921, - "words": 401, - "headings": 3, - "estimated_token_count_total": 633 + "chars": 27673, + "words": 3392, + "headings": 18, + "estimated_token_count_total": 5305 }, - "hash": "sha256:62c5ad101282227f79eac0e30a3ba9ce3ae1bf9e358bd58c0b17ef45db29c2ff", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:fe651be49fe0a9ae899b2cbf9c663325f407718dc63f1d2c6a2dc4931be751fa", "token_estimator": "heuristic-v1" }, { - "id": "parachains-interoperability-channels-between-parachains", - "title": "Opening HRMP Channels Between Parachains", - "slug": "parachains-interoperability-channels-between-parachains", + "id": "polkadot-protocol-smart-contract-basics-networks", + "title": "Networks for Polkadot Hub Smart Contracts", + "slug": "polkadot-protocol-smart-contract-basics-networks", "categories": [ - "Parachains" + "Basics", + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-channels-between-parachains.md", - "html_url": "https://docs.polkadot.com/parachains/interoperability/channels-between-parachains/", - "preview": "For establishing communication channels between parachains on the Polkadot network using the Horizontal Relay-routed Message Passing (HRMP) protocol, the following steps are required:", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics-networks.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/networks/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", "outline": [ { "depth": 2, @@ -7791,70 +6942,65 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Network Overview", + "anchor": "network-overview" }, { "depth": 2, - "title": "Procedure to Initiate an HRMP Channel", - "anchor": "procedure-to-initiate-an-hrmp-channel" + "title": "Local Development", + "anchor": "local-development" }, { - "depth": 3, - "title": "Fund Sender Sovereign Account", - "anchor": "fund-sender-sovereign-account" + "depth": 2, + "title": "Test Networks", + "anchor": "test-networks" }, { "depth": 3, - "title": "Create Channel Opening Extrinsic", - "anchor": "create-channel-opening-extrinsic" + "title": "Passet Hub", + "anchor": "passet-hub" }, { "depth": 3, - "title": "Craft and Submit the XCM Message from the Sender", - "anchor": "craft-and-submit-the-xcm-message-from-the-sender" + "title": "Westend Hub", + "anchor": "westend-hub" }, { "depth": 2, - "title": "Procedure to Accept an HRMP Channel", - "anchor": "procedure-to-accept-an-hrmp-channel" - }, - { - "depth": 3, - "title": "Fund Receiver Sovereign Account", - "anchor": "fund-receiver-sovereign-account" + "title": "Production Networks", + "anchor": "production-networks" }, { "depth": 3, - "title": "Create Channel Accepting Extrinsic", - "anchor": "create-channel-accepting-extrinsic" + "title": "Polkadot Hub", + "anchor": "polkadot-hub" }, { "depth": 3, - "title": "Craft and Submit the XCM Message from the Receiver", - "anchor": "craft-and-submit-the-xcm-message-from-the-receiver" + "title": "Kusama Hub", + "anchor": "kusama-hub" } ], "stats": { - "chars": 10934, - "words": 1549, - "headings": 10, - "estimated_token_count_total": 2285 + "chars": 5108, + "words": 696, + "headings": 9, + "estimated_token_count_total": 891 }, - "hash": "sha256:b8de1228b9976765accd18ff724038bed6f2449367f500bc3177ab2a053abe63", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:b5acdc9acf0e44836b8a4518155eba7d16cc3b103c557a00970ffb1c44c3e9f6", "token_estimator": "heuristic-v1" }, { - "id": "parachains-interoperability-channels-with-system-parachains", - "title": "Opening HRMP Channels with System Parachains", - "slug": "parachains-interoperability-channels-with-system-parachains", + "id": "polkadot-protocol-smart-contract-basics-overview", + "title": "Smart Contracts Basics Overview", + "slug": "polkadot-protocol-smart-contract-basics-overview", "categories": [ - "Parachains" + "Basics", + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-channels-with-system-parachains.md", - "html_url": "https://docs.polkadot.com/parachains/interoperability/channels-with-system-parachains/", - "preview": "While establishing Horizontal Relay-routed Message Passing (HRMP) channels between regular parachains involves a two-step request and acceptance procedure, opening channels with system parachains follows a more straightforward approach.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics-overview.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/overview/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", "outline": [ { "depth": 2, @@ -7863,581 +7009,442 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Smart Contracts Versus Parachains", + "anchor": "smart-contracts-versus-parachains" }, { "depth": 2, - "title": "Procedure to Establish an HRMP Channel", - "anchor": "procedure-to-establish-an-hrmp-channel" + "title": "Building a Smart Contract", + "anchor": "building-a-smart-contract" }, { "depth": 3, - "title": "Fund Parachain Sovereign Account", - "anchor": "fund-parachain-sovereign-account" + "title": "PolkaVM Contracts", + "anchor": "polkavm-contracts" }, { "depth": 3, - "title": "Create Establish Channel with System Extrinsic", - "anchor": "create-establish-channel-with-system-extrinsic" + "title": "EVM Contracts", + "anchor": "evm-contracts" }, { "depth": 3, - "title": "Craft and Submit the XCM Message", - "anchor": "craft-and-submit-the-xcm-message" + "title": "Wasm Contracts", + "anchor": "wasm-contracts" } ], "stats": { - "chars": 7203, - "words": 889, + "chars": 10854, + "words": 1559, "headings": 6, - "estimated_token_count_total": 1427 + "estimated_token_count_total": 2550 }, - "hash": "sha256:b501d99c464fb049d46676827b6a325a195c90617becc4a7db305441c115350a", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:5d293525ce81d27e32c26938a029a6a82b137221a0630d084f528853ffaf798e", "token_estimator": "heuristic-v1" }, { - "id": "parachains-interoperability-get-started", - "title": "Introduction to XCM", - "slug": "parachains-interoperability-get-started", + "id": "polkadot-protocol-smart-contract-basics", + "title": "Smart Contract Basics", + "slug": "polkadot-protocol-smart-contract-basics", "categories": [ - "Basics", - "Polkadot Protocol" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-get-started.md", - "html_url": "https://docs.polkadot.com/parachains/interoperability/get-started/", - "preview": "Polkadot’s unique value lies in its ability to enable interoperability between parachains and other blockchain systems. At the core of this capability is XCM (Cross-Consensus Messaging)—a flexible messaging format that facilitates communication and collaboration between independent consensus systems.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Gain a deep understanding of smart contracts on Polkadot, from execution environments to transaction mechanics.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Messaging Format", - "anchor": "messaging-format" - }, - { - "depth": 2, - "title": "The Four Principles of XCM", - "anchor": "the-four-principles-of-xcm" - }, - { - "depth": 2, - "title": "The XCM Tech Stack", - "anchor": "the-xcm-tech-stack" - }, - { - "depth": 2, - "title": "Core Functionalities of XCM", - "anchor": "core-functionalities-of-xcm" - }, - { - "depth": 2, - "title": "XCM Example", - "anchor": "xcm-example" + "title": "Key Topics", + "anchor": "key-topics" }, { "depth": 2, - "title": "Overview", - "anchor": "overview" + "title": "In This Section", + "anchor": "in-this-section" } ], "stats": { - "chars": 7450, - "words": 974, - "headings": 7, - "estimated_token_count_total": 1501 + "chars": 1110, + "words": 136, + "headings": 2, + "estimated_token_count_total": 148 }, - "hash": "sha256:3b26606dd5310c4b8ade5d05270ebf1e06f59afcda4ca2b985e07948215a197e", - "last_modified": "2025-10-28T14:42:14+00:00", + "hash": "sha256:e8dac01e89b7aac4b887e962e91084c253f5ea25c1abc3a56355390d0c3201c8", "token_estimator": "heuristic-v1" }, { - "id": "parachains-launch-a-parachain-choose-a-template", - "title": "parachains-launch-a-parachain-choose-a-template", - "slug": "parachains-launch-a-parachain-choose-a-template", + "id": "polkadot-protocol", + "title": "Learn About the Polkadot Protocol", + "slug": "polkadot-protocol", "categories": [ "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-launch-a-parachain-choose-a-template.md", - "html_url": "https://docs.polkadot.com/parachains/launch-a-parachain/choose-a-template/", - "preview": "TODO", - "outline": [], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol.md", + "html_url": "https://docs.polkadot.com/polkadot-protocol/", + "preview": "The Polkadot protocol is designed to enable scalable, secure, and interoperable networks. It introduces a unique multichain architecture that allows independent blockchains, known as parachains, to operate seamlessly while benefiting from the shared security of the relay chain. Polkadot’s decentralized governance ensures that network upgrades and decisions are community-driven, while its cross-chain messaging and interoperability features make it a hub for multichain applications.", + "outline": [ + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], "stats": { - "chars": 5, - "words": 1, - "headings": 0, - "estimated_token_count_total": 0 + "chars": 1170, + "words": 150, + "headings": 1, + "estimated_token_count_total": 12 }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:15:59+00:00", + "hash": "sha256:49be4b4b5289572086eaaaf9ccff3bee7879b534188331c9a8052b3fe5aa4933", "token_estimator": "heuristic-v1" }, { - "id": "parachains-launch-a-parachain-deploy-to-polkadot", - "title": "Deploy on Polkadot", - "slug": "parachains-launch-a-parachain-deploy-to-polkadot", + "id": "reference-glossary", + "title": "Glossary", + "slug": "reference-glossary", "categories": [ - "Parachains" + "Reference" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-launch-a-parachain-deploy-to-polkadot.md", - "html_url": "https://docs.polkadot.com/parachains/launch-a-parachain/deploy-to-polkadot/", - "preview": "Previously, you learned how to [choose and set up a parachain template](/parachains/launch-a-parachain/choose-a-template/){target=\\_blank}. Now, you'll take the next step towards a production-like environment by deploying your parachain to the Polkadot TestNet. Deploying to a TestNet is a crucial step for validating your parachain's functionality and preparing it for eventual MainNet deployment.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-glossary.md", + "html_url": "https://docs.polkadot.com/reference/glossary/", + "preview": "Key definitions, concepts, and terminology specific to the Polkadot ecosystem are included here.", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Authority", + "anchor": "authority" }, { "depth": 2, - "title": "Get Started with an Account and Tokens", - "anchor": "get-started-with-an-account-and-tokens" + "title": "Authority Round (Aura)", + "anchor": "authority-round-aura" }, { "depth": 2, - "title": "Reserve a Parachain Identifier", - "anchor": "reserve-a-parachain-identifier" + "title": "Blind Assignment of Blockchain Extension (BABE)", + "anchor": "blind-assignment-of-blockchain-extension-babe" }, { "depth": 2, - "title": "Generate Custom Keys for Your Collators", - "anchor": "generate-custom-keys-for-your-collators" + "title": "Block Author", + "anchor": "block-author" }, { "depth": 2, - "title": "Generate the Chain Specification", - "anchor": "generate-the-chain-specification" + "title": "Byzantine Fault Tolerance (BFT)", + "anchor": "byzantine-fault-tolerance-bft" + }, + { + "depth": 3, + "title": "Byzantine Failure", + "anchor": "byzantine-failure" + }, + { + "depth": 3, + "title": "Practical Byzantine Fault Tolerance (pBFT)", + "anchor": "practical-byzantine-fault-tolerance-pbft" + }, + { + "depth": 3, + "title": "Preimage", + "anchor": "preimage" }, { "depth": 2, - "title": "Export Required Files", - "anchor": "export-required-files" + "title": "Call", + "anchor": "call" }, { "depth": 2, - "title": "Register a Parathread", - "anchor": "register-a-parathread" + "title": "Chain Specification", + "anchor": "chain-specification" }, { "depth": 2, - "title": "Start the Collator Node", - "anchor": "start-the-collator-node" + "title": "Collator", + "anchor": "collator" }, { "depth": 2, - "title": "Producing Blocks", - "anchor": "producing-blocks" - } - ], - "stats": { - "chars": 14404, - "words": 2116, - "headings": 9, - "estimated_token_count_total": 3296 - }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-launch-a-parachain-obtain-coretime", - "title": "Obtain Coretime", - "slug": "parachains-launch-a-parachain-obtain-coretime", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-launch-a-parachain-obtain-coretime.md", - "html_url": "https://docs.polkadot.com/parachains/launch-a-parachain/obtain-coretime/", - "preview": "After deploying a parachain to Paseo in the [Deploy on Polkadot](/parachains/launch-a-parachain/deploy-to-polkadot/){target=\\_blank} tutorial, the next critical step is obtaining coretime. Coretime is the mechanism through which validation resources are allocated from the relay chain to your parachain. Your parachain can only produce and finalize blocks on the relay chain by obtaining coretime.", - "outline": [ + "title": "Collective", + "anchor": "collective" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Consensus", + "anchor": "consensus" }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Consensus Algorithm", + "anchor": "consensus-algorithm" }, { "depth": 2, - "title": "Order On-Demand Coretime", - "anchor": "order-on-demand-coretime" + "title": "Consensus Engine", + "anchor": "consensus-engine" }, { - "depth": 3, - "title": "On-Demand Extrinsics", - "anchor": "on-demand-extrinsics" + "depth": 2, + "title": "Coretime", + "anchor": "coretime" }, { - "depth": 3, - "title": "Place an On-Demand Order", - "anchor": "place-an-on-demand-order" + "depth": 2, + "title": "Development Phrase", + "anchor": "development-phrase" }, { "depth": 2, - "title": "Purchase Bulk Coretime", - "anchor": "purchase-bulk-coretime" + "title": "Digest", + "anchor": "digest" }, { - "depth": 3, - "title": "Connect Your Wallet to RegionX", - "anchor": "connect-your-wallet-to-regionx" + "depth": 2, + "title": "Dispatchable", + "anchor": "dispatchable" }, { - "depth": 3, - "title": "Obtain Coretime Chain Funds", - "anchor": "obtain-coretime-chain-funds" + "depth": 2, + "title": "Events", + "anchor": "events" }, { - "depth": 3, - "title": "Purchase a Core", - "anchor": "purchase-a-core" + "depth": 2, + "title": "Executor", + "anchor": "executor" }, { - "depth": 3, - "title": "Verify Your Purchase", - "anchor": "verify-your-purchase" + "depth": 2, + "title": "Existential Deposit", + "anchor": "existential-deposit" }, { - "depth": 3, - "title": "Assign Your Parachain to the Core", - "anchor": "assign-your-parachain-to-the-core" + "depth": 2, + "title": "Extrinsic", + "anchor": "extrinsic" }, { "depth": 2, - "title": "Next Steps", - "anchor": "next-steps" - } - ], - "stats": { - "chars": 9049, - "words": 1345, - "headings": 12, - "estimated_token_count_total": 2103 - }, - "hash": "sha256:15154f211753665d9af70dc81d15ceb3f0954e3febf9282c68c0074881d620c6", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-launch-a-parachain-set-up-the-parachain-template", - "title": "Set Up the Polkadot SDK Parachain Template", - "slug": "parachains-launch-a-parachain-set-up-the-parachain-template", - "categories": [ - "Basics", - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-launch-a-parachain-set-up-the-parachain-template.md", - "html_url": "https://docs.polkadot.com/parachains/launch-a-parachain/set-up-the-parachain-template/", - "preview": "The [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\\_blank} includes several [templates](/parachains/customize-runtime/#starting-templates){target=\\_blank} designed to help you quickly start building your own blockchain. Each template offers a different level of configuration, from minimal setups to feature-rich environments, allowing you to choose the foundation that best fits your project's needs.", - "outline": [ + "title": "Fork Choice Rule/Strategy", + "anchor": "fork-choice-rulestrategy" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "FRAME (Framework for Runtime Aggregation of Modularized Entities)", + "anchor": "frame-framework-for-runtime-aggregation-of-modularized-entities" }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Full Node", + "anchor": "full-node" }, { "depth": 2, - "title": "Polkadot SDK Utility Tools", - "anchor": "polkadot-sdk-utility-tools" + "title": "Genesis Configuration", + "anchor": "genesis-configuration" }, { "depth": 2, - "title": "Clone the Template", - "anchor": "clone-the-template" + "title": "GRANDPA", + "anchor": "grandpa" }, { "depth": 2, - "title": "Explore the Project Structure", - "anchor": "explore-the-project-structure" + "title": "Header", + "anchor": "header" }, { "depth": 2, - "title": "Compile the Runtime", - "anchor": "compile-the-runtime" + "title": "Hybrid Consensus", + "anchor": "hybrid-consensus" }, { "depth": 2, - "title": "Verify the Build", - "anchor": "verify-the-build" + "title": "Inherent Transactions", + "anchor": "inherent-transactions" }, { "depth": 2, - "title": "Run the Node Locally", - "anchor": "run-the-node-locally" + "title": "JSON-RPC", + "anchor": "json-rpc" }, { "depth": 2, - "title": "Interact with the Node", - "anchor": "interact-with-the-node" + "title": "Keystore", + "anchor": "keystore" }, { "depth": 2, - "title": "Stop the Node", - "anchor": "stop-the-node" + "title": "Kusama", + "anchor": "kusama" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 10608, - "words": 1512, - "headings": 11, - "estimated_token_count_total": 2379 - }, - "hash": "sha256:637b9460bb65621cbc7c1bff272ea287d5181a983bc61418167959e108e21791", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-overview", - "title": "Parachains Overview", - "slug": "parachains-overview", - "categories": [ - "Basics", - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-overview.md", - "html_url": "https://docs.polkadot.com/parachains/overview/", - "preview": "A parachain is a specialized blockchain that connects to the Polkadot relay chain, benefiting from shared security, interoperability, and scalability. Parachains are built using the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\\_blank}, a powerful toolkit written in Rust that provides everything needed to create custom blockchain logic while integrating seamlessly with the Polkadot network.", - "outline": [ + "title": "libp2p", + "anchor": "libp2p" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Light Client", + "anchor": "light-client" }, { "depth": 2, - "title": "Polkadot SDK: Parachain Architecture", - "anchor": "polkadot-sdk-parachain-architecture" + "title": "Metadata", + "anchor": "metadata" }, { - "depth": 3, - "title": "Substrate: The Foundation", - "anchor": "substrate-the-foundation" + "depth": 2, + "title": "Nominated Proof of Stake (NPoS)", + "anchor": "nominated-proof-of-stake-npos" }, { - "depth": 3, - "title": "FRAME: Building Blocks for Your Runtime", - "anchor": "frame-building-blocks-for-your-runtime" + "depth": 2, + "title": "Oracle", + "anchor": "oracle" }, { - "depth": 3, - "title": "Cumulus: Parachain-Specific Functionality", - "anchor": "cumulus-parachain-specific-functionality" + "depth": 2, + "title": "Origin", + "anchor": "origin" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 8461, - "words": 1024, - "headings": 6, - "estimated_token_count_total": 1751 - }, - "hash": "sha256:bbef601f2645c23200a3b16bc1b8e5bcad2aafdee6d60ae860ce8b5a53122c14", - "last_modified": "2025-10-28T14:15:59+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-runtime-maintenance-runtime-upgrades", - "title": "Runtime Upgrades", - "slug": "parachains-runtime-maintenance-runtime-upgrades", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-runtime-maintenance-runtime-upgrades.md", - "html_url": "https://docs.polkadot.com/parachains/runtime-maintenance/runtime-upgrades/", - "preview": "One of the defining features of Polkadot SDK-based blockchains is the ability to perform forkless runtime upgrades. Unlike traditional blockchains, which require hard forks and node coordination for upgrades, Polkadot networks enable seamless updates without network disruption.", - "outline": [ + "title": "Pallet", + "anchor": "pallet" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Parachain", + "anchor": "parachain" }, { "depth": 2, - "title": "How Runtime Upgrades Work", - "anchor": "how-runtime-upgrades-work" + "title": "Paseo", + "anchor": "paseo" }, { - "depth": 3, - "title": "Runtime Versioning", - "anchor": "runtime-versioning" + "depth": 2, + "title": "Polkadot", + "anchor": "polkadot" }, { - "depth": 3, - "title": "Accessing the Runtime Version", - "anchor": "accessing-the-runtime-version" + "depth": 2, + "title": "Polkadot Cloud", + "anchor": "polkadot-cloud" }, { "depth": 2, - "title": "Storage Migrations", - "anchor": "storage-migrations" - } - ], - "stats": { - "chars": 5837, - "words": 811, - "headings": 5, - "estimated_token_count_total": 1161 - }, - "hash": "sha256:ec31270001a6cd9d0a8ecb7974ad161d5c1ef4d3023d5a6af9fbc5a6ca46cbca", - "last_modified": "2025-10-28T14:42:14+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-runtime-maintenance-storage-migrations", - "title": "Storage Migrations", - "slug": "parachains-runtime-maintenance-storage-migrations", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-runtime-maintenance-storage-migrations.md", - "html_url": "https://docs.polkadot.com/parachains/runtime-maintenance/storage-migrations/", - "preview": "Storage migrations are a crucial part of the runtime upgrade process. They allow you to update the [storage items](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.storage.html){target=\\_blank} of your blockchain, adapting to changes in the runtime. Whenever you change the encoding or data types used to represent data in storage, you'll need to provide a storage migration to ensure the runtime can correctly interpret the existing stored values in the new runtime", - "outline": [ + "title": "Polkadot Hub", + "anchor": "polkadot-hub" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "PolkaVM", + "anchor": "polkavm" }, { "depth": 2, - "title": "Storage Migration Scenarios", - "anchor": "storage-migration-scenarios" + "title": "Relay Chain", + "anchor": "relay-chain" }, { "depth": 2, - "title": "Implement Storage Migrations", - "anchor": "implement-storage-migrations" + "title": "Rococo", + "anchor": "rococo" }, { - "depth": 3, - "title": "Core Migration Function", - "anchor": "core-migration-function" + "depth": 2, + "title": "Runtime", + "anchor": "runtime" }, { - "depth": 3, - "title": "Migration Testing Hooks", - "anchor": "migration-testing-hooks" + "depth": 2, + "title": "Slot", + "anchor": "slot" }, { - "depth": 3, - "title": "Migration Structure", - "anchor": "migration-structure" + "depth": 2, + "title": "Sovereign Account", + "anchor": "sovereign-account" }, { - "depth": 3, - "title": "Migration Organization", - "anchor": "migration-organization" + "depth": 2, + "title": "SS58 Address Format", + "anchor": "ss58-address-format" }, { - "depth": 3, - "title": "Scheduling Migrations", - "anchor": "scheduling-migrations" + "depth": 2, + "title": "State Transition Function (STF)", + "anchor": "state-transition-function-stf" }, { "depth": 2, - "title": "Single-Block Migrations", - "anchor": "single-block-migrations" + "title": "Storage Item", + "anchor": "storage-item" }, { "depth": 2, - "title": "Multi Block Migrations", - "anchor": "multi-block-migrations" - } - ], - "stats": { - "chars": 18500, - "words": 2363, - "headings": 10, - "estimated_token_count_total": 4014 - }, - "hash": "sha256:55dc252fdecf1590048ce8d009b822e90231442abe81e9593cf1635944a31336", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "parachains-runtime-maintenance-unlock-parachains", - "title": "Unlock a Parachain", - "slug": "parachains-runtime-maintenance-unlock-parachains", - "categories": [ - "Parachains" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-runtime-maintenance-unlock-parachains.md", - "html_url": "https://docs.polkadot.com/parachains/runtime-maintenance/unlock-parachains/", - "preview": "Parachain locks are a critical security mechanism in the Polkadot ecosystem designed to maintain decentralization during the parachain lifecycle. These locks prevent potential centralization risks that could emerge during the early stages of parachain operation.", - "outline": [ + "title": "Substrate", + "anchor": "substrate" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Transaction", + "anchor": "transaction" }, { "depth": 2, - "title": "Check If the Parachain Is Locked", - "anchor": "check-if-the-parachain-is-locked" + "title": "Transaction Era", + "anchor": "transaction-era" }, { "depth": 2, - "title": "How to Unlock a Parachain", - "anchor": "how-to-unlock-a-parachain" + "title": "Trie (Patricia Merkle Tree)", + "anchor": "trie-patricia-merkle-tree" }, { - "depth": 3, - "title": "Prepare the Unlock Call", - "anchor": "prepare-the-unlock-call" + "depth": 2, + "title": "Validator", + "anchor": "validator" }, { - "depth": 3, - "title": "Fund the Sovereign Account", - "anchor": "fund-the-sovereign-account" + "depth": 2, + "title": "WebAssembly (Wasm)", + "anchor": "webassembly-wasm" }, { - "depth": 3, - "title": "Craft and Submit the XCM", - "anchor": "craft-and-submit-the-xcm" + "depth": 2, + "title": "Weight", + "anchor": "weight" + }, + { + "depth": 2, + "title": "Westend", + "anchor": "westend" } ], "stats": { - "chars": 9232, - "words": 1276, - "headings": 6, - "estimated_token_count_total": 2028 + "chars": 24739, + "words": 3626, + "headings": 63, + "estimated_token_count_total": 5273 }, - "hash": "sha256:e408d05199cc184fc6fe8bb212efb3c9aa6cb79258977e07566692176c912def", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:40bd67811e7eabc79ca5d105eae388b19380d9f035022da17fc0d6bb173c817c", "token_estimator": "heuristic-v1" }, { - "id": "parachains-testing-fork-a-parachain", - "title": "Get Started", - "slug": "parachains-testing-fork-a-parachain", + "id": "reference-governance-origins-tracks", + "title": "Origins and Tracks", + "slug": "reference-governance-origins-tracks", "categories": [ - "Parachains", - "Tooling" + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-testing-fork-a-parachain.md", - "html_url": "https://docs.polkadot.com/parachains/testing/fork-a-parachain/", - "preview": "[Chopsticks](https://github.com/AcalaNetwork/chopsticks/){target=\\_blank}, developed by the [Acala Foundation](https://github.com/AcalaNetwork){target=\\_blank}, is a versatile tool tailored for developers working on Polkadot SDK-based blockchains. With Chopsticks, you can fork live chains locally, replay blocks to analyze extrinsics, and simulate complex scenarios like XCM interactions all without deploying to a live network.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-governance-origins-tracks.md", + "html_url": "https://docs.polkadot.com/reference/governance/origins-tracks/", + "preview": "Polkadot's OpenGov system empowers decentralized decision-making and active community participation by tailoring the governance process to the impact of proposed changes. Through a system of origins and tracks, OpenGov ensures that every referendum receives the appropriate scrutiny, balancing security, inclusivity, and efficiency.", "outline": [ { "depth": 2, @@ -8446,71 +7453,107 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Origins", + "anchor": "origins" }, { "depth": 2, - "title": "Install Chopsticks", - "anchor": "install-chopsticks" - }, - { - "depth": 3, - "title": "Global Installation", - "anchor": "global-installation" + "title": "Tracks", + "anchor": "tracks" }, { - "depth": 3, - "title": "Local Installation", - "anchor": "local-installation" + "depth": 2, + "title": "Additional Resources", + "anchor": "additional-resources" + } + ], + "stats": { + "chars": 3333, + "words": 469, + "headings": 4, + "estimated_token_count_total": 631 + }, + "hash": "sha256:baba9dd41091b792d09005d55d3df0bf65b35f42b40ebe63caf425a0978a22b0", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-governance", + "title": "On-Chain Governance Overview", + "slug": "reference-governance", + "categories": [ + "Basics", + "Polkadot Protocol" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-governance.md", + "html_url": "https://docs.polkadot.com/reference/governance/", + "preview": "Polkadot’s governance system exemplifies decentralized decision-making, empowering its community of stakeholders to shape the network’s future through active participation. The latest evolution, OpenGov, builds on Polkadot’s foundation by providing a more inclusive and efficient governance model.", + "outline": [ + { + "depth": 2, + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Configure Chopsticks", - "anchor": "configure-chopsticks" + "title": "Governance Evolution", + "anchor": "governance-evolution" + }, + { + "depth": 2, + "title": "OpenGov Key Features", + "anchor": "opengov-key-features" + }, + { + "depth": 2, + "title": "Origins and Tracks", + "anchor": "origins-and-tracks" + }, + { + "depth": 2, + "title": "Referendums", + "anchor": "referendums" }, { "depth": 3, - "title": "Configuration File", - "anchor": "configuration-file" + "title": "Vote on Referendums", + "anchor": "vote-on-referendums" }, { "depth": 3, - "title": "CLI Flags", - "anchor": "cli-flags" + "title": "Delegate Voting Power", + "anchor": "delegate-voting-power" }, { - "depth": 2, - "title": "WebSocket Commands", - "anchor": "websocket-commands" + "depth": 3, + "title": "Cancel a Referendum", + "anchor": "cancel-a-referendum" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 10894, - "words": 1330, - "headings": 10, - "estimated_token_count_total": 2614 + "chars": 7493, + "words": 1019, + "headings": 9, + "estimated_token_count_total": 1611 }, - "hash": "sha256:4325cdd697814b8043db808da3dee86d3d9c6fc7dd523aae7fe8914d59d1b39c", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:62beec261e72529f70e07a641177d489d2c8872f9c9d618cbadf1ac0fd881986", "token_estimator": "heuristic-v1" }, { - "id": "parachains-testing-run-a-parachain-network", - "title": "Get Started", - "slug": "parachains-testing-run-a-parachain-network", + "id": "reference-parachains-accounts", + "title": "Polkadot SDK Accounts", + "slug": "reference-parachains-accounts", "categories": [ - "Parachains", - "Tooling" + "Basics", + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-testing-run-a-parachain-network.md", - "html_url": "https://docs.polkadot.com/parachains/testing/run-a-parachain-network/", - "preview": "Zombienet is a robust testing framework designed for Polkadot SDK-based blockchain networks. It enables developers to efficiently deploy and test ephemeral blockchain environments on platforms like Kubernetes, Podman, and native setups. With its simple and versatile CLI, Zombienet provides an all-in-one solution for spawning networks, running tests, and validating performance.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-accounts.md", + "html_url": "https://docs.polkadot.com/reference/parachains/accounts/", + "preview": "Accounts are essential for managing identity, transactions, and governance on the network in the Polkadot SDK. Understanding these components is critical for seamless development and operation on the network, whether you're building or interacting with Polkadot-based chains.", "outline": [ { "depth": 2, @@ -8519,91 +7562,95 @@ }, { "depth": 2, - "title": "Install Zombienet", - "anchor": "install-zombienet" - }, - { - "depth": 2, - "title": "Providers", - "anchor": "providers" + "title": "Account Data Structure", + "anchor": "account-data-structure" }, { "depth": 3, - "title": "Kubernetes", - "anchor": "kubernetes" + "title": "Account", + "anchor": "account" }, { "depth": 3, - "title": "Podman", - "anchor": "podman" + "title": "Account Info", + "anchor": "account-info" }, { "depth": 3, - "title": "Local Provider", - "anchor": "local-provider" + "title": "Account Reference Counters", + "anchor": "account-reference-counters" }, { "depth": 2, - "title": "Configure Zombienet", - "anchor": "configure-zombienet" + "title": "Account Balance Types", + "anchor": "account-balance-types" }, { "depth": 3, - "title": "Configuration Files", - "anchor": "configuration-files" + "title": "Balance Types", + "anchor": "balance-types" }, { "depth": 3, - "title": "CLI Usage", - "anchor": "cli-usage" + "title": "Locks", + "anchor": "locks" }, { "depth": 3, - "title": "Settings", - "anchor": "settings" + "title": "Balance Types on Polkadot.js", + "anchor": "balance-types-on-polkadotjs" + }, + { + "depth": 2, + "title": "Address Formats", + "anchor": "address-formats" }, { "depth": 3, - "title": "Relay Chain Configuration", - "anchor": "relay-chain-configuration" + "title": "Basic Format", + "anchor": "basic-format" }, { "depth": 3, - "title": "Parachain Configuration", - "anchor": "parachain-configuration" + "title": "Address Type", + "anchor": "address-type" }, { "depth": 3, - "title": "XCM Configuration", - "anchor": "xcm-configuration" + "title": "Address Length", + "anchor": "address-length" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "depth": 3, + "title": "Checksum Types", + "anchor": "checksum-types" + }, + { + "depth": 3, + "title": "Validating Addresses", + "anchor": "validating-addresses" } ], "stats": { - "chars": 41636, - "words": 4599, - "headings": 14, - "estimated_token_count_total": 9871 + "chars": 29604, + "words": 4194, + "headings": 15, + "estimated_token_count_total": 6507 }, - "hash": "sha256:0d7e04fd952cc9d5bd8cdbfd87cc4004c5f95e896a16bc7f89dfc4caeac8f371", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:0104a9132a69345a2faac37fca0e2853a2ded1efb009511a83a98d44509ab887", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-architecture-parachains-consensus", - "title": "Parachain Consensus", - "slug": "polkadot-protocol-architecture-parachains-consensus", + "id": "reference-parachains-blocks-transactions-fees-blocks", + "title": "Blocks", + "slug": "reference-parachains-blocks-transactions-fees-blocks", "categories": [ - "Polkadot Protocol", - "Parachains" + "Basics", + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-parachains-consensus.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/parachains/consensus/", - "preview": "Parachains are independent blockchains built with the Polkadot SDK, designed to leverage Polkadot’s relay chain for shared security and transaction finality. These specialized chains operate as part of Polkadot’s execution sharding model, where each parachain manages its own state and transactions while relying on the relay chain for validation and consensus.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-blocks-transactions-fees-blocks.md", + "html_url": "https://docs.polkadot.com/reference/parachains/blocks-transactions-fees/blocks/", + "preview": "In the Polkadot SDK, blocks are fundamental to the functioning of the blockchain, serving as containers for [transactions](/reference/parachains/blocks-transactions-fees/transactions/){target=\\_blank} and changes to the chain's state. Blocks consist of headers and an array of transactions, ensuring the integrity and validity of operations on the network. This guide explores the essential components of a block, the process of block production, and how blocks are validated and imported across the", "outline": [ { "depth": 2, @@ -8612,167 +7659,157 @@ }, { "depth": 2, - "title": "The Role of Collators", - "anchor": "the-role-of-collators" + "title": "What is a Block?", + "anchor": "what-is-a-block" }, { "depth": 2, - "title": "Consensus and Validation", - "anchor": "consensus-and-validation" + "title": "Block Production", + "anchor": "block-production" }, { "depth": 3, - "title": "Path of a Parachain Block", - "anchor": "path-of-a-parachain-block" + "title": "Initialize Block", + "anchor": "initialize-block" + }, + { + "depth": 3, + "title": "Finalize Block", + "anchor": "finalize-block" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Block Authoring and Import", + "anchor": "block-authoring-and-import" + }, + { + "depth": 3, + "title": "Block Import Queue", + "anchor": "block-import-queue" + }, + { + "depth": 2, + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 6150, - "words": 790, - "headings": 5, - "estimated_token_count_total": 1125 + "chars": 6252, + "words": 910, + "headings": 8, + "estimated_token_count_total": 1395 }, - "hash": "sha256:9875239c6071033a37a0f67fabca5a6e840c4a287620309f47b4f29c5a95a1cb", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:424783c102bea5dae5b8749635858c6c59055563442a98f57521f0027dafa8d3", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-architecture-parachains-overview", - "title": "Overview", - "slug": "polkadot-protocol-architecture-parachains-overview", + "id": "reference-parachains-blocks-transactions-fees-fees", + "title": "Transactions Weights and Fees", + "slug": "reference-parachains-blocks-transactions-fees-fees", "categories": [ "Basics", - "Polkadot Protocol", - "Parachains" + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-parachains-overview.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/parachains/overview/", - "preview": "A [_parachain_](/polkadot-protocol/glossary#parachain){target=\\_blank} is a coherent, application-specific blockchain that derives security from its respective relay chain. Parachains on Polkadot are each their own separate, fully functioning blockchain. The primary difference between a parachain and a regular, \"solo\" blockchain is that the relay chain verifies the state of all parachains that are connected to it. In many ways, parachains can be thought of as a [\"cynical\" rollup](#cryptoeconomic", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-blocks-transactions-fees-fees.md", + "html_url": "https://docs.polkadot.com/reference/parachains/blocks-transactions-fees/fees/", + "preview": "When transactions are executed, or data is stored on-chain, the activity changes the chain's state and consumes blockchain resources. Because the resources available to a blockchain are limited, managing how operations on-chain consume them is important. In addition to being limited in practical terms, such as storage capacity, blockchain resources represent a potential attack vector for malicious users. For example, a malicious user might attempt to overload the network with messages to stop th", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Introductions", + "anchor": "introductions" }, { "depth": 2, - "title": "Coherent Systems", - "anchor": "coherent-systems" + "title": "How Fees are Calculated", + "anchor": "how-fees-are-calculated" }, { "depth": 2, - "title": "Flexible Ecosystem", - "anchor": "flexible-ecosystem" + "title": "Using the Transaction Payment Pallet", + "anchor": "using-the-transaction-payment-pallet" }, { - "depth": 2, - "title": "State Transition Functions (Runtimes)", - "anchor": "state-transition-functions-runtimes" + "depth": 3, + "title": "Understanding the Inclusion Fee", + "anchor": "understanding-the-inclusion-fee" }, { - "depth": 2, - "title": "Shared Security: Validated by the Relay Chain", - "anchor": "shared-security-validated-by-the-relay-chain" + "depth": 3, + "title": "Accounts with an Insufficient Balance", + "anchor": "accounts-with-an-insufficient-balance" }, { "depth": 3, - "title": "Cryptoeconomic Security: ELVES Protocol", - "anchor": "cryptoeconomic-security-elves-protocol" + "title": "Fee Multipliers", + "anchor": "fee-multipliers" }, { "depth": 2, - "title": "Interoperability", - "anchor": "interoperability" + "title": "Transactions with Special Requirements", + "anchor": "transactions-with-special-requirements" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 9561, - "words": 1321, - "headings": 8, - "estimated_token_count_total": 1861 - }, - "hash": "sha256:932c12e1af939698279ede2eacb2190e1f56119582adf2064d6cf86f7a4f3e3c", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-architecture-parachains", - "title": "Parachains", - "slug": "polkadot-protocol-architecture-parachains", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-parachains.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/parachains/", - "preview": "Discover how parachains secure their networks and reach consensus by harnessing Polkadot’s relay chain and its robust validator framework. This integrated architecture ensures shared security and seamless coordination across the entire ecosystem.", - "outline": [ + "title": "Default Weight Annotations", + "anchor": "default-weight-annotations" + }, + { + "depth": 3, + "title": "Weights and Database Read/Write Operations", + "anchor": "weights-and-database-readwrite-operations" + }, + { + "depth": 3, + "title": "Dispatch Classes", + "anchor": "dispatch-classes" + }, + { + "depth": 3, + "title": "Dynamic Weights", + "anchor": "dynamic-weights" + }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 725, - "words": 93, - "headings": 1, - "estimated_token_count_total": 12 - }, - "hash": "sha256:00be43ac8d666bbe15c5c2fa5a5085697d0bb5a6f341ebbb943a209f0be355df", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-architecture-polkadot-chain", - "title": "The Polkadot Relay Chain", - "slug": "polkadot-protocol-architecture-polkadot-chain", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-polkadot-chain.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/", - "preview": "Discover the central role of the Polkadot relay chain in securing the network and fostering interoperability. As the backbone of Polkadot, the relay chain provides shared security and ensures consensus across the ecosystem. It empowers parachains with flexible coretime allocation, enabling them to purchase blockspace on demand, ensuring efficiency and scalability for diverse blockchain applications.", - "outline": [ + "title": "Post Dispatch Weight Correction", + "anchor": "post-dispatch-weight-correction" + }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "title": "Custom Fees", + "anchor": "custom-fees" + }, + { + "depth": 3, + "title": "Custom Weights", + "anchor": "custom-weights" + }, + { + "depth": 2, + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 481, - "words": 63, - "headings": 1, - "estimated_token_count_total": 12 + "chars": 20800, + "words": 2917, + "headings": 15, + "estimated_token_count_total": 4464 }, - "hash": "sha256:2d228c52844df8952520fafdd3e6f0e26bfd2f32b5ee60c6241cf7d38603643c", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:7d0c3fa7982b3e1843adb8f27422456397580b3a3eba5047b381da8517742536", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-architecture-polkadot-chain-overview", - "title": "Overview of the Polkadot Relay Chain", - "slug": "polkadot-protocol-architecture-polkadot-chain-overview", + "id": "reference-parachains-blocks-transactions-fees-transactions", + "title": "Transactions", + "slug": "reference-parachains-blocks-transactions-fees-transactions", "categories": [ "Basics", - "Polkadot Protocol", - "Parachains" + "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-polkadot-chain-overview.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/overview/", - "preview": "Polkadot is a next-generation blockchain protocol designed to support a multi-chain future by enabling secure communication and interoperability between different blockchains. Built as a Layer-0 protocol, Polkadot introduces innovations like application-specific Layer-1 chains ([parachains](/polkadot-protocol/architecture/parachains/){targe=\\_blank}), shared security through [Nominated Proof of Stake (NPoS)](/polkadot-protocol/glossary/#nominated-proof-of-stake-npos){target=\\_blank}, and cross-c", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-blocks-transactions-fees-transactions.md", + "html_url": "https://docs.polkadot.com/reference/parachains/blocks-transactions-fees/transactions/", + "preview": "Transactions are essential components of blockchain networks, enabling state changes and the execution of key operations. In the Polkadot SDK, transactions, often called extrinsics, come in multiple forms, including signed, unsigned, and inherent transactions.", "outline": [ { "depth": 2, @@ -8781,163 +7818,130 @@ }, { "depth": 2, - "title": "Polkadot 1.0", - "anchor": "polkadot-10" - }, - { - "depth": 3, - "title": "High-Level Architecture", - "anchor": "high-level-architecture" + "title": "What Is a Transaction?", + "anchor": "what-is-a-transaction" }, { "depth": 3, - "title": "Polkadot's Additional Functionalities", - "anchor": "polkadots-additional-functionalities" + "title": "Signed Transactions", + "anchor": "signed-transactions" }, { "depth": 3, - "title": "Polkadot's Resilience", - "anchor": "polkadots-resilience" + "title": "Unsigned Transactions", + "anchor": "unsigned-transactions" }, { "depth": 3, - "title": "Polkadot's Blockspace", - "anchor": "polkadots-blockspace" + "title": "Inherent Transactions", + "anchor": "inherent-transactions" }, { "depth": 2, - "title": "DOT Token", - "anchor": "dot-token" + "title": "Transaction Formats", + "anchor": "transaction-formats" }, { "depth": 3, - "title": "Redenomination of DOT", - "anchor": "redenomination-of-dot" + "title": "Types of Transaction Formats", + "anchor": "types-of-transaction-formats" }, { "depth": 3, - "title": "The Planck Unit", - "anchor": "the-planck-unit" + "title": "Signed Transaction Data Structure", + "anchor": "signed-transaction-data-structure" }, { "depth": 3, - "title": "Uses for DOT", - "anchor": "uses-for-dot" + "title": "Signed Extensions", + "anchor": "signed-extensions" }, { "depth": 2, - "title": "JAM and the Road Ahead", - "anchor": "jam-and-the-road-ahead" - } - ], - "stats": { - "chars": 12513, - "words": 1781, - "headings": 11, - "estimated_token_count_total": 2591 - }, - "hash": "sha256:201e7efa0ad6b24890dd06f69714e19d9700ab7f7a51a33fe6d6e0664b7170b2", - "last_modified": "2025-10-28T14:15:59+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-architecture-polkadot-chain-pos-consensus", - "title": "Proof of Stake Consensus", - "slug": "polkadot-protocol-architecture-polkadot-chain-pos-consensus", - "categories": [ - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-polkadot-chain-pos-consensus.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/", - "preview": "Polkadot's Proof of Stake consensus model leverages a unique hybrid approach by design to promote decentralized and secure network operations. In traditional Proof of Stake (PoS) systems, a node's ability to validate transactions is tied to its token holdings, which can lead to centralization risks and limited validator participation. Polkadot addresses these concerns through its [Nominated Proof of Stake (NPoS)](/polkadot-protocol/glossary/#nominated-proof-of-stake-npos){target=\\_blank} model a", - "outline": [ + "title": "Transaction Construction", + "anchor": "transaction-construction" + }, { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "depth": 3, + "title": "Construct a Signed Transaction", + "anchor": "construct-a-signed-transaction" }, { - "depth": 2, - "title": "Nominated Proof of Stake", - "anchor": "nominated-proof-of-stake" + "depth": 3, + "title": "Transaction Encoding", + "anchor": "transaction-encoding" }, { - "depth": 2, - "title": "Hybrid Consensus", - "anchor": "hybrid-consensus" + "depth": 3, + "title": "Customize Transaction Construction", + "anchor": "customize-transaction-construction" }, { "depth": 2, - "title": "Block Production - BABE", - "anchor": "block-production-babe" + "title": "Lifecycle of a Transaction", + "anchor": "lifecycle-of-a-transaction" }, { "depth": 3, - "title": "Validator Participation", - "anchor": "validator-participation" + "title": "Define Transaction Properties", + "anchor": "define-transaction-properties" }, { "depth": 3, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Process on a Block Authoring Node", + "anchor": "process-on-a-block-authoring-node" }, { - "depth": 2, - "title": "Finality Gadget - GRANDPA", - "anchor": "finality-gadget-grandpa" + "depth": 3, + "title": "Validate and Queue", + "anchor": "validate-and-queue" }, { "depth": 3, - "title": "Probabilistic vs. Provable Finality", - "anchor": "probabilistic-vs-provable-finality" + "title": "Transaction Ordering and Priority", + "anchor": "transaction-ordering-and-priority" }, { "depth": 3, - "title": "Additional Resources", - "anchor": "additional-resources-2" + "title": "Transaction Execution", + "anchor": "transaction-execution" }, { "depth": 2, - "title": "Fork Choice", - "anchor": "fork-choice" - }, - { - "depth": 3, - "title": "Additional Resources", - "anchor": "additional-resources-3" + "title": "Transaction Mortality", + "anchor": "transaction-mortality" }, { "depth": 2, - "title": "Bridging - BEEFY", - "anchor": "bridging-beefy" + "title": "Unique Identifiers for Extrinsics", + "anchor": "unique-identifiers-for-extrinsics" }, { - "depth": 3, + "depth": 2, "title": "Additional Resources", - "anchor": "additional-resources-4" + "anchor": "additional-resources" } ], "stats": { - "chars": 12788, - "words": 1838, - "headings": 13, - "estimated_token_count_total": 2534 + "chars": 23610, + "words": 3333, + "headings": 22, + "estimated_token_count_total": 4708 }, - "hash": "sha256:191df9b098e17e9de4597c9f8ced8abbafdfabc7e0f5c0a94d767fc2c9d7742b", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:66726634d3a51cd9c471621054a6e5f09c8061dca6144b64c8bcf45626359617", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-architecture-system-chains-asset-hub", - "title": "Asset Hub", - "slug": "polkadot-protocol-architecture-system-chains-asset-hub", + "id": "reference-parachains-chain-data", + "title": "Chain Data", + "slug": "reference-parachains-chain-data", "categories": [ + "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains-asset-hub.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/asset-hub/", - "preview": "The Asset Hub is a critical component in the Polkadot ecosystem, enabling the management of fungible and non-fungible assets across the network. Since the relay chain focuses on maintaining security and consensus without direct asset management, Asset Hub provides a streamlined platform for creating, managing, and using on-chain assets in a fee-efficient manner. This guide outlines the core features of Asset Hub, including how it handles asset operations, cross-chain transfers, and asset integra", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-chain-data.md", + "html_url": "https://docs.polkadot.com/reference/parachains/chain-data/", + "preview": "Understanding and leveraging on-chain data is a fundamental aspect of blockchain development. Whether you're building frontend applications or backend systems, accessing and decoding runtime metadata is vital to interacting with the blockchain. This guide introduces you to the tools and processes for generating and retrieving metadata, explains its role in application development, and outlines the additional APIs available for interacting with a Polkadot node. By mastering these components, you", "outline": [ { "depth": 2, @@ -8946,131 +7950,114 @@ }, { "depth": 2, - "title": "Assets Basics", - "anchor": "assets-basics" + "title": "Application Development", + "anchor": "application-development" }, { "depth": 2, - "title": "Assets Pallet", - "anchor": "assets-pallet" + "title": "Understand Metadata", + "anchor": "understand-metadata" }, { - "depth": 3, - "title": "Key Features", - "anchor": "key-features" + "depth": 2, + "title": "Expose Runtime Information as Metadata", + "anchor": "expose-runtime-information-as-metadata" }, { - "depth": 3, - "title": "Main Functions", - "anchor": "main-functions" + "depth": 2, + "title": "Generate Metadata", + "anchor": "generate-metadata" }, { - "depth": 3, - "title": "Querying Functions", - "anchor": "querying-functions" + "depth": 2, + "title": "Retrieve Runtime Metadata", + "anchor": "retrieve-runtime-metadata" }, { "depth": 3, - "title": "Permission Models and Roles", - "anchor": "permission-models-and-roles" + "title": "Use Polkadot.js", + "anchor": "use-polkadotjs" }, { "depth": 3, - "title": "Asset Freezing", - "anchor": "asset-freezing" + "title": "Use Curl", + "anchor": "use-curl" }, { "depth": 3, - "title": "Non-Custodial Transfers (Approval API)", - "anchor": "non-custodial-transfers-approval-api" + "title": "Use Subxt", + "anchor": "use-subxt" }, { "depth": 2, - "title": "Foreign Assets", - "anchor": "foreign-assets" - }, - { - "depth": 3, - "title": "Handling Foreign Assets", - "anchor": "handling-foreign-assets" + "title": "Client Applications and Metadata", + "anchor": "client-applications-and-metadata" }, { "depth": 2, - "title": "Integration", - "anchor": "integration" - }, - { - "depth": 3, - "title": "API Sidecar", - "anchor": "api-sidecar" - }, - { - "depth": 3, - "title": "TxWrapper", - "anchor": "txwrapper" + "title": "Metadata Format", + "anchor": "metadata-format" }, { "depth": 3, - "title": "ParaSpell", - "anchor": "paraspell" + "title": "Pallets", + "anchor": "pallets" }, { "depth": 3, - "title": "Parachain Node", - "anchor": "parachain-node" + "title": "Extrinsic", + "anchor": "extrinsic" }, { "depth": 2, - "title": "XCM Transfer Monitoring", - "anchor": "xcm-transfer-monitoring" - }, - { - "depth": 3, - "title": "Monitor XCM Deposits", - "anchor": "monitor-xcm-deposits" - }, - { - "depth": 3, - "title": "Track XCM Information Back to the Source", - "anchor": "track-xcm-information-back-to-the-source" - }, - { - "depth": 3, - "title": "Practical Monitoring Examples", - "anchor": "practical-monitoring-examples" - }, - { - "depth": 3, - "title": "Monitor for Failed XCM Transfers", - "anchor": "monitor-for-failed-xcm-transfers" + "title": "Included RPC APIs", + "anchor": "included-rpc-apis" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 20100, - "words": 2910, - "headings": 22, - "estimated_token_count_total": 4105 + "chars": 18650, + "words": 2216, + "headings": 15, + "estimated_token_count_total": 3774 }, - "hash": "sha256:759ab6dea0ad03c3f627558ea186d9f32351fa559acde82931684efc2da59d46", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:49238d1e9e2c33e0fcd3a84b5e30f0d3840d7d23a783b538875e0a23f38efc1d", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-architecture-system-chains-bridge-hub", - "title": "Bridge Hub", - "slug": "polkadot-protocol-architecture-system-chains-bridge-hub", + "id": "reference-parachains-consensus-async-backing", + "title": "reference-parachains-consensus-async-backing", + "slug": "reference-parachains-consensus-async-backing", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-consensus-async-backing.md", + "html_url": "https://docs.polkadot.com/reference/parachains/consensus/async-backing/", + "preview": "TODO", + "outline": [], + "stats": { + "chars": 5, + "words": 1, + "headings": 0, + "estimated_token_count_total": 0 + }, + "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-parachains-consensus-elastic-scaling", + "title": "Elastic Scaling", + "slug": "reference-parachains-consensus-elastic-scaling", "categories": [ "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains-bridge-hub.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/bridge-hub/", - "preview": "The Bridge Hub system parachain plays a crucial role in facilitating trustless interactions between Polkadot, Kusama, Ethereum, and other blockchain ecosystems. By implementing on-chain light clients and supporting protocols like BEEFY and GRANDPA, Bridge Hub ensures seamless message transmission and state verification across chains. It also provides essential [pallets](/polkadot-protocol/glossary/#pallet){target=\\_blank} for sending and receiving messages, making it a cornerstone of Polkadot’s", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-consensus-elastic-scaling.md", + "html_url": "https://docs.polkadot.com/reference/parachains/consensus/elastic-scaling/", + "preview": "Polkadot's architecture delivers scalability and security through its shared security model, where the relay chain coordinates and validates multiple parallel chains.", "outline": [ { "depth": 2, @@ -9079,127 +8066,80 @@ }, { "depth": 2, - "title": "Trustless Bridging", - "anchor": "trustless-bridging" + "title": "How Elastic Scaling Works", + "anchor": "how-elastic-scaling-works" }, { "depth": 2, - "title": "Bridging Components", - "anchor": "bridging-components" + "title": "Benefits of Elastic Scaling", + "anchor": "benefits-of-elastic-scaling" }, { - "depth": 3, - "title": "Ethereum-Specific Support", - "anchor": "ethereum-specific-support" + "depth": 2, + "title": "Use Cases", + "anchor": "use-cases" }, { - "depth": 2, - "title": "Deployed Bridges", - "anchor": "deployed-bridges" + "depth": 3, + "title": "Handling Sudden Traffic Spikes", + "anchor": "handling-sudden-traffic-spikes" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } - ], - "stats": { - "chars": 5475, - "words": 775, - "headings": 6, - "estimated_token_count_total": 1218 - }, - "hash": "sha256:26c156146ef9743fc26c6499294ff14186f97edbc2a34f445d3366b72f7148ae", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-architecture-system-chains-collectives", - "title": "Collectives Chain", - "slug": "polkadot-protocol-architecture-system-chains-collectives", - "categories": [ - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains-collectives.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/collectives/", - "preview": "Established through [Referendum 81](https://polkadot-old.polkassembly.io/referendum/81){target=\\_blank}, the Collectives chain operates as a dedicated parachain exclusive to the Polkadot network with no counterpart on Kusama. This specialized infrastructure provides a foundation for various on-chain governance groups essential to Polkadot's ecosystem.", - "outline": [ + "depth": 3, + "title": "Supporting Early-Stage Growth", + "anchor": "supporting-early-stage-growth" + }, { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "depth": 3, + "title": "Scaling Massive IoT Networks", + "anchor": "scaling-massive-iot-networks" }, { - "depth": 2, - "title": "Key Collectives", - "anchor": "key-collectives" + "depth": 3, + "title": "Powering Real-Time, Low-Latency Systems", + "anchor": "powering-real-time-low-latency-systems" } ], "stats": { - "chars": 2288, - "words": 293, - "headings": 2, - "estimated_token_count_total": 424 + "chars": 7871, + "words": 1047, + "headings": 8, + "estimated_token_count_total": 1440 }, - "hash": "sha256:59ec351fbb8d3a392e90f4f5bf6b62f58b21d6d7a900c5e367e5d2e09ecb3aca", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:2d228c52844df8952520fafdd3e6f0e26bfd2f32b5ee60c6241cf7d38603643c", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-architecture-system-chains-coretime", - "title": "Coretime Chain", - "slug": "polkadot-protocol-architecture-system-chains-coretime", + "id": "reference-parachains-consensus", + "title": "reference-parachains-consensus", + "slug": "reference-parachains-consensus", "categories": [ - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains-coretime.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/coretime/", - "preview": "The Coretime system chain facilitates the allocation, procurement, sale, and scheduling of bulk [coretime](/reference/glossary/#coretime){target=\\_blank}, enabling tasks (such as [parachains](/reference/glossary/#parachain){target=\\_blank}) to utilize the computation and security provided by Polkadot.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Bulk Coretime Assignment", - "anchor": "bulk-coretime-assignment" - }, - { - "depth": 2, - "title": "On Demand Coretime", - "anchor": "on-demand-coretime" - }, - { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" - } + "Uncategorized" ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-consensus.md", + "html_url": "https://docs.polkadot.com/reference/parachains/consensus/", + "preview": "TODO", + "outline": [], "stats": { - "chars": 5279, - "words": 772, - "headings": 4, - "estimated_token_count_total": 1230 + "chars": 5, + "words": 1, + "headings": 0, + "estimated_token_count_total": 0 }, - "hash": "sha256:8d186fa56ccbbf4b6c85cffc5521b9a99a20e9517f3b4a435730745803cbf2e8", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-architecture-system-chains-overview", - "title": "Overview of Polkadot's System Chains", - "slug": "polkadot-protocol-architecture-system-chains-overview", + "id": "reference-parachains-cryptography", + "title": "Cryptography", + "slug": "reference-parachains-cryptography", "categories": [ "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains-overview.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/overview/", - "preview": "Polkadot's relay chain is designed to secure parachains and facilitate seamless inter-chain communication. However, resource-intensive—tasks like governance, asset management, and bridging are more efficiently handled by system parachains. These specialized chains offload functionality from the relay chain, leveraging Polkadot's parallel execution model to improve performance and scalability. By distributing key functionalities across system parachains, Polkadot can maximize its relay chain's bl", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-cryptography.md", + "html_url": "https://docs.polkadot.com/reference/parachains/cryptography/", + "preview": "Cryptography forms the backbone of blockchain technology, providing the mathematical verifiability crucial for consensus systems, data integrity, and user security. While a deep understanding of the underlying mathematical processes isn't necessary for most blockchain developers, grasping the fundamental applications of cryptography is essential. This page comprehensively overviews cryptographic implementations used across Polkadot SDK-based chains and the broader blockchain ecosystem.", "outline": [ { "depth": 2, @@ -9208,216 +8148,80 @@ }, { "depth": 2, - "title": "System Chains", - "anchor": "system-chains" + "title": "Hash Functions", + "anchor": "hash-functions" }, { - "depth": 2, - "title": "Existing System Chains", - "anchor": "existing-system-chains" + "depth": 3, + "title": "Key Properties of Hash Functions", + "anchor": "key-properties-of-hash-functions" }, { "depth": 3, - "title": "Asset Hub", - "anchor": "asset-hub" + "title": "Blake2", + "anchor": "blake2" }, { - "depth": 3, - "title": "Collectives", - "anchor": "collectives" + "depth": 2, + "title": "Types of Cryptography", + "anchor": "types-of-cryptography" }, { "depth": 3, - "title": "Bridge Hub", - "anchor": "bridge-hub" + "title": "Symmetric Cryptography", + "anchor": "symmetric-cryptography" }, { "depth": 3, - "title": "People Chain", - "anchor": "people-chain" + "title": "Asymmetric Cryptography", + "anchor": "asymmetric-cryptography" }, { "depth": 3, - "title": "Coretime Chain", - "anchor": "coretime-chain" + "title": "Trade-offs and Compromises", + "anchor": "trade-offs-and-compromises" + }, + { + "depth": 2, + "title": "Digital Signatures", + "anchor": "digital-signatures" }, { "depth": 3, - "title": "Encointer", - "anchor": "encointer" - } - ], - "stats": { - "chars": 7727, - "words": 1105, - "headings": 9, - "estimated_token_count_total": 1643 - }, - "hash": "sha256:100377787627052a29bd1173270b5ad307639b828c331e71c85d4c00bc5692d8", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-architecture-system-chains", - "title": "System Chains", - "slug": "polkadot-protocol-architecture-system-chains", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-system-chains.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/system-chains/", - "preview": "Explore the critical roles Polkadot’s system chains play in enhancing the network’s efficiency and scalability. From managing on-chain assets with the Asset Hub to enabling seamless Web3 integration through the Bridge Hub and facilitating coretime operations with the Coretime chain, each system chain is designed to offload specialized tasks from the relay chain, optimizing the entire ecosystem.", - "outline": [ - { - "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 929, - "words": 124, - "headings": 1, - "estimated_token_count_total": 12 - }, - "hash": "sha256:8239d1e8d8642cb7c10e9e5f971c99b999e9e4a87373b50bf4a691225c1e4702", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-architecture", - "title": "Architecture", - "slug": "polkadot-protocol-architecture", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/architecture/", - "preview": "Explore Polkadot's architecture, including the relay chain, parachains, and system chains, and discover the role each component plays in the broader ecosystem.", - "outline": [ - { - "depth": 2, - "title": "A Brief Look at Polkadot’s Chain Ecosystem", - "anchor": "a-brief-look-at-polkadots-chain-ecosystem" + "title": "Example of Creating a Digital Signature", + "anchor": "example-of-creating-a-digital-signature" }, { "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 990, - "words": 132, - "headings": 2, - "estimated_token_count_total": 177 - }, - "hash": "sha256:f0e04286eacf23b182186f23e9854c0cd251545b8a8d561d2503f962dbfe32c0", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-onchain-governance", - "title": "On-Chain Governance", - "slug": "polkadot-protocol-onchain-governance", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-onchain-governance.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/onchain-governance/", - "preview": "Polkadot's on-chain governance system, OpenGov, enables decentralized decision-making across the network. It empowers stakeholders to propose, vote on, and enact changes with transparency and efficiency. This system ensures that governance is both flexible and inclusive, allowing developers to integrate custom governance solutions and mechanisms within the network. Understanding how OpenGov functions is crucial for anyone looking to engage with Polkadot’s decentralized ecosystem, whether you’re", - "outline": [ - { - "depth": 2, - "title": "Start Building Governance Solutions", - "anchor": "start-building-governance-solutions" + "title": "Elliptic Curve", + "anchor": "elliptic-curve" }, { - "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 2114, - "words": 285, - "headings": 2, - "estimated_token_count_total": 233 - }, - "hash": "sha256:baba9dd41091b792d09005d55d3df0bf65b35f42b40ebe63caf425a0978a22b0", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-blocks-transactions-fees", - "title": "Blocks, Transactions, and Fees", - "slug": "polkadot-protocol-parachain-basics-blocks-transactions-fees", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-blocks-transactions-fees.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/blocks-transactions-fees/", - "preview": "Discover the inner workings of Polkadot’s blocks and transactions, including their structure, processing, and lifecycle within the network. Learn how blocks are authored, validated, and finalized, ensuring seamless operation and consensus across the ecosystem. Dive into the various types of transactions—signed, unsigned, and inherent—and understand how they are constructed, submitted, and validated.", - "outline": [ - { - "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 788, - "words": 105, - "headings": 1, - "estimated_token_count_total": 12 - }, - "hash": "sha256:62beec261e72529f70e07a641177d489d2c8872f9c9d618cbadf1ac0fd881986", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics", - "title": "Parachain Basics", - "slug": "polkadot-protocol-parachain-basics", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/", - "preview": "This section equips developers with the essential knowledge to create, deploy, and enhance applications and blockchains within the Polkadot ecosystem. Gain a comprehensive understanding of Polkadot’s foundational components, including accounts, balances, and transactions, as well as advanced topics like data encoding and cryptographic methods. Mastering these concepts is vital for building robust and secure applications on Polkadot.", - "outline": [ - { - "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" + "depth": 3, + "title": "Various Implementations", + "anchor": "various-implementations" } ], "stats": { - "chars": 29648, - "words": 4201, - "headings": 15, - "estimated_token_count_total": 6521 + "chars": 8860, + "words": 1293, + "headings": 12, + "estimated_token_count_total": 1797 }, - "hash": "sha256:1f9ce923b3ce296571fe63837c0d3c3c791a339ef02db09ead6b2b92e9d1bfd5", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:259dcef86aadc513675258b665cc3940db65af6eb32a5db85da6ac339966fa60", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-parachain-basics-blocks-transactions-fees-blocks", - "title": "Blocks", - "slug": "polkadot-protocol-parachain-basics-blocks-transactions-fees-blocks", + "id": "reference-parachains-data-encoding", + "title": "Data Encoding", + "slug": "reference-parachains-data-encoding", "categories": [ "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-blocks-transactions-fees-blocks.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/blocks-transactions-fees/blocks/", - "preview": "In the Polkadot SDK, blocks are fundamental to the functioning of the blockchain, serving as containers for [transactions](/polkadot-protocol/parachain-basics/blocks-transactions-fees/transactions/){target=\\_blank} and changes to the chain's state. Blocks consist of headers and an array of transactions, ensuring the integrity and validity of operations on the network. This guide explores the essential components of a block, the process of block production, and how blocks are validated and import", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-data-encoding.md", + "html_url": "https://docs.polkadot.com/reference/parachains/data-encoding/", + "preview": "The Polkadot SDK uses a lightweight and efficient encoding/decoding mechanism to optimize data transmission across the network. This mechanism, known as the _SCALE_ codec, is used for serializing and deserializing data.", "outline": [ { "depth": 2, @@ -9426,1618 +8230,200 @@ }, { "depth": 2, - "title": "What is a Block?", - "anchor": "what-is-a-block" + "title": "SCALE Codec", + "anchor": "scale-codec" }, { - "depth": 2, - "title": "Block Production", - "anchor": "block-production" + "depth": 3, + "title": "Encode", + "anchor": "encode" }, { "depth": 3, - "title": "Initialize Block", - "anchor": "initialize-block" + "title": "Decode", + "anchor": "decode" }, { "depth": 3, - "title": "Finalize Block", - "anchor": "finalize-block" + "title": "CompactAs", + "anchor": "compactas" }, { - "depth": 2, - "title": "Block Authoring and Import", - "anchor": "block-authoring-and-import" + "depth": 3, + "title": "HasCompact", + "anchor": "hascompact" }, { "depth": 3, - "title": "Block Import Queue", - "anchor": "block-import-queue" + "title": "EncodeLike", + "anchor": "encodelike" + }, + { + "depth": 3, + "title": "Data Types", + "anchor": "data-types" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Encode and Decode Rust Trait Implementations", + "anchor": "encode-and-decode-rust-trait-implementations" + }, + { + "depth": 2, + "title": "SCALE Codec Libraries", + "anchor": "scale-codec-libraries" } ], "stats": { - "chars": 6266, - "words": 912, - "headings": 8, - "estimated_token_count_total": 1399 + "chars": 13629, + "words": 1314, + "headings": 10, + "estimated_token_count_total": 3213 }, - "hash": "sha256:bcad23a74d962cab72b54cdc090bf9ee0cd5ecf79f70fb642f154668c2743983", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:e448294b6e52291ac0add5fa6533572814e6cd27af42bdaccc2000b86f52d775", "token_estimator": "heuristic-v1" }, { - "id": "polkadot-protocol-parachain-basics-blocks-transactions-fees-fees", - "title": "Transactions Weights and Fees", - "slug": "polkadot-protocol-parachain-basics-blocks-transactions-fees-fees", + "id": "reference-parachains-interoperability", + "title": "Interoperability", + "slug": "reference-parachains-interoperability", "categories": [ "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-blocks-transactions-fees-fees.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/blocks-transactions-fees/fees/", - "preview": "When transactions are executed, or data is stored on-chain, the activity changes the chain's state and consumes blockchain resources. Because the resources available to a blockchain are limited, managing how operations on-chain consume them is important. In addition to being limited in practical terms, such as storage capacity, blockchain resources represent a potential attack vector for malicious users. For example, a malicious user might attempt to overload the network with messages to stop th", - "outline": [ - { - "depth": 2, - "title": "Introductions", - "anchor": "introductions" - }, - { - "depth": 2, - "title": "How Fees are Calculated", - "anchor": "how-fees-are-calculated" - }, - { - "depth": 2, - "title": "Using the Transaction Payment Pallet", - "anchor": "using-the-transaction-payment-pallet" - }, - { - "depth": 3, - "title": "Understanding the Inclusion Fee", - "anchor": "understanding-the-inclusion-fee" - }, - { - "depth": 3, - "title": "Accounts with an Insufficient Balance", - "anchor": "accounts-with-an-insufficient-balance" - }, - { - "depth": 3, - "title": "Fee Multipliers", - "anchor": "fee-multipliers" - }, - { - "depth": 2, - "title": "Transactions with Special Requirements", - "anchor": "transactions-with-special-requirements" - }, - { - "depth": 2, - "title": "Default Weight Annotations", - "anchor": "default-weight-annotations" - }, - { - "depth": 3, - "title": "Weights and Database Read/Write Operations", - "anchor": "weights-and-database-readwrite-operations" - }, - { - "depth": 3, - "title": "Dispatch Classes", - "anchor": "dispatch-classes" - }, - { - "depth": 3, - "title": "Dynamic Weights", - "anchor": "dynamic-weights" - }, - { - "depth": 2, - "title": "Post Dispatch Weight Correction", - "anchor": "post-dispatch-weight-correction" - }, - { - "depth": 2, - "title": "Custom Fees", - "anchor": "custom-fees" - }, - { - "depth": 3, - "title": "Custom Weights", - "anchor": "custom-weights" - }, - { - "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" - } - ], - "stats": { - "chars": 20797, - "words": 2917, - "headings": 15, - "estimated_token_count_total": 4464 - }, - "hash": "sha256:299597c39d0e4e4902be8e45b354fff78a862aa5799e4f16d16787a97a1e3da8", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-blocks-transactions-fees-transactions", - "title": "Transactions", - "slug": "polkadot-protocol-parachain-basics-blocks-transactions-fees-transactions", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-blocks-transactions-fees-transactions.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/blocks-transactions-fees/transactions/", - "preview": "Transactions are essential components of blockchain networks, enabling state changes and the execution of key operations. In the Polkadot SDK, transactions, often called extrinsics, come in multiple forms, including signed, unsigned, and inherent transactions.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "What Is a Transaction?", - "anchor": "what-is-a-transaction" - }, - { - "depth": 3, - "title": "Signed Transactions", - "anchor": "signed-transactions" - }, - { - "depth": 3, - "title": "Unsigned Transactions", - "anchor": "unsigned-transactions" - }, - { - "depth": 3, - "title": "Inherent Transactions", - "anchor": "inherent-transactions" - }, - { - "depth": 2, - "title": "Transaction Formats", - "anchor": "transaction-formats" - }, - { - "depth": 3, - "title": "Types of Transaction Formats", - "anchor": "types-of-transaction-formats" - }, - { - "depth": 3, - "title": "Signed Transaction Data Structure", - "anchor": "signed-transaction-data-structure" - }, - { - "depth": 3, - "title": "Signed Extensions", - "anchor": "signed-extensions" - }, - { - "depth": 2, - "title": "Transaction Construction", - "anchor": "transaction-construction" - }, - { - "depth": 3, - "title": "Construct a Signed Transaction", - "anchor": "construct-a-signed-transaction" - }, - { - "depth": 3, - "title": "Transaction Encoding", - "anchor": "transaction-encoding" - }, - { - "depth": 3, - "title": "Customize Transaction Construction", - "anchor": "customize-transaction-construction" - }, - { - "depth": 2, - "title": "Lifecycle of a Transaction", - "anchor": "lifecycle-of-a-transaction" - }, - { - "depth": 3, - "title": "Define Transaction Properties", - "anchor": "define-transaction-properties" - }, - { - "depth": 3, - "title": "Process on a Block Authoring Node", - "anchor": "process-on-a-block-authoring-node" - }, - { - "depth": 3, - "title": "Validate and Queue", - "anchor": "validate-and-queue" - }, - { - "depth": 3, - "title": "Transaction Ordering and Priority", - "anchor": "transaction-ordering-and-priority" - }, - { - "depth": 3, - "title": "Transaction Execution", - "anchor": "transaction-execution" - }, - { - "depth": 2, - "title": "Transaction Mortality", - "anchor": "transaction-mortality" - }, - { - "depth": 2, - "title": "Unique Identifiers for Extrinsics", - "anchor": "unique-identifiers-for-extrinsics" - }, - { - "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" - } - ], - "stats": { - "chars": 23604, - "words": 3333, - "headings": 22, - "estimated_token_count_total": 4705 - }, - "hash": "sha256:6675634d4c5f274a7cc69802ee0a2d259e38efd5afd1c9dacc2d0fecfb370e4c", - "last_modified": "2025-10-28T14:15:59+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-chain-data", - "title": "Chain Data", - "slug": "polkadot-protocol-parachain-basics-chain-data", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-chain-data.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/chain-data/", - "preview": "Understanding and leveraging on-chain data is a fundamental aspect of blockchain development. Whether you're building frontend applications or backend systems, accessing and decoding runtime metadata is vital to interacting with the blockchain. This guide introduces you to the tools and processes for generating and retrieving metadata, explains its role in application development, and outlines the additional APIs available for interacting with a Polkadot node. By mastering these components, you", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Application Development", - "anchor": "application-development" - }, - { - "depth": 2, - "title": "Understand Metadata", - "anchor": "understand-metadata" - }, - { - "depth": 2, - "title": "Expose Runtime Information as Metadata", - "anchor": "expose-runtime-information-as-metadata" - }, - { - "depth": 2, - "title": "Generate Metadata", - "anchor": "generate-metadata" - }, - { - "depth": 2, - "title": "Retrieve Runtime Metadata", - "anchor": "retrieve-runtime-metadata" - }, - { - "depth": 3, - "title": "Use Polkadot.js", - "anchor": "use-polkadotjs" - }, - { - "depth": 3, - "title": "Use Curl", - "anchor": "use-curl" - }, - { - "depth": 3, - "title": "Use Subxt", - "anchor": "use-subxt" - }, - { - "depth": 2, - "title": "Client Applications and Metadata", - "anchor": "client-applications-and-metadata" - }, - { - "depth": 2, - "title": "Metadata Format", - "anchor": "metadata-format" - }, - { - "depth": 3, - "title": "Pallets", - "anchor": "pallets" - }, - { - "depth": 3, - "title": "Extrinsic", - "anchor": "extrinsic" - }, - { - "depth": 2, - "title": "Included RPC APIs", - "anchor": "included-rpc-apis" - }, - { - "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" - } - ], - "stats": { - "chars": 18678, - "words": 2220, - "headings": 15, - "estimated_token_count_total": 3782 - }, - "hash": "sha256:eb4da21d561e9fd9333d97805318f0e263f54570120d3852ce7eba64da604cc2", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-cryptography", - "title": "Cryptography", - "slug": "polkadot-protocol-parachain-basics-cryptography", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-cryptography.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/cryptography/", - "preview": "Cryptography forms the backbone of blockchain technology, providing the mathematical verifiability crucial for consensus systems, data integrity, and user security. While a deep understanding of the underlying mathematical processes isn't necessary for most blockchain developers, grasping the fundamental applications of cryptography is essential. This page comprehensively overviews cryptographic implementations used across Polkadot SDK-based chains and the broader blockchain ecosystem.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Hash Functions", - "anchor": "hash-functions" - }, - { - "depth": 3, - "title": "Key Properties of Hash Functions", - "anchor": "key-properties-of-hash-functions" - }, - { - "depth": 3, - "title": "Blake2", - "anchor": "blake2" - }, - { - "depth": 2, - "title": "Types of Cryptography", - "anchor": "types-of-cryptography" - }, - { - "depth": 3, - "title": "Symmetric Cryptography", - "anchor": "symmetric-cryptography" - }, - { - "depth": 3, - "title": "Asymmetric Cryptography", - "anchor": "asymmetric-cryptography" - }, - { - "depth": 3, - "title": "Trade-offs and Compromises", - "anchor": "trade-offs-and-compromises" - }, - { - "depth": 2, - "title": "Digital Signatures", - "anchor": "digital-signatures" - }, - { - "depth": 3, - "title": "Example of Creating a Digital Signature", - "anchor": "example-of-creating-a-digital-signature" - }, - { - "depth": 2, - "title": "Elliptic Curve", - "anchor": "elliptic-curve" - }, - { - "depth": 3, - "title": "Various Implementations", - "anchor": "various-implementations" - } - ], - "stats": { - "chars": 8860, - "words": 1293, - "headings": 12, - "estimated_token_count_total": 1797 - }, - "hash": "sha256:259dcef86aadc513675258b665cc3940db65af6eb32a5db85da6ac339966fa60", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-data-encoding", - "title": "Data Encoding", - "slug": "polkadot-protocol-parachain-basics-data-encoding", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-data-encoding.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/data-encoding/", - "preview": "The Polkadot SDK uses a lightweight and efficient encoding/decoding mechanism to optimize data transmission across the network. This mechanism, known as the _SCALE_ codec, is used for serializing and deserializing data.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "SCALE Codec", - "anchor": "scale-codec" - }, - { - "depth": 3, - "title": "Encode", - "anchor": "encode" - }, - { - "depth": 3, - "title": "Decode", - "anchor": "decode" - }, - { - "depth": 3, - "title": "CompactAs", - "anchor": "compactas" - }, - { - "depth": 3, - "title": "HasCompact", - "anchor": "hascompact" - }, - { - "depth": 3, - "title": "EncodeLike", - "anchor": "encodelike" - }, - { - "depth": 3, - "title": "Data Types", - "anchor": "data-types" - }, - { - "depth": 2, - "title": "Encode and Decode Rust Trait Implementations", - "anchor": "encode-and-decode-rust-trait-implementations" - }, - { - "depth": 2, - "title": "SCALE Codec Libraries", - "anchor": "scale-codec-libraries" - } - ], - "stats": { - "chars": 13629, - "words": 1314, - "headings": 10, - "estimated_token_count_total": 3213 - }, - "hash": "sha256:e448294b6e52291ac0add5fa6533572814e6cd27af42bdaccc2000b86f52d775", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-interoperability", - "title": "Interoperability", - "slug": "polkadot-protocol-parachain-basics-interoperability", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-interoperability.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/interoperability/", - "preview": "Interoperability lies at the heart of the Polkadot ecosystem, enabling communication and collaboration across a diverse range of blockchains. By bridging the gaps between parachains, relay chains, and even external networks, Polkadot unlocks the potential for truly decentralized applications, efficient resource sharing, and scalable solutions.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Why Interoperability Matters", - "anchor": "why-interoperability-matters" - }, - { - "depth": 2, - "title": "Key Mechanisms for Interoperability", - "anchor": "key-mechanisms-for-interoperability" - }, - { - "depth": 3, - "title": "Cross-Consensus Messaging (XCM): The Backbone of Communication", - "anchor": "cross-consensus-messaging-xcm-the-backbone-of-communication" - }, - { - "depth": 3, - "title": "Bridges: Connecting External Networks", - "anchor": "bridges-connecting-external-networks" - }, - { - "depth": 2, - "title": "The Polkadot Advantage", - "anchor": "the-polkadot-advantage" - }, - { - "depth": 2, - "title": "Looking Ahead", - "anchor": "looking-ahead" - } - ], - "stats": { - "chars": 4657, - "words": 588, - "headings": 7, - "estimated_token_count_total": 780 - }, - "hash": "sha256:077e7e5bfc9509cf09f455959a5da7a74b7af69836b3c4b334692f32e306ddf1", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-networks", - "title": "Networks", - "slug": "polkadot-protocol-parachain-basics-networks", - "categories": [ - "Basics", - "Polkadot Protocol", - "Networks" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-networks.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/networks/", - "preview": "The Polkadot ecosystem is built on a robust set of networks designed to enable secure and scalable development. Whether you are testing new features or deploying to live production, Polkadot offers several layers of networks tailored for each stage of the development process. From local environments to experimental networks like Kusama and community-run TestNets such as Paseo, developers can thoroughly test, iterate, and validate their applications. This guide will introduce you to Polkadot's va", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Network Overview", - "anchor": "network-overview" - }, - { - "depth": 2, - "title": "Polkadot Development Networks", - "anchor": "polkadot-development-networks" - }, - { - "depth": 2, - "title": "Kusama Network", - "anchor": "kusama-network" - }, - { - "depth": 2, - "title": "Test Networks", - "anchor": "test-networks" - }, - { - "depth": 3, - "title": "Westend", - "anchor": "westend" - }, - { - "depth": 3, - "title": "Paseo", - "anchor": "paseo" - }, - { - "depth": 2, - "title": "Local Test Networks", - "anchor": "local-test-networks" - }, - { - "depth": 3, - "title": "Zombienet", - "anchor": "zombienet" - }, - { - "depth": 3, - "title": "Chopsticks", - "anchor": "chopsticks" - } - ], - "stats": { - "chars": 7834, - "words": 1111, - "headings": 10, - "estimated_token_count_total": 1473 - }, - "hash": "sha256:695c624a1d7a3ed6fea0f4f5c19bb2100be986cec29ba58edb4598b9e9b98494", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-node-and-runtime", - "title": "Node and Runtime", - "slug": "polkadot-protocol-parachain-basics-node-and-runtime", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-node-and-runtime.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/node-and-runtime/", - "preview": "Every blockchain platform relies on a decentralized network of computers, called nodes, that communicate with each other about transactions and blocks. In this context, a node refers to the software running on the connected devices rather than the physical or virtual machines in the network.", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Architectural Principles", - "anchor": "architectural-principles" - }, - { - "depth": 3, - "title": "Advantages of this Architecture", - "anchor": "advantages-of-this-architecture" - }, - { - "depth": 2, - "title": "Node (Client)", - "anchor": "node-client" - }, - { - "depth": 2, - "title": "Runtime", - "anchor": "runtime" - }, - { - "depth": 3, - "title": "Characteristics", - "anchor": "characteristics" - }, - { - "depth": 3, - "title": "Key Functions", - "anchor": "key-functions" - }, - { - "depth": 2, - "title": "Communication Between Node and Runtime", - "anchor": "communication-between-node-and-runtime" - }, - { - "depth": 3, - "title": "Runtime APIs", - "anchor": "runtime-apis" - }, - { - "depth": 3, - "title": "Host Functions", - "anchor": "host-functions" - } - ], - "stats": { - "chars": 4937, - "words": 628, - "headings": 10, - "estimated_token_count_total": 914 - }, - "hash": "sha256:8122e21c149d0863cfe3b37fc5606bcdb91668e9d265f0f05451a61ff70e4e93", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-parachain-basics-randomness", - "title": "Randomness", - "slug": "polkadot-protocol-parachain-basics-randomness", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-parachain-basics-randomness.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/parachain-basics/randomness/", - "preview": "Randomness is crucial in Proof of Stake (PoS) blockchains to ensure a fair and unpredictable distribution of validator duties. However, computers are inherently deterministic, meaning the same input always produces the same output. What we typically refer to as \"random\" numbers on a computer are actually pseudo-random. These numbers rely on an initial \"seed,\" which can come from external sources like [atmospheric noise](https://www.random.org/randomness/){target=\\_blank}, [heart rates](https://m", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "VRF", - "anchor": "vrf" - }, - { - "depth": 3, - "title": "How VRF Works", - "anchor": "how-vrf-works" - }, - { - "depth": 2, - "title": "RANDAO", - "anchor": "randao" - }, - { - "depth": 2, - "title": "VDFs", - "anchor": "vdfs" - }, - { - "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" - } - ], - "stats": { - "chars": 6541, - "words": 1008, - "headings": 6, - "estimated_token_count_total": 1394 - }, - "hash": "sha256:217a79109aff1607594a0238fd91bfa812827620887c4f063c7e0a7a37f967d6", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-smart-contract-basics-accounts", - "title": "Accounts in Asset Hub Smart Contracts", - "slug": "polkadot-protocol-smart-contract-basics-accounts", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics-accounts.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/accounts/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Address Types and Mappings", - "anchor": "address-types-and-mappings" - }, - { - "depth": 3, - "title": "Ethereum to Polkadot Mapping", - "anchor": "ethereum-to-polkadot-mapping" - }, - { - "depth": 3, - "title": "Polkadot to Ethereum Mapping", - "anchor": "polkadot-to-ethereum-mapping" - }, - { - "depth": 3, - "title": "Account Mapping for Native Polkadot Accounts", - "anchor": "account-mapping-for-native-polkadot-accounts" - }, - { - "depth": 2, - "title": "Account Registration", - "anchor": "account-registration" - }, - { - "depth": 2, - "title": "Fallback Accounts", - "anchor": "fallback-accounts" - }, - { - "depth": 2, - "title": "Contract Address Generation", - "anchor": "contract-address-generation" - }, - { - "depth": 2, - "title": "Security Considerations", - "anchor": "security-considerations" - } - ], - "stats": { - "chars": 8538, - "words": 1141, - "headings": 9, - "estimated_token_count_total": 1822 - }, - "hash": "sha256:db2b1806153242680043ced536f64fc8a2ed3c09adc1bec5aa287168b48e0994", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-smart-contract-basics-blocks-transactions-fees", - "title": "Transactions and Fees on Asset Hub", - "slug": "polkadot-protocol-smart-contract-basics-blocks-transactions-fees", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics-blocks-transactions-fees.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/blocks-transactions-fees/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Smart Contract Blocks", - "anchor": "smart-contract-blocks" - }, - { - "depth": 2, - "title": "Smart Contract Transactions", - "anchor": "smart-contract-transactions" - }, - { - "depth": 3, - "title": "EVM Transaction Types", - "anchor": "evm-transaction-types" - }, - { - "depth": 2, - "title": "Fees and Gas", - "anchor": "fees-and-gas" - }, - { - "depth": 3, - "title": "Gas Model Overview", - "anchor": "gas-model-overview" - }, - { - "depth": 3, - "title": "Fee Components", - "anchor": "fee-components" - }, - { - "depth": 3, - "title": "Gas Calculation and Conversion", - "anchor": "gas-calculation-and-conversion" - } - ], - "stats": { - "chars": 6361, - "words": 789, - "headings": 8, - "estimated_token_count_total": 1178 - }, - "hash": "sha256:9a6b3fa6c005d75c25f0f683b7d8c3b65891454743b794c12b005f910b81609c", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-smart-contract-basics-evm-vs-polkavm", - "title": "EVM vs PolkaVM", - "slug": "polkadot-protocol-smart-contract-basics-evm-vs-polkavm", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics-evm-vs-polkavm.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/evm-vs-polkavm/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Core Virtual Machine Architecture", - "anchor": "core-virtual-machine-architecture" - }, - { - "depth": 3, - "title": "High-Level Architecture Comparison", - "anchor": "high-level-architecture-comparison" - }, - { - "depth": 2, - "title": "Gas Model", - "anchor": "gas-model" - }, - { - "depth": 3, - "title": "Dynamic Gas Value Scaling", - "anchor": "dynamic-gas-value-scaling" - }, - { - "depth": 3, - "title": "Multi-Dimensional Resource Metering", - "anchor": "multi-dimensional-resource-metering" - }, - { - "depth": 2, - "title": "Memory Management", - "anchor": "memory-management" - }, - { - "depth": 3, - "title": "Current Memory Limits", - "anchor": "current-memory-limits" - }, - { - "depth": 2, - "title": "Account Management - Existential Deposit", - "anchor": "account-management-existential-deposit" - }, - { - "depth": 3, - "title": "Account Management Comparison", - "anchor": "account-management-comparison" - }, - { - "depth": 2, - "title": "Contract Deployment", - "anchor": "contract-deployment" - }, - { - "depth": 2, - "title": "Solidity and YUL IR Translation Incompatibilities", - "anchor": "solidity-and-yul-ir-translation-incompatibilities" - }, - { - "depth": 3, - "title": "Contract Code Structure", - "anchor": "contract-code-structure" - }, - { - "depth": 3, - "title": "Solidity-Specific Differences", - "anchor": "solidity-specific-differences" - }, - { - "depth": 3, - "title": "YUL Function Translation Differences", - "anchor": "yul-function-translation-differences" - }, - { - "depth": 3, - "title": "Unsupported Operations", - "anchor": "unsupported-operations" - }, - { - "depth": 3, - "title": "Compilation Pipeline Considerations", - "anchor": "compilation-pipeline-considerations" - }, - { - "depth": 3, - "title": "Memory Pointer Limitations", - "anchor": "memory-pointer-limitations" - } - ], - "stats": { - "chars": 27673, - "words": 3392, - "headings": 18, - "estimated_token_count_total": 5305 - }, - "hash": "sha256:fe651be49fe0a9ae899b2cbf9c663325f407718dc63f1d2c6a2dc4931be751fa", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-smart-contract-basics-networks", - "title": "Networks for Polkadot Hub Smart Contracts", - "slug": "polkadot-protocol-smart-contract-basics-networks", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics-networks.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/networks/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Network Overview", - "anchor": "network-overview" - }, - { - "depth": 2, - "title": "Local Development", - "anchor": "local-development" - }, - { - "depth": 2, - "title": "Test Networks", - "anchor": "test-networks" - }, - { - "depth": 3, - "title": "Passet Hub", - "anchor": "passet-hub" - }, - { - "depth": 3, - "title": "Westend Hub", - "anchor": "westend-hub" - }, - { - "depth": 2, - "title": "Production Networks", - "anchor": "production-networks" - }, - { - "depth": 3, - "title": "Polkadot Hub", - "anchor": "polkadot-hub" - }, - { - "depth": 3, - "title": "Kusama Hub", - "anchor": "kusama-hub" - } - ], - "stats": { - "chars": 5108, - "words": 696, - "headings": 9, - "estimated_token_count_total": 891 - }, - "hash": "sha256:b5acdc9acf0e44836b8a4518155eba7d16cc3b103c557a00970ffb1c44c3e9f6", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-smart-contract-basics-overview", - "title": "Smart Contracts Basics Overview", - "slug": "polkadot-protocol-smart-contract-basics-overview", - "categories": [ - "Basics", - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics-overview.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/overview/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", - "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Smart Contracts Versus Parachains", - "anchor": "smart-contracts-versus-parachains" - }, - { - "depth": 2, - "title": "Building a Smart Contract", - "anchor": "building-a-smart-contract" - }, - { - "depth": 3, - "title": "PolkaVM Contracts", - "anchor": "polkavm-contracts" - }, - { - "depth": 3, - "title": "EVM Contracts", - "anchor": "evm-contracts" - }, - { - "depth": 3, - "title": "Wasm Contracts", - "anchor": "wasm-contracts" - } - ], - "stats": { - "chars": 10854, - "words": 1559, - "headings": 6, - "estimated_token_count_total": 2550 - }, - "hash": "sha256:e2cf14bcb483308f73a80c8e8871ce1a86fa694576d2e6e51beafc24488f4d58", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol-smart-contract-basics", - "title": "Smart Contract Basics", - "slug": "polkadot-protocol-smart-contract-basics", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-smart-contract-basics.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/smart-contract-basics/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Gain a deep understanding of smart contracts on Polkadot, from execution environments to transaction mechanics.", - "outline": [ - { - "depth": 2, - "title": "Key Topics", - "anchor": "key-topics" - }, - { - "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 1110, - "words": 136, - "headings": 2, - "estimated_token_count_total": 148 - }, - "hash": "sha256:e8dac01e89b7aac4b887e962e91084c253f5ea25c1abc3a56355390d0c3201c8", - "token_estimator": "heuristic-v1" - }, - { - "id": "polkadot-protocol", - "title": "Learn About the Polkadot Protocol", - "slug": "polkadot-protocol", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol.md", - "html_url": "https://docs.polkadot.com/polkadot-protocol/", - "preview": "The Polkadot protocol is designed to enable scalable, secure, and interoperable networks. It introduces a unique multichain architecture that allows independent blockchains, known as parachains, to operate seamlessly while benefiting from the shared security of the relay chain. Polkadot’s decentralized governance ensures that network upgrades and decisions are community-driven, while its cross-chain messaging and interoperability features make it a hub for multichain applications.", - "outline": [ - { - "depth": 2, - "title": "In This Section", - "anchor": "in-this-section" - } - ], - "stats": { - "chars": 1170, - "words": 150, - "headings": 1, - "estimated_token_count_total": 12 - }, - "hash": "sha256:6992c9a2d1b315b64d9782880105cf2d436750249a84577aceb95cc213863009", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "reference-glossary", - "title": "Glossary", - "slug": "reference-glossary", - "categories": [ - "Reference" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-glossary.md", - "html_url": "https://docs.polkadot.com/reference/glossary/", - "preview": "Key definitions, concepts, and terminology specific to the Polkadot ecosystem are included here.", - "outline": [ - { - "depth": 2, - "title": "Authority", - "anchor": "authority" - }, - { - "depth": 2, - "title": "Authority Round (Aura)", - "anchor": "authority-round-aura" - }, - { - "depth": 2, - "title": "Blind Assignment of Blockchain Extension (BABE)", - "anchor": "blind-assignment-of-blockchain-extension-babe" - }, - { - "depth": 2, - "title": "Block Author", - "anchor": "block-author" - }, - { - "depth": 2, - "title": "Byzantine Fault Tolerance (BFT)", - "anchor": "byzantine-fault-tolerance-bft" - }, - { - "depth": 3, - "title": "Byzantine Failure", - "anchor": "byzantine-failure" - }, - { - "depth": 3, - "title": "Practical Byzantine Fault Tolerance (pBFT)", - "anchor": "practical-byzantine-fault-tolerance-pbft" - }, - { - "depth": 3, - "title": "Preimage", - "anchor": "preimage" - }, - { - "depth": 2, - "title": "Call", - "anchor": "call" - }, - { - "depth": 2, - "title": "Chain Specification", - "anchor": "chain-specification" - }, - { - "depth": 2, - "title": "Collator", - "anchor": "collator" - }, - { - "depth": 2, - "title": "Collective", - "anchor": "collective" - }, - { - "depth": 2, - "title": "Consensus", - "anchor": "consensus" - }, - { - "depth": 2, - "title": "Consensus Algorithm", - "anchor": "consensus-algorithm" - }, - { - "depth": 2, - "title": "Consensus Engine", - "anchor": "consensus-engine" - }, - { - "depth": 2, - "title": "Coretime", - "anchor": "coretime" - }, - { - "depth": 2, - "title": "Development Phrase", - "anchor": "development-phrase" - }, - { - "depth": 2, - "title": "Digest", - "anchor": "digest" - }, - { - "depth": 2, - "title": "Dispatchable", - "anchor": "dispatchable" - }, - { - "depth": 2, - "title": "Events", - "anchor": "events" - }, - { - "depth": 2, - "title": "Executor", - "anchor": "executor" - }, - { - "depth": 2, - "title": "Existential Deposit", - "anchor": "existential-deposit" - }, - { - "depth": 2, - "title": "Extrinsic", - "anchor": "extrinsic" - }, - { - "depth": 2, - "title": "Fork Choice Rule/Strategy", - "anchor": "fork-choice-rulestrategy" - }, - { - "depth": 2, - "title": "FRAME (Framework for Runtime Aggregation of Modularized Entities)", - "anchor": "frame-framework-for-runtime-aggregation-of-modularized-entities" - }, - { - "depth": 2, - "title": "Full Node", - "anchor": "full-node" - }, - { - "depth": 2, - "title": "Genesis Configuration", - "anchor": "genesis-configuration" - }, - { - "depth": 2, - "title": "GRANDPA", - "anchor": "grandpa" - }, - { - "depth": 2, - "title": "Header", - "anchor": "header" - }, - { - "depth": 2, - "title": "Hybrid Consensus", - "anchor": "hybrid-consensus" - }, - { - "depth": 2, - "title": "Inherent Transactions", - "anchor": "inherent-transactions" - }, - { - "depth": 2, - "title": "JSON-RPC", - "anchor": "json-rpc" - }, - { - "depth": 2, - "title": "Keystore", - "anchor": "keystore" - }, - { - "depth": 2, - "title": "Kusama", - "anchor": "kusama" - }, - { - "depth": 2, - "title": "libp2p", - "anchor": "libp2p" - }, - { - "depth": 2, - "title": "Light Client", - "anchor": "light-client" - }, - { - "depth": 2, - "title": "Metadata", - "anchor": "metadata" - }, - { - "depth": 2, - "title": "Nominated Proof of Stake (NPoS)", - "anchor": "nominated-proof-of-stake-npos" - }, - { - "depth": 2, - "title": "Oracle", - "anchor": "oracle" - }, - { - "depth": 2, - "title": "Origin", - "anchor": "origin" - }, - { - "depth": 2, - "title": "Pallet", - "anchor": "pallet" - }, - { - "depth": 2, - "title": "Parachain", - "anchor": "parachain" - }, - { - "depth": 2, - "title": "Paseo", - "anchor": "paseo" - }, - { - "depth": 2, - "title": "Polkadot", - "anchor": "polkadot" - }, - { - "depth": 2, - "title": "Polkadot Cloud", - "anchor": "polkadot-cloud" - }, - { - "depth": 2, - "title": "Polkadot Hub", - "anchor": "polkadot-hub" - }, - { - "depth": 2, - "title": "PolkaVM", - "anchor": "polkavm" - }, - { - "depth": 2, - "title": "Relay Chain", - "anchor": "relay-chain" - }, - { - "depth": 2, - "title": "Rococo", - "anchor": "rococo" - }, - { - "depth": 2, - "title": "Runtime", - "anchor": "runtime" - }, + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-interoperability.md", + "html_url": "https://docs.polkadot.com/reference/parachains/interoperability/", + "preview": "Interoperability lies at the heart of the Polkadot ecosystem, enabling communication and collaboration across a diverse range of blockchains. By bridging the gaps between parachains, relay chains, and even external networks, Polkadot unlocks the potential for truly decentralized applications, efficient resource sharing, and scalable solutions.", + "outline": [ { "depth": 2, - "title": "Slot", - "anchor": "slot" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Sovereign Account", - "anchor": "sovereign-account" + "title": "Why Interoperability Matters", + "anchor": "why-interoperability-matters" }, { "depth": 2, - "title": "SS58 Address Format", - "anchor": "ss58-address-format" + "title": "Key Mechanisms for Interoperability", + "anchor": "key-mechanisms-for-interoperability" }, { - "depth": 2, - "title": "State Transition Function (STF)", - "anchor": "state-transition-function-stf" + "depth": 3, + "title": "Cross-Consensus Messaging (XCM): The Backbone of Communication", + "anchor": "cross-consensus-messaging-xcm-the-backbone-of-communication" }, { - "depth": 2, - "title": "Storage Item", - "anchor": "storage-item" + "depth": 3, + "title": "Bridges: Connecting External Networks", + "anchor": "bridges-connecting-external-networks" }, { "depth": 2, - "title": "Substrate", - "anchor": "substrate" + "title": "The Polkadot Advantage", + "anchor": "the-polkadot-advantage" }, { "depth": 2, - "title": "Transaction", - "anchor": "transaction" - }, + "title": "Looking Ahead", + "anchor": "looking-ahead" + } + ], + "stats": { + "chars": 4635, + "words": 584, + "headings": 7, + "estimated_token_count_total": 772 + }, + "hash": "sha256:11bb4f113bdda5852a3115e64d5ba47f8eccd4e3619a05ad960ab3a541f31346", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-parachains-networks", + "title": "Networks", + "slug": "reference-parachains-networks", + "categories": [ + "Basics", + "Polkadot Protocol", + "Networks" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-networks.md", + "html_url": "https://docs.polkadot.com/reference/parachains/networks/", + "preview": "The Polkadot ecosystem is built on a robust set of networks designed to enable secure and scalable development. Whether you are testing new features or deploying to live production, Polkadot offers several layers of networks tailored for each stage of the development process. From local environments to experimental networks like Kusama and community-run TestNets such as Paseo, developers can thoroughly test, iterate, and validate their applications. This guide will introduce you to Polkadot's va", + "outline": [ { "depth": 2, - "title": "Transaction Era", - "anchor": "transaction-era" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Trie (Patricia Merkle Tree)", - "anchor": "trie-patricia-merkle-tree" + "title": "Network Overview", + "anchor": "network-overview" }, { "depth": 2, - "title": "Validator", - "anchor": "validator" + "title": "Polkadot Development Networks", + "anchor": "polkadot-development-networks" }, { "depth": 2, - "title": "WebAssembly (Wasm)", - "anchor": "webassembly-wasm" + "title": "Kusama Network", + "anchor": "kusama-network" }, { "depth": 2, - "title": "Weight", - "anchor": "weight" + "title": "Test Networks", + "anchor": "test-networks" }, { - "depth": 2, + "depth": 3, "title": "Westend", "anchor": "westend" - } - ], - "stats": { - "chars": 24739, - "words": 3626, - "headings": 63, - "estimated_token_count_total": 5273 - }, - "hash": "sha256:40bd67811e7eabc79ca5d105eae388b19380d9f035022da17fc0d6bb173c817c", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "reference-governance-origins-tracks", - "title": "Origins and Tracks", - "slug": "reference-governance-origins-tracks", - "categories": [ - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-governance-origins-tracks.md", - "html_url": "https://docs.polkadot.com/reference/governance/origins-tracks/", - "preview": "Polkadot's OpenGov system empowers decentralized decision-making and active community participation by tailoring the governance process to the impact of proposed changes. Through a system of origins and tracks, OpenGov ensures that every referendum receives the appropriate scrutiny, balancing security, inclusivity, and efficiency.", - "outline": [ + }, { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "depth": 3, + "title": "Paseo", + "anchor": "paseo" }, { "depth": 2, - "title": "Origins", - "anchor": "origins" + "title": "Local Test Networks", + "anchor": "local-test-networks" }, { - "depth": 2, - "title": "Tracks", - "anchor": "tracks" + "depth": 3, + "title": "Zombienet", + "anchor": "zombienet" }, { - "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "depth": 3, + "title": "Chopsticks", + "anchor": "chopsticks" } ], "stats": { - "chars": 3333, - "words": 469, - "headings": 4, - "estimated_token_count_total": 631 + "chars": 7834, + "words": 1111, + "headings": 10, + "estimated_token_count_total": 1473 }, - "hash": "sha256:baba9dd41091b792d09005d55d3df0bf65b35f42b40ebe63caf425a0978a22b0", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:e49e063a2cc0fb5a48c6cdc3de266bb6e025a006940fea8e90cc4d5f9884900f", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-accounts", - "title": "Polkadot SDK Accounts", - "slug": "reference-parachains-accounts", + "id": "reference-parachains-node-and-runtime", + "title": "Node and Runtime", + "slug": "reference-parachains-node-and-runtime", "categories": [ "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-accounts.md", - "html_url": "https://docs.polkadot.com/reference/parachains/accounts/", - "preview": "Accounts are essential for managing identity, transactions, and governance on the network in the Polkadot SDK. Understanding these components is critical for seamless development and operation on the network, whether you're building or interacting with Polkadot-based chains.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-node-and-runtime.md", + "html_url": "https://docs.polkadot.com/reference/parachains/node-and-runtime/", + "preview": "Every blockchain platform relies on a decentralized network of computers, called nodes, that communicate with each other about transactions and blocks. In this context, a node refers to the software running on the connected devices rather than the physical or virtual machines in the network.", "outline": [ { "depth": 2, @@ -11046,96 +8432,122 @@ }, { "depth": 2, - "title": "Account Data Structure", - "anchor": "account-data-structure" - }, - { - "depth": 3, - "title": "Account", - "anchor": "account" + "title": "Architectural Principles", + "anchor": "architectural-principles" }, { "depth": 3, - "title": "Account Info", - "anchor": "account-info" + "title": "Advantages of this Architecture", + "anchor": "advantages-of-this-architecture" }, { - "depth": 3, - "title": "Account Reference Counters", - "anchor": "account-reference-counters" + "depth": 2, + "title": "Node (Client)", + "anchor": "node-client" }, { "depth": 2, - "title": "Account Balance Types", - "anchor": "account-balance-types" + "title": "Runtime", + "anchor": "runtime" }, { "depth": 3, - "title": "Balance Types", - "anchor": "balance-types" + "title": "Characteristics", + "anchor": "characteristics" }, { "depth": 3, - "title": "Locks", - "anchor": "locks" + "title": "Key Functions", + "anchor": "key-functions" + }, + { + "depth": 2, + "title": "Communication Between Node and Runtime", + "anchor": "communication-between-node-and-runtime" }, { "depth": 3, - "title": "Balance Types on Polkadot.js", - "anchor": "balance-types-on-polkadotjs" + "title": "Runtime APIs", + "anchor": "runtime-apis" }, + { + "depth": 3, + "title": "Host Functions", + "anchor": "host-functions" + } + ], + "stats": { + "chars": 4937, + "words": 628, + "headings": 10, + "estimated_token_count_total": 914 + }, + "hash": "sha256:8122e21c149d0863cfe3b37fc5606bcdb91668e9d265f0f05451a61ff70e4e93", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-parachains-randomness", + "title": "Randomness", + "slug": "reference-parachains-randomness", + "categories": [ + "Basics", + "Polkadot Protocol" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-randomness.md", + "html_url": "https://docs.polkadot.com/reference/parachains/randomness/", + "preview": "Randomness is crucial in Proof of Stake (PoS) blockchains to ensure a fair and unpredictable distribution of validator duties. However, computers are inherently deterministic, meaning the same input always produces the same output. What we typically refer to as \"random\" numbers on a computer are actually pseudo-random. These numbers rely on an initial \"seed,\" which can come from external sources like [atmospheric noise](https://www.random.org/randomness/){target=\\_blank}, [heart rates](https://m", + "outline": [ { "depth": 2, - "title": "Address Formats", - "anchor": "address-formats" + "title": "Introduction", + "anchor": "introduction" }, { - "depth": 3, - "title": "Basic Format", - "anchor": "basic-format" + "depth": 2, + "title": "VRF", + "anchor": "vrf" }, { "depth": 3, - "title": "Address Type", - "anchor": "address-type" + "title": "How VRF Works", + "anchor": "how-vrf-works" }, { - "depth": 3, - "title": "Address Length", - "anchor": "address-length" + "depth": 2, + "title": "RANDAO", + "anchor": "randao" }, { - "depth": 3, - "title": "Checksum Types", - "anchor": "checksum-types" + "depth": 2, + "title": "VDFs", + "anchor": "vdfs" }, { - "depth": 3, - "title": "Validating Addresses", - "anchor": "validating-addresses" + "depth": 2, + "title": "Additional Resources", + "anchor": "additional-resources" } ], "stats": { - "chars": 29604, - "words": 4194, - "headings": 15, - "estimated_token_count_total": 6507 + "chars": 6503, + "words": 1005, + "headings": 6, + "estimated_token_count_total": 1388 }, - "hash": "sha256:0104a9132a69345a2faac37fca0e2853a2ded1efb009511a83a98d44509ab887", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:c7d8a5a4263fd21af458ab0bd102377104affdf2431b4fe74eeff4ebe62a4a81", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-blocks-transactions-fees-blocks", - "title": "Blocks", - "slug": "reference-parachains-blocks-transactions-fees-blocks", + "id": "reference-parachains", + "title": "Parachains Overview", + "slug": "reference-parachains", "categories": [ "Basics", - "Polkadot Protocol" + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-blocks-transactions-fees-blocks.md", - "html_url": "https://docs.polkadot.com/reference/parachains/blocks-transactions-fees/blocks/", - "preview": "In the Polkadot SDK, blocks are fundamental to the functioning of the blockchain, serving as containers for [transactions](/reference/parachains/blocks-transactions-fees/transactions/){target=\\_blank} and changes to the chain's state. Blocks consist of headers and an array of transactions, ensuring the integrity and validity of operations on the network. This guide explores the essential components of a block, the process of block production, and how blocks are validated and imported across the", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains.md", + "html_url": "https://docs.polkadot.com/reference/parachains/", + "preview": "A parachain is a specialized blockchain that connects to the Polkadot relay chain, benefiting from shared security, interoperability, and scalability. Parachains are built using the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\\_blank}, a powerful toolkit written in Rust that provides everything needed to create custom blockchain logic while integrating seamlessly with the Polkadot network.", "outline": [ { "depth": 2, @@ -11144,159 +8556,175 @@ }, { "depth": 2, - "title": "What is a Block?", - "anchor": "what-is-a-block" - }, - { - "depth": 2, - "title": "Block Production", - "anchor": "block-production" + "title": "Polkadot SDK: Parachain Architecture", + "anchor": "polkadot-sdk-parachain-architecture" }, { "depth": 3, - "title": "Initialize Block", - "anchor": "initialize-block" + "title": "Substrate: The Foundation", + "anchor": "substrate-the-foundation" }, { "depth": 3, - "title": "Finalize Block", - "anchor": "finalize-block" - }, - { - "depth": 2, - "title": "Block Authoring and Import", - "anchor": "block-authoring-and-import" + "title": "FRAME: Building Blocks for Your Runtime", + "anchor": "frame-building-blocks-for-your-runtime" }, { "depth": 3, - "title": "Block Import Queue", - "anchor": "block-import-queue" + "title": "Cumulus: Parachain-Specific Functionality", + "anchor": "cumulus-parachain-specific-functionality" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 6252, - "words": 910, - "headings": 8, - "estimated_token_count_total": 1395 + "chars": 8495, + "words": 1029, + "headings": 6, + "estimated_token_count_total": 1759 }, - "hash": "sha256:424783c102bea5dae5b8749635858c6c59055563442a98f57521f0027dafa8d3", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:ecb0d9459e08920db7d2d59dc7c01aba7a91ce8c9e39256bd0c3efa473dbaa17", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-blocks-transactions-fees-fees", - "title": "Transactions Weights and Fees", - "slug": "reference-parachains-blocks-transactions-fees-fees", + "id": "reference-polkadot-hub-assets-and-smart-contracts", + "title": "Asset Hub", + "slug": "reference-polkadot-hub-assets-and-smart-contracts", "categories": [ - "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-blocks-transactions-fees-fees.md", - "html_url": "https://docs.polkadot.com/reference/parachains/blocks-transactions-fees/fees/", - "preview": "When transactions are executed, or data is stored on-chain, the activity changes the chain's state and consumes blockchain resources. Because the resources available to a blockchain are limited, managing how operations on-chain consume them is important. In addition to being limited in practical terms, such as storage capacity, blockchain resources represent a potential attack vector for malicious users. For example, a malicious user might attempt to overload the network with messages to stop th", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-assets-and-smart-contracts.md", + "html_url": "https://docs.polkadot.com/reference/polkadot-hub/assets-and-smart-contracts/", + "preview": "The Asset Hub is a critical component in the Polkadot ecosystem, enabling the management of fungible and non-fungible assets across the network. Since the relay chain focuses on maintaining security and consensus without direct asset management, Asset Hub provides a streamlined platform for creating, managing, and using on-chain assets in a fee-efficient manner. This guide outlines the core features of Asset Hub, including how it handles asset operations, cross-chain transfers, and asset integra", "outline": [ { "depth": 2, - "title": "Introductions", - "anchor": "introductions" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "How Fees are Calculated", - "anchor": "how-fees-are-calculated" + "title": "Assets Basics", + "anchor": "assets-basics" }, { "depth": 2, - "title": "Using the Transaction Payment Pallet", - "anchor": "using-the-transaction-payment-pallet" + "title": "Assets Pallet", + "anchor": "assets-pallet" }, { "depth": 3, - "title": "Understanding the Inclusion Fee", - "anchor": "understanding-the-inclusion-fee" + "title": "Key Features", + "anchor": "key-features" }, { "depth": 3, - "title": "Accounts with an Insufficient Balance", - "anchor": "accounts-with-an-insufficient-balance" + "title": "Main Functions", + "anchor": "main-functions" }, { "depth": 3, - "title": "Fee Multipliers", - "anchor": "fee-multipliers" + "title": "Querying Functions", + "anchor": "querying-functions" + }, + { + "depth": 3, + "title": "Permission Models and Roles", + "anchor": "permission-models-and-roles" + }, + { + "depth": 3, + "title": "Asset Freezing", + "anchor": "asset-freezing" + }, + { + "depth": 3, + "title": "Non-Custodial Transfers (Approval API)", + "anchor": "non-custodial-transfers-approval-api" }, { "depth": 2, - "title": "Transactions with Special Requirements", - "anchor": "transactions-with-special-requirements" + "title": "Foreign Assets", + "anchor": "foreign-assets" + }, + { + "depth": 3, + "title": "Handling Foreign Assets", + "anchor": "handling-foreign-assets" }, { "depth": 2, - "title": "Default Weight Annotations", - "anchor": "default-weight-annotations" + "title": "Integration", + "anchor": "integration" }, { "depth": 3, - "title": "Weights and Database Read/Write Operations", - "anchor": "weights-and-database-readwrite-operations" + "title": "API Sidecar", + "anchor": "api-sidecar" }, { "depth": 3, - "title": "Dispatch Classes", - "anchor": "dispatch-classes" + "title": "TxWrapper", + "anchor": "txwrapper" }, { "depth": 3, - "title": "Dynamic Weights", - "anchor": "dynamic-weights" + "title": "Parachain Node", + "anchor": "parachain-node" }, { "depth": 2, - "title": "Post Dispatch Weight Correction", - "anchor": "post-dispatch-weight-correction" + "title": "XCM Transfer Monitoring", + "anchor": "xcm-transfer-monitoring" }, { - "depth": 2, - "title": "Custom Fees", - "anchor": "custom-fees" + "depth": 3, + "title": "Monitor XCM Deposits", + "anchor": "monitor-xcm-deposits" }, { "depth": 3, - "title": "Custom Weights", - "anchor": "custom-weights" + "title": "Track XCM Information Back to the Source", + "anchor": "track-xcm-information-back-to-the-source" + }, + { + "depth": 3, + "title": "Practical Monitoring Examples", + "anchor": "practical-monitoring-examples" + }, + { + "depth": 3, + "title": "Monitor for Failed XCM Transfers", + "anchor": "monitor-for-failed-xcm-transfers" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 20800, - "words": 2917, - "headings": 15, - "estimated_token_count_total": 4464 + "chars": 18211, + "words": 2649, + "headings": 21, + "estimated_token_count_total": 3678 }, - "hash": "sha256:7d0c3fa7982b3e1843adb8f27422456397580b3a3eba5047b381da8517742536", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:3d10c04cffc5f737ff75b079d661c2c1904629d23ae1e415e64fd6ae4e98759e", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-blocks-transactions-fees-transactions", - "title": "Transactions", - "slug": "reference-parachains-blocks-transactions-fees-transactions", + "id": "reference-polkadot-hub-bridging", + "title": "Bridge Hub", + "slug": "reference-polkadot-hub-bridging", "categories": [ - "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-blocks-transactions-fees-transactions.md", - "html_url": "https://docs.polkadot.com/reference/parachains/blocks-transactions-fees/transactions/", - "preview": "Transactions are essential components of blockchain networks, enabling state changes and the execution of key operations. In the Polkadot SDK, transactions, often called extrinsics, come in multiple forms, including signed, unsigned, and inherent transactions.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-bridging.md", + "html_url": "https://docs.polkadot.com/reference/polkadot-hub/bridging/", + "preview": "The Bridge Hub system parachain plays a crucial role in facilitating trustless interactions between Polkadot, Kusama, Ethereum, and other blockchain ecosystems. By implementing on-chain light clients and supporting protocols like BEEFY and GRANDPA, Bridge Hub ensures seamless message transmission and state verification across chains. It also provides essential [pallets](/reference/glossary/#pallet){target=\\_blank} for sending and receiving messages, making it a cornerstone of Polkadot’s interope", "outline": [ { "depth": 2, @@ -11305,131 +8733,126 @@ }, { "depth": 2, - "title": "What Is a Transaction?", - "anchor": "what-is-a-transaction" - }, - { - "depth": 3, - "title": "Signed Transactions", - "anchor": "signed-transactions" + "title": "Trustless Bridging", + "anchor": "trustless-bridging" }, { - "depth": 3, - "title": "Unsigned Transactions", - "anchor": "unsigned-transactions" + "depth": 2, + "title": "Bridging Components", + "anchor": "bridging-components" }, { "depth": 3, - "title": "Inherent Transactions", - "anchor": "inherent-transactions" + "title": "Ethereum-Specific Support", + "anchor": "ethereum-specific-support" }, { "depth": 2, - "title": "Transaction Formats", - "anchor": "transaction-formats" + "title": "Deployed Bridges", + "anchor": "deployed-bridges" }, { - "depth": 3, - "title": "Types of Transaction Formats", - "anchor": "types-of-transaction-formats" - }, + "depth": 2, + "title": "Where to Go Next", + "anchor": "where-to-go-next" + } + ], + "stats": { + "chars": 5467, + "words": 776, + "headings": 6, + "estimated_token_count_total": 1220 + }, + "hash": "sha256:86734ba8bcdea7913f488edf666a6104bed0a18649d57abde82c149c41c2b871", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-polkadot-hub-collectives-and-daos", + "title": "Collectives Chain", + "slug": "reference-polkadot-hub-collectives-and-daos", + "categories": [ + "Polkadot Protocol" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-collectives-and-daos.md", + "html_url": "https://docs.polkadot.com/reference/polkadot-hub/collectives-and-daos/", + "preview": "Established through [Referendum 81](https://polkadot-old.polkassembly.io/referendum/81){target=\\_blank}, the Collectives chain operates as a dedicated parachain exclusive to the Polkadot network with no counterpart on Kusama. This specialized infrastructure provides a foundation for various on-chain governance groups essential to Polkadot's ecosystem.", + "outline": [ { - "depth": 3, - "title": "Signed Transaction Data Structure", - "anchor": "signed-transaction-data-structure" + "depth": 2, + "title": "Introduction", + "anchor": "introduction" }, { - "depth": 3, - "title": "Signed Extensions", - "anchor": "signed-extensions" - }, + "depth": 2, + "title": "Key Collectives", + "anchor": "key-collectives" + } + ], + "stats": { + "chars": 2288, + "words": 293, + "headings": 2, + "estimated_token_count_total": 424 + }, + "hash": "sha256:59ec351fbb8d3a392e90f4f5bf6b62f58b21d6d7a900c5e367e5d2e09ecb3aca", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-polkadot-hub-consensus-and-security-agile-coretime", + "title": "Agile Coretime", + "slug": "reference-polkadot-hub-consensus-and-security-agile-coretime", + "categories": [ + "Polkadot Protocol" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-agile-coretime.md", + "html_url": "https://docs.polkadot.com/reference/polkadot-hub/consensus-and-security/agile-coretime/", + "preview": "Agile Coretime is the [scheduling](https://en.wikipedia.org/wiki/Scheduling_(computing)){target=\\_blank} framework on Polkadot that lets parachains efficiently access cores, which comprise an active validator set tasked with parablock validation. As the first blockchain to enable a flexible scheduling system for blockspace production, Polkadot offers unparalleled adaptability for parachains.", + "outline": [ { "depth": 2, - "title": "Transaction Construction", - "anchor": "transaction-construction" - }, - { - "depth": 3, - "title": "Construct a Signed Transaction", - "anchor": "construct-a-signed-transaction" - }, - { - "depth": 3, - "title": "Transaction Encoding", - "anchor": "transaction-encoding" - }, - { - "depth": 3, - "title": "Customize Transaction Construction", - "anchor": "customize-transaction-construction" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Lifecycle of a Transaction", - "anchor": "lifecycle-of-a-transaction" - }, - { - "depth": 3, - "title": "Define Transaction Properties", - "anchor": "define-transaction-properties" - }, - { - "depth": 3, - "title": "Process on a Block Authoring Node", - "anchor": "process-on-a-block-authoring-node" - }, - { - "depth": 3, - "title": "Validate and Queue", - "anchor": "validate-and-queue" + "title": "Bulk Coretime", + "anchor": "bulk-coretime" }, { "depth": 3, - "title": "Transaction Ordering and Priority", - "anchor": "transaction-ordering-and-priority" + "title": "Coretime Interlacing", + "anchor": "coretime-interlacing" }, { "depth": 3, - "title": "Transaction Execution", - "anchor": "transaction-execution" - }, - { - "depth": 2, - "title": "Transaction Mortality", - "anchor": "transaction-mortality" - }, - { - "depth": 2, - "title": "Unique Identifiers for Extrinsics", - "anchor": "unique-identifiers-for-extrinsics" + "title": "Coretime Splitting", + "anchor": "coretime-splitting" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "On-Demand Coretime", + "anchor": "on-demand-coretime" } ], "stats": { - "chars": 23610, - "words": 3333, - "headings": 22, - "estimated_token_count_total": 4708 + "chars": 3028, + "words": 452, + "headings": 5, + "estimated_token_count_total": 619 }, - "hash": "sha256:547f062b248779f0b3e823778120c4f32e449937b6f270ddf97378bc6d795c62", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:00be43ac8d666bbe15c5c2fa5a5085697d0bb5a6f341ebbb943a209f0be355df", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-chain-data", - "title": "Chain Data", - "slug": "reference-parachains-chain-data", + "id": "reference-polkadot-hub-consensus-and-security-pos-consensus", + "title": "Proof of Stake Consensus", + "slug": "reference-polkadot-hub-consensus-and-security-pos-consensus", "categories": [ - "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-chain-data.md", - "html_url": "https://docs.polkadot.com/reference/parachains/chain-data/", - "preview": "Understanding and leveraging on-chain data is a fundamental aspect of blockchain development. Whether you're building frontend applications or backend systems, accessing and decoding runtime metadata is vital to interacting with the blockchain. This guide introduces you to the tools and processes for generating and retrieving metadata, explains its role in application development, and outlines the additional APIs available for interacting with a Polkadot node. By mastering these components, you", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-pos-consensus.md", + "html_url": "https://docs.polkadot.com/reference/polkadot-hub/consensus-and-security/pos-consensus/", + "preview": "Polkadot's Proof of Stake consensus model leverages a unique hybrid approach by design to promote decentralized and secure network operations. In traditional Proof of Stake (PoS) systems, a node's ability to validate transactions is tied to its token holdings, which can lead to centralization risks and limited validator participation. Polkadot addresses these concerns through its [Nominated Proof of Stake (NPoS)](/reference/glossary/#nominated-proof-of-stake-npos){target=\\_blank} model and a com", "outline": [ { "depth": 2, @@ -11438,116 +8861,86 @@ }, { "depth": 2, - "title": "Application Development", - "anchor": "application-development" - }, - { - "depth": 2, - "title": "Understand Metadata", - "anchor": "understand-metadata" + "title": "Nominated Proof of Stake", + "anchor": "nominated-proof-of-stake" }, { "depth": 2, - "title": "Expose Runtime Information as Metadata", - "anchor": "expose-runtime-information-as-metadata" + "title": "Hybrid Consensus", + "anchor": "hybrid-consensus" }, { "depth": 2, - "title": "Generate Metadata", - "anchor": "generate-metadata" + "title": "Block Production - BABE", + "anchor": "block-production-babe" }, { - "depth": 2, - "title": "Retrieve Runtime Metadata", - "anchor": "retrieve-runtime-metadata" + "depth": 3, + "title": "Validator Participation", + "anchor": "validator-participation" }, { "depth": 3, - "title": "Use Polkadot.js", - "anchor": "use-polkadotjs" + "title": "Additional Resources", + "anchor": "additional-resources" }, { - "depth": 3, - "title": "Use Curl", - "anchor": "use-curl" + "depth": 2, + "title": "Finality Gadget - GRANDPA", + "anchor": "finality-gadget-grandpa" }, { "depth": 3, - "title": "Use Subxt", - "anchor": "use-subxt" + "title": "Probabilistic vs. Provable Finality", + "anchor": "probabilistic-vs-provable-finality" }, { - "depth": 2, - "title": "Client Applications and Metadata", - "anchor": "client-applications-and-metadata" + "depth": 3, + "title": "Additional Resources", + "anchor": "additional-resources-2" }, { "depth": 2, - "title": "Metadata Format", - "anchor": "metadata-format" - }, - { - "depth": 3, - "title": "Pallets", - "anchor": "pallets" + "title": "Fork Choice", + "anchor": "fork-choice" }, { "depth": 3, - "title": "Extrinsic", - "anchor": "extrinsic" + "title": "Additional Resources", + "anchor": "additional-resources-3" }, { "depth": 2, - "title": "Included RPC APIs", - "anchor": "included-rpc-apis" + "title": "Bridging - BEEFY", + "anchor": "bridging-beefy" }, { - "depth": 2, + "depth": 3, "title": "Additional Resources", - "anchor": "additional-resources" + "anchor": "additional-resources-4" } ], "stats": { - "chars": 18650, - "words": 2216, - "headings": 15, - "estimated_token_count_total": 3774 - }, - "hash": "sha256:49238d1e9e2c33e0fcd3a84b5e30f0d3840d7d23a783b538875e0a23f38efc1d", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "reference-parachains-consensus-async-backing", - "title": "reference-parachains-consensus-async-backing", - "slug": "reference-parachains-consensus-async-backing", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-consensus-async-backing.md", - "html_url": "https://docs.polkadot.com/reference/parachains/consensus/async-backing/", - "preview": "TODO", - "outline": [], - "stats": { - "chars": 5, - "words": 1, - "headings": 0, - "estimated_token_count_total": 0 + "chars": 12753, + "words": 1834, + "headings": 13, + "estimated_token_count_total": 2526 }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:231fc555eefe5f910fb36e0c03945147d0fb235272850797391751f4444b0a9c", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-consensus-elastic-scaling", - "title": "Elastic Scaling", - "slug": "reference-parachains-consensus-elastic-scaling", + "id": "reference-polkadot-hub-consensus-and-security-relay-chain", + "title": "Overview of the Polkadot Relay Chain", + "slug": "reference-polkadot-hub-consensus-and-security-relay-chain", "categories": [ - "Polkadot Protocol" + "Basics", + "Polkadot Protocol", + "Parachains" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-consensus-elastic-scaling.md", - "html_url": "https://docs.polkadot.com/reference/parachains/consensus/elastic-scaling/", - "preview": "Polkadot's architecture delivers scalability and security through its shared security model, where the relay chain coordinates and validates multiple parallel chains.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-relay-chain.md", + "html_url": "https://docs.polkadot.com/reference/polkadot-hub/consensus-and-security/relay-chain/", + "preview": "Polkadot is a next-generation blockchain protocol designed to support a multi-chain future by enabling secure communication and interoperability between different blockchains. Built as a Layer-0 protocol, Polkadot introduces innovations like application-specific Layer-1 chains ([parachains](/polkadot-protocol/architecture/parachains/){targe=\\_blank}), shared security through [Nominated Proof of Stake (NPoS)](/reference/glossary/#nominated-proof-of-stake-npos){target=\\_blank}, and cross-chain int", "outline": [ { "depth": 2, @@ -11556,61 +8949,74 @@ }, { "depth": 2, - "title": "How Elastic Scaling Works", - "anchor": "how-elastic-scaling-works" + "title": "Polkadot 1.0", + "anchor": "polkadot-10" }, { - "depth": 2, - "title": "Benefits of Elastic Scaling", - "anchor": "benefits-of-elastic-scaling" + "depth": 3, + "title": "High-Level Architecture", + "anchor": "high-level-architecture" }, { - "depth": 2, - "title": "Use Cases", - "anchor": "use-cases" + "depth": 3, + "title": "Polkadot's Additional Functionalities", + "anchor": "polkadots-additional-functionalities" }, { "depth": 3, - "title": "Handling Sudden Traffic Spikes", - "anchor": "handling-sudden-traffic-spikes" + "title": "Polkadot's Resilience", + "anchor": "polkadots-resilience" }, { "depth": 3, - "title": "Supporting Early-Stage Growth", - "anchor": "supporting-early-stage-growth" + "title": "Polkadot's Blockspace", + "anchor": "polkadots-blockspace" + }, + { + "depth": 2, + "title": "DOT Token", + "anchor": "dot-token" }, { "depth": 3, - "title": "Scaling Massive IoT Networks", - "anchor": "scaling-massive-iot-networks" + "title": "Redenomination of DOT", + "anchor": "redenomination-of-dot" }, { "depth": 3, - "title": "Powering Real-Time, Low-Latency Systems", - "anchor": "powering-real-time-low-latency-systems" + "title": "The Planck Unit", + "anchor": "the-planck-unit" + }, + { + "depth": 3, + "title": "Uses for DOT", + "anchor": "uses-for-dot" + }, + { + "depth": 2, + "title": "JAM and the Road Ahead", + "anchor": "jam-and-the-road-ahead" } ], "stats": { - "chars": 7871, - "words": 1047, - "headings": 8, - "estimated_token_count_total": 1440 + "chars": 12430, + "words": 1771, + "headings": 11, + "estimated_token_count_total": 2571 }, - "hash": "sha256:2d228c52844df8952520fafdd3e6f0e26bfd2f32b5ee60c6241cf7d38603643c", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:8a914e4309d4fe7070e62d7abe4665b6c76c8dc5ec3219332eccb16b77b0dd95", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-cryptography", - "title": "Cryptography", - "slug": "reference-parachains-cryptography", + "id": "reference-polkadot-hub-people-and-identity", + "title": "People Chain", + "slug": "reference-polkadot-hub-people-and-identity", "categories": [ - "Basics", "Polkadot Protocol" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-cryptography.md", - "html_url": "https://docs.polkadot.com/reference/parachains/cryptography/", - "preview": "Cryptography forms the backbone of blockchain technology, providing the mathematical verifiability crucial for consensus systems, data integrity, and user security. While a deep understanding of the underlying mathematical processes isn't necessary for most blockchain developers, grasping the fundamental applications of cryptography is essential. This page comprehensively overviews cryptographic implementations used across Polkadot SDK-based chains and the broader blockchain ecosystem.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-people-and-identity.md", + "html_url": "https://docs.polkadot.com/reference/polkadot-hub/people-and-identity/", + "preview": "People chain is a specialized parachain within the Polkadot ecosystem dedicated to secure, decentralized identity management.", "outline": [ { "depth": 2, @@ -11619,154 +9025,167 @@ }, { "depth": 2, - "title": "Hash Functions", - "anchor": "hash-functions" - }, - { - "depth": 3, - "title": "Key Properties of Hash Functions", - "anchor": "key-properties-of-hash-functions" + "title": "Identity Management System", + "anchor": "identity-management-system" }, { "depth": 3, - "title": "Blake2", - "anchor": "blake2" + "title": "Sub-Identities", + "anchor": "sub-identities" }, { "depth": 2, - "title": "Types of Cryptography", - "anchor": "types-of-cryptography" - }, - { - "depth": 3, - "title": "Symmetric Cryptography", - "anchor": "symmetric-cryptography" + "title": "Verification Process", + "anchor": "verification-process" }, { "depth": 3, - "title": "Asymmetric Cryptography", - "anchor": "asymmetric-cryptography" + "title": "Judgment Requests", + "anchor": "judgment-requests" }, { "depth": 3, - "title": "Trade-offs and Compromises", - "anchor": "trade-offs-and-compromises" - }, - { - "depth": 2, - "title": "Digital Signatures", - "anchor": "digital-signatures" + "title": "Judgment Classifications", + "anchor": "judgment-classifications" }, { "depth": 3, - "title": "Example of Creating a Digital Signature", - "anchor": "example-of-creating-a-digital-signature" + "title": "Registrars", + "anchor": "registrars" }, { "depth": 2, - "title": "Elliptic Curve", - "anchor": "elliptic-curve" - }, - { - "depth": 3, - "title": "Various Implementations", - "anchor": "various-implementations" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 8860, - "words": 1293, - "headings": 12, - "estimated_token_count_total": 1797 + "chars": 4750, + "words": 606, + "headings": 8, + "estimated_token_count_total": 876 }, - "hash": "sha256:259dcef86aadc513675258b665cc3940db65af6eb32a5db85da6ac339966fa60", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:8239d1e8d8642cb7c10e9e5f971c99b999e9e4a87373b50bf4a691225c1e4702", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-data-encoding", - "title": "Data Encoding", - "slug": "reference-parachains-data-encoding", + "id": "reference-polkadot-hub", + "title": "reference-polkadot-hub", + "slug": "reference-polkadot-hub", "categories": [ - "Basics", - "Polkadot Protocol" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-data-encoding.md", - "html_url": "https://docs.polkadot.com/reference/parachains/data-encoding/", - "preview": "The Polkadot SDK uses a lightweight and efficient encoding/decoding mechanism to optimize data transmission across the network. This mechanism, known as the _SCALE_ codec, is used for serializing and deserializing data.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub.md", + "html_url": "https://docs.polkadot.com/reference/polkadot-hub/", + "preview": "TODO", + "outline": [], + "stats": { + "chars": 5, + "words": 1, + "headings": 0, + "estimated_token_count_total": 0 + }, + "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-tools-chopsticks", + "title": "reference-tools-chopsticks", + "slug": "reference-tools-chopsticks", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-chopsticks.md", + "html_url": "https://docs.polkadot.com/reference/tools/chopsticks/", + "preview": "TODO", + "outline": [], + "stats": { + "chars": 5, + "words": 1, + "headings": 0, + "estimated_token_count_total": 0 + }, + "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-tools-dedot", + "title": "Dedot", + "slug": "reference-tools-dedot", + "categories": [ + "Tooling", + "Dapps" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-dedot.md", + "html_url": "https://docs.polkadot.com/reference/tools/dedot/", + "preview": "[Dedot](https://github.com/dedotdev/dedot){target=\\_blank} is a next-generation JavaScript client for Polkadot and Polkadot SDK-based blockchains. Designed to elevate the dApp development experience, Dedot is built and optimized to be lightweight and tree-shakable, offering precise types and APIs suggestions for individual Polkadot SDK-based blockchains and [ink! smart contracts](https://use.ink/){target=\\_blank}.", "outline": [ { "depth": 2, "title": "Introduction", "anchor": "introduction" }, - { - "depth": 2, - "title": "SCALE Codec", - "anchor": "scale-codec" - }, { "depth": 3, - "title": "Encode", - "anchor": "encode" + "title": "Key Features", + "anchor": "key-features" }, { - "depth": 3, - "title": "Decode", - "anchor": "decode" + "depth": 2, + "title": "Installation", + "anchor": "installation" }, { - "depth": 3, - "title": "CompactAs", - "anchor": "compactas" + "depth": 2, + "title": "Get Started", + "anchor": "get-started" }, { "depth": 3, - "title": "HasCompact", - "anchor": "hascompact" + "title": "Initialize a Client Instance", + "anchor": "initialize-a-client-instance" }, { "depth": 3, - "title": "EncodeLike", - "anchor": "encodelike" + "title": "Enable Type and API Suggestions", + "anchor": "enable-type-and-api-suggestions" }, { "depth": 3, - "title": "Data Types", - "anchor": "data-types" + "title": "Read On-Chain Data", + "anchor": "read-on-chain-data" }, { - "depth": 2, - "title": "Encode and Decode Rust Trait Implementations", - "anchor": "encode-and-decode-rust-trait-implementations" + "depth": 3, + "title": "Sign and Send Transactions", + "anchor": "sign-and-send-transactions" }, { "depth": 2, - "title": "SCALE Codec Libraries", - "anchor": "scale-codec-libraries" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 13629, - "words": 1314, - "headings": 10, - "estimated_token_count_total": 3213 + "chars": 8855, + "words": 1100, + "headings": 9, + "estimated_token_count_total": 2300 }, - "hash": "sha256:e448294b6e52291ac0add5fa6533572814e6cd27af42bdaccc2000b86f52d775", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:ba24e31e2ad94fbf1d73f1878da92dd2e1476db00170780bbdf0e65ab18bc961", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-interoperability", - "title": "Interoperability", - "slug": "reference-parachains-interoperability", + "id": "reference-tools-light-clients", + "title": "Light Clients", + "slug": "reference-tools-light-clients", "categories": [ - "Basics", - "Polkadot Protocol" + "Parachains", + "Tooling" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-interoperability.md", - "html_url": "https://docs.polkadot.com/reference/parachains/interoperability/", - "preview": "Interoperability lies at the heart of the Polkadot ecosystem, enabling communication and collaboration across a diverse range of blockchains. By bridging the gaps between parachains, relay chains, and even external networks, Polkadot unlocks the potential for truly decentralized applications, efficient resource sharing, and scalable solutions.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-light-clients.md", + "html_url": "https://docs.polkadot.com/reference/tools/light-clients/", + "preview": "Light clients enable secure and efficient blockchain interaction without running a full node. They provide a trust-minimized alternative to JSON-RPC by verifying data through cryptographic proofs rather than blindly trusting remote nodes.", "outline": [ { "depth": 2, @@ -11775,57 +9194,55 @@ }, { "depth": 2, - "title": "Why Interoperability Matters", - "anchor": "why-interoperability-matters" + "title": "Light Clients Workflow", + "anchor": "light-clients-workflow" }, { "depth": 2, - "title": "Key Mechanisms for Interoperability", - "anchor": "key-mechanisms-for-interoperability" + "title": "JSON-RPC and Light Client Comparison", + "anchor": "json-rpc-and-light-client-comparison" }, { - "depth": 3, - "title": "Cross-Consensus Messaging (XCM): The Backbone of Communication", - "anchor": "cross-consensus-messaging-xcm-the-backbone-of-communication" + "depth": 2, + "title": "Using Light Clients", + "anchor": "using-light-clients" }, { "depth": 3, - "title": "Bridges: Connecting External Networks", - "anchor": "bridges-connecting-external-networks" + "title": "PAPI Light Client Support", + "anchor": "papi-light-client-support" }, { - "depth": 2, - "title": "The Polkadot Advantage", - "anchor": "the-polkadot-advantage" + "depth": 3, + "title": "Substrate Connect - Browser Extension", + "anchor": "substrate-connect-browser-extension" }, { "depth": 2, - "title": "Looking Ahead", - "anchor": "looking-ahead" + "title": "Resources", + "anchor": "resources" } ], "stats": { - "chars": 4635, - "words": 584, + "chars": 6490, + "words": 870, "headings": 7, - "estimated_token_count_total": 772 + "estimated_token_count_total": 1430 }, - "hash": "sha256:11bb4f113bdda5852a3115e64d5ba47f8eccd4e3619a05ad960ab3a541f31346", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:1284c42be692167e01bcc44e2e134ec20615402675fac26df246c00aa1588d80", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-networks", - "title": "Networks", - "slug": "reference-parachains-networks", + "id": "reference-tools-moonwall", + "title": "E2E Testing with Moonwall", + "slug": "reference-tools-moonwall", "categories": [ - "Basics", - "Polkadot Protocol", - "Networks" + "Parachains", + "Tooling" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-networks.md", - "html_url": "https://docs.polkadot.com/reference/parachains/networks/", - "preview": "The Polkadot ecosystem is built on a robust set of networks designed to enable secure and scalable development. Whether you are testing new features or deploying to live production, Polkadot offers several layers of networks tailored for each stage of the development process. From local environments to experimental networks like Kusama and community-run TestNets such as Paseo, developers can thoroughly test, iterate, and validate their applications. This guide will introduce you to Polkadot's va", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-moonwall.md", + "html_url": "https://docs.polkadot.com/reference/tools/moonwall/", + "preview": "Moonwall is an end-to-end testing framework designed explicitly for Polkadot SDK-based blockchain networks. It addresses one of the most significant challenges in blockchain development: managing complex test environments and network configurations.", "outline": [ { "depth": 2, @@ -11834,71 +9251,65 @@ }, { "depth": 2, - "title": "Network Overview", - "anchor": "network-overview" - }, - { - "depth": 2, - "title": "Polkadot Development Networks", - "anchor": "polkadot-development-networks" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "Kusama Network", - "anchor": "kusama-network" + "title": "Install Moonwall", + "anchor": "install-moonwall" }, { - "depth": 2, - "title": "Test Networks", - "anchor": "test-networks" + "depth": 3, + "title": "Global Installation", + "anchor": "global-installation" }, { "depth": 3, - "title": "Westend", - "anchor": "westend" + "title": "Local Installation", + "anchor": "local-installation" }, { - "depth": 3, - "title": "Paseo", - "anchor": "paseo" + "depth": 2, + "title": "Initialize Moonwall", + "anchor": "initialize-moonwall" }, { "depth": 2, - "title": "Local Test Networks", - "anchor": "local-test-networks" + "title": "Writing Tests", + "anchor": "writing-tests" }, { - "depth": 3, - "title": "Zombienet", - "anchor": "zombienet" + "depth": 2, + "title": "Running the Tests", + "anchor": "running-the-tests" }, { - "depth": 3, - "title": "Chopsticks", - "anchor": "chopsticks" + "depth": 2, + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 7834, - "words": 1111, - "headings": 10, - "estimated_token_count_total": 1473 + "chars": 10240, + "words": 1295, + "headings": 9, + "estimated_token_count_total": 2453 }, - "hash": "sha256:e49e063a2cc0fb5a48c6cdc3de266bb6e025a006940fea8e90cc4d5f9884900f", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:2c77cfb38bb2e466a8f56dabbb706fcd2e90cf1634fc9beb7f0ee95a75735653", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-node-and-runtime", - "title": "Node and Runtime", - "slug": "reference-parachains-node-and-runtime", + "id": "reference-tools-omninode", + "title": "Polkadot Omni Node", + "slug": "reference-tools-omninode", "categories": [ - "Basics", - "Polkadot Protocol" + "Parachains", + "Tooling" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-node-and-runtime.md", - "html_url": "https://docs.polkadot.com/reference/parachains/node-and-runtime/", - "preview": "Every blockchain platform relies on a decentralized network of computers, called nodes, that communicate with each other about transactions and blocks. In this context, a node refers to the software running on the connected devices rather than the physical or virtual machines in the network.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-omninode.md", + "html_url": "https://docs.polkadot.com/reference/tools/omninode/", + "preview": "The [`polkadot-omni-node`](https://crates.io/crates/polkadot-omni-node/0.7.0){target=\\_blank} crate is a versatile, pre-built binary designed to simplify running parachains in the Polkadot ecosystem. Unlike traditional node binaries that are tightly coupled to specific runtime code, the `polkadot-omni-node` operates using an external [chain specification](/polkadot-protocol/glossary#chain-specification){target=\\_blank} file, allowing it to adapt dynamically to different parachains.", "outline": [ { "depth": 2, @@ -11907,71 +9318,65 @@ }, { "depth": 2, - "title": "Architectural Principles", - "anchor": "architectural-principles" - }, - { - "depth": 3, - "title": "Advantages of this Architecture", - "anchor": "advantages-of-this-architecture" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "Node (Client)", - "anchor": "node-client" + "title": "Install Polkadot Omni Node", + "anchor": "install-polkadot-omni-node" }, { "depth": 2, - "title": "Runtime", - "anchor": "runtime" + "title": "Obtain Chain Specifications", + "anchor": "obtain-chain-specifications" }, { - "depth": 3, - "title": "Characteristics", - "anchor": "characteristics" + "depth": 2, + "title": "Run a Parachain Full Node", + "anchor": "run-a-parachain-full-node" }, { - "depth": 3, - "title": "Key Functions", - "anchor": "key-functions" + "depth": 2, + "title": "Interact with the Node", + "anchor": "interact-with-the-node" }, { "depth": 2, - "title": "Communication Between Node and Runtime", - "anchor": "communication-between-node-and-runtime" + "title": "Parachain Compatibility", + "anchor": "parachain-compatibility" }, { "depth": 3, - "title": "Runtime APIs", - "anchor": "runtime-apis" + "title": "Required Runtime APIs", + "anchor": "required-runtime-apis" }, { "depth": 3, - "title": "Host Functions", - "anchor": "host-functions" + "title": "Required Pallets", + "anchor": "required-pallets" } ], "stats": { - "chars": 4937, - "words": 628, - "headings": 10, - "estimated_token_count_total": 914 + "chars": 8916, + "words": 1165, + "headings": 9, + "estimated_token_count_total": 2018 }, - "hash": "sha256:8122e21c149d0863cfe3b37fc5606bcdb91668e9d265f0f05451a61ff70e4e93", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:a87815deff81936d7f50842f8600004990076c1a33e7e6b408ab954b6ce47259", "token_estimator": "heuristic-v1" }, { - "id": "reference-parachains-randomness", - "title": "Randomness", - "slug": "reference-parachains-randomness", + "id": "reference-tools-papi", + "title": "Polkadot-API", + "slug": "reference-tools-papi", "categories": [ - "Basics", - "Polkadot Protocol" + "Tooling", + "Dapps" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains-randomness.md", - "html_url": "https://docs.polkadot.com/reference/parachains/randomness/", - "preview": "Randomness is crucial in Proof of Stake (PoS) blockchains to ensure a fair and unpredictable distribution of validator duties. However, computers are inherently deterministic, meaning the same input always produces the same output. What we typically refer to as \"random\" numbers on a computer are actually pseudo-random. These numbers rely on an initial \"seed,\" which can come from external sources like [atmospheric noise](https://www.random.org/randomness/){target=\\_blank}, [heart rates](https://m", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-papi.md", + "html_url": "https://docs.polkadot.com/reference/tools/papi/", + "preview": "[Polkadot-API](https://github.com/polkadot-api/polkadot-api){target=\\_blank} (PAPI) is a set of libraries built to be modular, composable, and grounded in a “light-client first” approach. Its primary aim is to equip dApp developers with an extensive toolkit for building fully decentralized applications.", "outline": [ { "depth": 2, @@ -11980,155 +9385,136 @@ }, { "depth": 2, - "title": "VRF", - "anchor": "vrf" + "title": "Get Started", + "anchor": "get-started" }, { "depth": 3, - "title": "How VRF Works", - "anchor": "how-vrf-works" + "title": "API Instantiation", + "anchor": "api-instantiation" }, { - "depth": 2, - "title": "RANDAO", - "anchor": "randao" + "depth": 3, + "title": "Reading Chain Data", + "anchor": "reading-chain-data" }, { - "depth": 2, - "title": "VDFs", - "anchor": "vdfs" + "depth": 3, + "title": "Sending Transactions", + "anchor": "sending-transactions" }, { "depth": 2, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 6503, - "words": 1005, + "chars": 8957, + "words": 1156, "headings": 6, - "estimated_token_count_total": 1388 + "estimated_token_count_total": 1987 }, - "hash": "sha256:c7d8a5a4263fd21af458ab0bd102377104affdf2431b4fe74eeff4ebe62a4a81", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:2ca93b09d3bb9159bbf53816886a9b242bb3c13b996c51fd52962e049e2d5477", "token_estimator": "heuristic-v1" }, { - "id": "reference-polkadot-hub-assets-and-smart-contracts", - "title": "Asset Hub", - "slug": "reference-polkadot-hub-assets-and-smart-contracts", + "id": "reference-tools-paraspell", + "title": "ParaSpell XCM SDK", + "slug": "reference-tools-paraspell", "categories": [ - "Polkadot Protocol" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-assets-and-smart-contracts.md", - "html_url": "https://docs.polkadot.com/reference/polkadot-hub/assets-and-smart-contracts/", - "preview": "The Asset Hub is a critical component in the Polkadot ecosystem, enabling the management of fungible and non-fungible assets across the network. Since the relay chain focuses on maintaining security and consensus without direct asset management, Asset Hub provides a streamlined platform for creating, managing, and using on-chain assets in a fee-efficient manner. This guide outlines the core features of Asset Hub, including how it handles asset operations, cross-chain transfers, and asset integra", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-paraspell.md", + "html_url": "https://docs.polkadot.com/reference/tools/paraspell/", + "preview": "[ParaSpell](https://paraspell.github.io/docs/){target=\\_blank} is a comprehensive suite of open-source tools designed to simplify cross-chain interactions within the Polkadot ecosystem. At its core, ParaSpell is dedicated to enhancing the functionality of the [XCM (Cross-Consensus Messaging)](/parachains/interoperability/get-started/){target=\\_blank} protocol by providing developers with a unified and streamlined experience for building interoperable decentralized applications (dApps).", "outline": [ { "depth": 2, "title": "Introduction", "anchor": "introduction" }, - { - "depth": 2, - "title": "Assets Basics", - "anchor": "assets-basics" - }, - { - "depth": 2, - "title": "Assets Pallet", - "anchor": "assets-pallet" - }, - { - "depth": 3, - "title": "Key Features", - "anchor": "key-features" - }, - { - "depth": 3, - "title": "Main Functions", - "anchor": "main-functions" - }, - { - "depth": 3, - "title": "Querying Functions", - "anchor": "querying-functions" - }, - { - "depth": 3, - "title": "Permission Models and Roles", - "anchor": "permission-models-and-roles" - }, - { - "depth": 3, - "title": "Asset Freezing", - "anchor": "asset-freezing" - }, { "depth": 3, - "title": "Non-Custodial Transfers (Approval API)", - "anchor": "non-custodial-transfers-approval-api" + "title": "ParaSpell XCM SDK", + "anchor": "paraspell-xcm-sdk" }, { "depth": 2, - "title": "Foreign Assets", - "anchor": "foreign-assets" - }, - { - "depth": 3, - "title": "Handling Foreign Assets", - "anchor": "handling-foreign-assets" + "title": "Install ParaSpell", + "anchor": "install-paraspell" }, { "depth": 2, - "title": "Integration", - "anchor": "integration" - }, + "title": "Where to Go Next", + "anchor": "where-to-go-next" + } + ], + "stats": { + "chars": 4043, + "words": 562, + "headings": 4, + "estimated_token_count_total": 888 + }, + "hash": "sha256:c8741954ea656680aa3322c825e3f6acbaac369baaa42232b06af9e5e482f74f", + "token_estimator": "heuristic-v1" + }, + { + "id": "reference-tools-polkadart", + "title": "Polkadart", + "slug": "reference-tools-polkadart", + "categories": [ + "Tooling", + "Dapps" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-polkadart.md", + "html_url": "https://docs.polkadot.com/reference/tools/polkadart/", + "preview": "Polkadart is the most comprehensive Dart/Flutter SDK for interacting with Polkadot, Substrate, and other compatible blockchain networks. Designed with a Dart-first approach and type-safe APIs, it provides everything developers need to build powerful decentralized applications.", + "outline": [ { - "depth": 3, - "title": "API Sidecar", - "anchor": "api-sidecar" + "depth": 2, + "title": "Installation", + "anchor": "installation" }, { - "depth": 3, - "title": "TxWrapper", - "anchor": "txwrapper" + "depth": 2, + "title": "Get Started", + "anchor": "get-started" }, { "depth": 3, - "title": "ParaSpell", - "anchor": "paraspell" + "title": "Type Generation", + "anchor": "type-generation" }, { "depth": 3, - "title": "Parachain Node", - "anchor": "parachain-node" + "title": "Run Generator", + "anchor": "run-generator" }, { - "depth": 2, - "title": "XCM Transfer Monitoring", - "anchor": "xcm-transfer-monitoring" + "depth": 3, + "title": "Use Generated Types", + "anchor": "use-generated-types" }, { "depth": 3, - "title": "Monitor XCM Deposits", - "anchor": "monitor-xcm-deposits" + "title": "Creating an API Instance", + "anchor": "creating-an-api-instance" }, { "depth": 3, - "title": "Track XCM Information Back to the Source", - "anchor": "track-xcm-information-back-to-the-source" + "title": "Reading Chain Data", + "anchor": "reading-chain-data" }, { "depth": 3, - "title": "Practical Monitoring Examples", - "anchor": "practical-monitoring-examples" + "title": "Subscribe to New Blocks", + "anchor": "subscribe-to-new-blocks" }, { "depth": 3, - "title": "Monitor for Failed XCM Transfers", - "anchor": "monitor-for-failed-xcm-transfers" + "title": "Send a Transaction", + "anchor": "send-a-transaction" }, { "depth": 2, @@ -12137,50 +9523,65 @@ } ], "stats": { - "chars": 20065, - "words": 2901, - "headings": 22, - "estimated_token_count_total": 4087 + "chars": 5178, + "words": 624, + "headings": 10, + "estimated_token_count_total": 1084 }, - "hash": "sha256:73c34bb1dc80d04f765812c3ed2f247aeda6ce55598b0680d0bd157f25456b99", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:7f533abe61586af8438e350c41b741d74a8edb839f9dc4139bc4619ba3748258", "token_estimator": "heuristic-v1" }, { - "id": "reference-polkadot-hub-bridging", - "title": "Bridge Hub", - "slug": "reference-polkadot-hub-bridging", + "id": "reference-tools-polkadot-js-api", + "title": "Polkadot.js API", + "slug": "reference-tools-polkadot-js-api", "categories": [ - "Polkadot Protocol" + "Tooling", + "Dapps" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-bridging.md", - "html_url": "https://docs.polkadot.com/reference/polkadot-hub/bridging/", - "preview": "The Bridge Hub system parachain plays a crucial role in facilitating trustless interactions between Polkadot, Kusama, Ethereum, and other blockchain ecosystems. By implementing on-chain light clients and supporting protocols like BEEFY and GRANDPA, Bridge Hub ensures seamless message transmission and state verification across chains. It also provides essential [pallets](/reference/glossary/#pallet){target=\\_blank} for sending and receiving messages, making it a cornerstone of Polkadot’s interope", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-polkadot-js-api.md", + "html_url": "https://docs.polkadot.com/reference/tools/polkadot-js-api/", + "preview": "!!! warning \"Maintenance Mode Only\" The Polkadot.js API is now in maintenance mode and is no longer actively developed. New projects should use [Dedot](/develop/toolkit/api-libraries/dedot){target=\\_blank} (TypeScript-first API) or [Polkadot API](/develop/toolkit/api-libraries/papi){target=\\_blank} (modern, type-safe API) as actively maintained alternatives.", "outline": [ { "depth": 2, "title": "Introduction", "anchor": "introduction" }, + { + "depth": 3, + "title": "Dynamic API Generation", + "anchor": "dynamic-api-generation" + }, + { + "depth": 3, + "title": "Available API Categories", + "anchor": "available-api-categories" + }, { "depth": 2, - "title": "Trustless Bridging", - "anchor": "trustless-bridging" + "title": "Installation", + "anchor": "installation" }, { "depth": 2, - "title": "Bridging Components", - "anchor": "bridging-components" + "title": "Get Started", + "anchor": "get-started" }, { "depth": 3, - "title": "Ethereum-Specific Support", - "anchor": "ethereum-specific-support" + "title": "Creating an API Instance", + "anchor": "creating-an-api-instance" }, { - "depth": 2, - "title": "Deployed Bridges", - "anchor": "deployed-bridges" + "depth": 3, + "title": "Reading Chain Data", + "anchor": "reading-chain-data" + }, + { + "depth": 3, + "title": "Sending Transactions", + "anchor": "sending-transactions" }, { "depth": 2, @@ -12189,25 +9590,25 @@ } ], "stats": { - "chars": 5467, - "words": 776, - "headings": 6, - "estimated_token_count_total": 1220 + "chars": 5042, + "words": 684, + "headings": 9, + "estimated_token_count_total": 1166 }, - "hash": "sha256:86734ba8bcdea7913f488edf666a6104bed0a18649d57abde82c149c41c2b871", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:ed3986f30880fefca5975fcdc847c68b4aca65862c63e3002b25391b0521781d", "token_estimator": "heuristic-v1" }, { - "id": "reference-polkadot-hub-collectives-and-daos", - "title": "Collectives Chain", - "slug": "reference-polkadot-hub-collectives-and-daos", + "id": "reference-tools-py-substrate-interface", + "title": "Python Substrate Interface", + "slug": "reference-tools-py-substrate-interface", "categories": [ - "Polkadot Protocol" + "Tooling", + "Dapps" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-collectives-and-daos.md", - "html_url": "https://docs.polkadot.com/reference/polkadot-hub/collectives-and-daos/", - "preview": "Established through [Referendum 81](https://polkadot-old.polkassembly.io/referendum/81){target=\\_blank}, the Collectives chain operates as a dedicated parachain exclusive to the Polkadot network with no counterpart on Kusama. This specialized infrastructure provides a foundation for various on-chain governance groups essential to Polkadot's ecosystem.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-py-substrate-interface.md", + "html_url": "https://docs.polkadot.com/reference/tools/py-substrate-interface/", + "preview": "The [Python Substrate Interface](https://github.com/polkascan/py-substrate-interface){target=\\_blank} is a powerful library that enables interaction with Polkadot SDK-based chains. It provides essential functionality for:", "outline": [ { "depth": 2, @@ -12216,77 +9617,55 @@ }, { "depth": 2, - "title": "Key Collectives", - "anchor": "key-collectives" - } - ], - "stats": { - "chars": 2288, - "words": 293, - "headings": 2, - "estimated_token_count_total": 424 - }, - "hash": "sha256:59ec351fbb8d3a392e90f4f5bf6b62f58b21d6d7a900c5e367e5d2e09ecb3aca", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "reference-polkadot-hub-consensus-and-security-agile-coretime", - "title": "Agile Coretime", - "slug": "reference-polkadot-hub-consensus-and-security-agile-coretime", - "categories": [ - "Polkadot Protocol" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-agile-coretime.md", - "html_url": "https://docs.polkadot.com/reference/polkadot-hub/consensus-and-security/agile-coretime/", - "preview": "Agile Coretime is the [scheduling](https://en.wikipedia.org/wiki/Scheduling_(computing)){target=\\_blank} framework on Polkadot that lets parachains efficiently access cores, which comprise an active validator set tasked with parablock validation. As the first blockchain to enable a flexible scheduling system for blockspace production, Polkadot offers unparalleled adaptability for parachains.", - "outline": [ + "title": "Installation", + "anchor": "installation" + }, { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Get Started", + "anchor": "get-started" }, { - "depth": 2, - "title": "Bulk Coretime", - "anchor": "bulk-coretime" + "depth": 3, + "title": "Establishing Connection", + "anchor": "establishing-connection" }, { "depth": 3, - "title": "Coretime Interlacing", - "anchor": "coretime-interlacing" + "title": "Reading Chain State", + "anchor": "reading-chain-state" }, { "depth": 3, - "title": "Coretime Splitting", - "anchor": "coretime-splitting" + "title": "Submitting Transactions", + "anchor": "submitting-transactions" }, { "depth": 2, - "title": "On-Demand Coretime", - "anchor": "on-demand-coretime" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 3028, - "words": 452, - "headings": 5, - "estimated_token_count_total": 619 + "chars": 4302, + "words": 541, + "headings": 7, + "estimated_token_count_total": 942 }, - "hash": "sha256:00be43ac8d666bbe15c5c2fa5a5085697d0bb5a6f341ebbb943a209f0be355df", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:8987fc35cd28602054ee018031f773e2e3837425107c51d0e2ac68a94b86e9c0", "token_estimator": "heuristic-v1" }, { - "id": "reference-polkadot-hub-consensus-and-security-pos-consensus", - "title": "Proof of Stake Consensus", - "slug": "reference-polkadot-hub-consensus-and-security-pos-consensus", + "id": "reference-tools-sidecar", + "title": "Sidecar REST API", + "slug": "reference-tools-sidecar", "categories": [ - "Polkadot Protocol" + "Tooling", + "Dapps" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-pos-consensus.md", - "html_url": "https://docs.polkadot.com/reference/polkadot-hub/consensus-and-security/pos-consensus/", - "preview": "Polkadot's Proof of Stake consensus model leverages a unique hybrid approach by design to promote decentralized and secure network operations. In traditional Proof of Stake (PoS) systems, a node's ability to validate transactions is tied to its token holdings, which can lead to centralization risks and limited validator participation. Polkadot addresses these concerns through its [Nominated Proof of Stake (NPoS)](/reference/glossary/#nominated-proof-of-stake-npos){target=\\_blank} model and a com", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-sidecar.md", + "html_url": "https://docs.polkadot.com/reference/tools/sidecar/", + "preview": "The [Sidecar REST API](https://github.com/paritytech/substrate-api-sidecar){target=\\_blank} is a service that provides a REST interface for interacting with Polkadot SDK-based blockchains. With this API, developers can easily access a broad range of endpoints for nodes, accounts, transactions, parachains, and more.", "outline": [ { "depth": 2, @@ -12295,87 +9674,50 @@ }, { "depth": 2, - "title": "Nominated Proof of Stake", - "anchor": "nominated-proof-of-stake" - }, - { - "depth": 2, - "title": "Hybrid Consensus", - "anchor": "hybrid-consensus" - }, - { - "depth": 2, - "title": "Block Production - BABE", - "anchor": "block-production-babe" - }, - { - "depth": 3, - "title": "Validator Participation", - "anchor": "validator-participation" - }, - { - "depth": 3, - "title": "Additional Resources", - "anchor": "additional-resources" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "Finality Gadget - GRANDPA", - "anchor": "finality-gadget-grandpa" - }, - { - "depth": 3, - "title": "Probabilistic vs. Provable Finality", - "anchor": "probabilistic-vs-provable-finality" - }, - { - "depth": 3, - "title": "Additional Resources", - "anchor": "additional-resources-2" + "title": "Installation", + "anchor": "installation" }, { "depth": 2, - "title": "Fork Choice", - "anchor": "fork-choice" + "title": "Usage", + "anchor": "usage" }, { "depth": 3, - "title": "Additional Resources", - "anchor": "additional-resources-3" + "title": "Endpoints", + "anchor": "endpoints" }, { "depth": 2, - "title": "Bridging - BEEFY", - "anchor": "bridging-beefy" - }, - { - "depth": 3, - "title": "Additional Resources", - "anchor": "additional-resources-4" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 12753, - "words": 1834, - "headings": 13, - "estimated_token_count_total": 2526 + "chars": 7309, + "words": 1033, + "headings": 6, + "estimated_token_count_total": 1945 }, - "hash": "sha256:231fc555eefe5f910fb36e0c03945147d0fb235272850797391751f4444b0a9c", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:0795462182cb97256bb5c2acb035855fe0d6557185de8ac99482725ecb4f94c1", "token_estimator": "heuristic-v1" }, { - "id": "reference-polkadot-hub-consensus-and-security-relay-chain", - "title": "Overview of the Polkadot Relay Chain", - "slug": "reference-polkadot-hub-consensus-and-security-relay-chain", + "id": "reference-tools-subxt", + "title": "Subxt Rust API", + "slug": "reference-tools-subxt", "categories": [ - "Basics", - "Polkadot Protocol", - "Parachains" + "Tooling", + "Dapps" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-relay-chain.md", - "html_url": "https://docs.polkadot.com/reference/polkadot-hub/consensus-and-security/relay-chain/", - "preview": "Polkadot is a next-generation blockchain protocol designed to support a multi-chain future by enabling secure communication and interoperability between different blockchains. Built as a Layer-0 protocol, Polkadot introduces innovations like application-specific Layer-1 chains ([parachains](/polkadot-protocol/architecture/parachains/){targe=\\_blank}), shared security through [Nominated Proof of Stake (NPoS)](/reference/glossary/#nominated-proof-of-stake-npos){target=\\_blank}, and cross-chain int", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-subxt.md", + "html_url": "https://docs.polkadot.com/reference/tools/subxt/", + "preview": "Subxt is a Rust library designed to interact with Polkadot SDK-based blockchains. It provides a type-safe interface for submitting transactions, querying on-chain state, and performing other blockchain interactions. By leveraging Rust's strong type system, subxt ensures that your code is validated at compile time, reducing runtime errors and improving reliability.", "outline": [ { "depth": 2, @@ -12384,75 +9726,71 @@ }, { "depth": 2, - "title": "Polkadot 1.0", - "anchor": "polkadot-10" + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 3, - "title": "High-Level Architecture", - "anchor": "high-level-architecture" + "depth": 2, + "title": "Installation", + "anchor": "installation" }, { - "depth": 3, - "title": "Polkadot's Additional Functionalities", - "anchor": "polkadots-additional-functionalities" + "depth": 2, + "title": "Get Started", + "anchor": "get-started" }, { "depth": 3, - "title": "Polkadot's Resilience", - "anchor": "polkadots-resilience" + "title": "Download Chain Metadata", + "anchor": "download-chain-metadata" }, { "depth": 3, - "title": "Polkadot's Blockspace", - "anchor": "polkadots-blockspace" - }, - { - "depth": 2, - "title": "DOT Token", - "anchor": "dot-token" + "title": "Generate Type-Safe Interfaces", + "anchor": "generate-type-safe-interfaces" }, { "depth": 3, - "title": "Redenomination of DOT", - "anchor": "redenomination-of-dot" + "title": "Initialize the Subxt Client", + "anchor": "initialize-the-subxt-client" }, { "depth": 3, - "title": "The Planck Unit", - "anchor": "the-planck-unit" + "title": "Read Chain Data", + "anchor": "read-chain-data" }, { "depth": 3, - "title": "Uses for DOT", - "anchor": "uses-for-dot" + "title": "Submit Transactions", + "anchor": "submit-transactions" }, { "depth": 2, - "title": "JAM and the Road Ahead", - "anchor": "jam-and-the-road-ahead" + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 12430, - "words": 1771, - "headings": 11, - "estimated_token_count_total": 2571 + "chars": 9174, + "words": 1175, + "headings": 10, + "estimated_token_count_total": 2187 }, - "hash": "sha256:8a914e4309d4fe7070e62d7abe4665b6c76c8dc5ec3219332eccb16b77b0dd95", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:56269d9ea47f5b4e92cd7d5a1e65ab06d181a9c380f90bb3ef285529b12299f7", "token_estimator": "heuristic-v1" }, { - "id": "reference-polkadot-hub-people-and-identity", - "title": "People Chain", - "slug": "reference-polkadot-hub-people-and-identity", + "id": "reference-tools-xcm-tools", + "title": "XCM Tools", + "slug": "reference-tools-xcm-tools", "categories": [ - "Polkadot Protocol" + "Basics", + "Tooling", + "Dapps" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-people-and-identity.md", - "html_url": "https://docs.polkadot.com/reference/polkadot-hub/people-and-identity/", - "preview": "People chain is a specialized parachain within the Polkadot ecosystem dedicated to secure, decentralized identity management.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-xcm-tools.md", + "html_url": "https://docs.polkadot.com/reference/tools/xcm-tools/", + "preview": "As described in the [Interoperability](/develop/interoperability){target=\\_blank} section, XCM (Cross-Consensus Messaging) is a protocol used in the Polkadot and Kusama ecosystems to enable communication and interaction between chains. It facilitates cross-chain communication, allowing assets, data, and messages to flow seamlessly across the ecosystem.", "outline": [ { "depth": 2, @@ -12461,59 +9799,53 @@ }, { "depth": 2, - "title": "Identity Management System", - "anchor": "identity-management-system" + "title": "Popular XCM Tools", + "anchor": "popular-xcm-tools" }, { "depth": 3, - "title": "Sub-Identities", - "anchor": "sub-identities" - }, - { - "depth": 2, - "title": "Verification Process", - "anchor": "verification-process" + "title": "Moonsong Labs XCM Tools", + "anchor": "moonsong-labs-xcm-tools" }, { "depth": 3, - "title": "Judgment Requests", - "anchor": "judgment-requests" + "title": "ParaSpell", + "anchor": "paraspell" }, { "depth": 3, - "title": "Judgment Classifications", - "anchor": "judgment-classifications" + "title": "Astar XCM Tools", + "anchor": "astar-xcm-tools" }, { "depth": 3, - "title": "Registrars", - "anchor": "registrars" + "title": "Chopsticks", + "anchor": "chopsticks" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "depth": 3, + "title": "Moonbeam XCM SDK", + "anchor": "moonbeam-xcm-sdk" } ], "stats": { - "chars": 4750, - "words": 606, - "headings": 8, - "estimated_token_count_total": 876 + "chars": 6146, + "words": 852, + "headings": 7, + "estimated_token_count_total": 1377 }, - "hash": "sha256:8239d1e8d8642cb7c10e9e5f971c99b999e9e4a87373b50bf4a691225c1e4702", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:674e4f60c82fc7544c7af8e09f1e0f677c9907cdff88b107f6c8489e97a43487", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-chopsticks", - "title": "reference-tools-chopsticks", - "slug": "reference-tools-chopsticks", + "id": "reference-tools-zombienet", + "title": "reference-tools-zombienet", + "slug": "reference-tools-zombienet", "categories": [ "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-chopsticks.md", - "html_url": "https://docs.polkadot.com/reference/tools/chopsticks/", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-zombienet.md", + "html_url": "https://docs.polkadot.com/reference/tools/zombienet/", "preview": "TODO", "outline": [], "stats": { @@ -12523,60 +9855,180 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:15+00:00", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-dedot", - "title": "Dedot", - "slug": "reference-tools-dedot", + "id": "reference", + "title": "reference", + "slug": "reference", "categories": [ - "Tooling", - "Dapps" + "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-dedot.md", - "html_url": "https://docs.polkadot.com/reference/tools/dedot/", - "preview": "[Dedot](https://github.com/dedotdev/dedot){target=\\_blank} is a next-generation JavaScript client for Polkadot and Polkadot SDK-based blockchains. Designed to elevate the dApp development experience, Dedot is built and optimized to be lightweight and tree-shakable, offering precise types and APIs suggestions for individual Polkadot SDK-based blockchains and [ink! smart contracts](https://use.ink/){target=\\_blank}.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md", + "html_url": "https://docs.polkadot.com/reference/", + "preview": "TODO", + "outline": [], + "stats": { + "chars": 5, + "words": 1, + "headings": 0, + "estimated_token_count_total": 0 + }, + "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-connect", + "title": "Connect to Polkadot", + "slug": "smart-contracts-connect", + "categories": [ + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-connect.md", + "html_url": "https://docs.polkadot.com/smart-contracts/connect/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ", "outline": [ { "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "title": "Networks Details", + "anchor": "networks-details" + }, + { + "depth": 2, + "title": "Test Tokens", + "anchor": "test-tokens" + }, + { + "depth": 2, + "title": "Where to Go Next", + "anchor": "where-to-go-next" + } + ], + "stats": { + "chars": 3459, + "words": 476, + "headings": 3, + "estimated_token_count_total": 558 + }, + "hash": "sha256:a2490223926957381913ae0ed22e2df3611a6713ec9d77a3015d1cd6a578b3f6", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-cookbook-dapps-zero-to-hero", + "title": "Zero to Hero Smart Contract DApp", + "slug": "smart-contracts-cookbook-dapps-zero-to-hero", + "categories": [ + "dApp", + "Tooling" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/dapps/zero-to-hero/", + "preview": "Decentralized applications (dApps) are a key component of the Web3 ecosystem, enabling developers to build applications that communicate directly with blockchain networks. Polkadot Hub, a blockchain with smart contract support, serves as a robust platform for deploying and interacting with dApps.", + "outline": [ + { + "depth": 2, + "title": "Prerequisites", + "anchor": "prerequisites" + }, + { + "depth": 2, + "title": "Project Overview", + "anchor": "project-overview" + }, + { + "depth": 2, + "title": "Create and Deploy the Storage Contract", + "anchor": "create-and-deploy-the-storage-contract" }, { "depth": 3, - "title": "Key Features", - "anchor": "key-features" + "title": "Set Up Hardhat Project", + "anchor": "set-up-hardhat-project" + }, + { + "depth": 3, + "title": "Create the Storage Contract", + "anchor": "create-the-storage-contract" + }, + { + "depth": 3, + "title": "Configure Hardhat for Polkadot Hub", + "anchor": "configure-hardhat-for-polkadot-hub" + }, + { + "depth": 3, + "title": "Compile the Contract", + "anchor": "compile-the-contract" + }, + { + "depth": 3, + "title": "Deploy the Contract", + "anchor": "deploy-the-contract" + }, + { + "depth": 3, + "title": "Export the Contract ABI", + "anchor": "export-the-contract-abi" + }, + { + "depth": 2, + "title": "Set Up the dApp Project", + "anchor": "set-up-the-dapp-project" + }, + { + "depth": 2, + "title": "Install Dependencies", + "anchor": "install-dependencies" + }, + { + "depth": 2, + "title": "Connect to Polkadot Hub", + "anchor": "connect-to-polkadot-hub" + }, + { + "depth": 2, + "title": "Set Up the Smart Contract Interface", + "anchor": "set-up-the-smart-contract-interface" + }, + { + "depth": 2, + "title": "Create the Wallet Connection Component", + "anchor": "create-the-wallet-connection-component" + }, + { + "depth": 2, + "title": "Create the Read Contract Component", + "anchor": "create-the-read-contract-component" }, { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Create the Write Contract Component", + "anchor": "create-the-write-contract-component" }, { "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "title": "How It Works", + "anchor": "how-it-works" }, { "depth": 3, - "title": "Initialize a Client Instance", - "anchor": "initialize-a-client-instance" + "title": "Wallet Connection", + "anchor": "wallet-connection" }, { "depth": 3, - "title": "Enable Type and API Suggestions", - "anchor": "enable-type-and-api-suggestions" + "title": "Data Reads", + "anchor": "data-reads" }, { "depth": 3, - "title": "Read On-Chain Data", - "anchor": "read-on-chain-data" + "title": "Data Writes", + "anchor": "data-writes" }, { - "depth": 3, - "title": "Sign and Send Transactions", - "anchor": "sign-and-send-transactions" + "depth": 2, + "title": "Conclusion", + "anchor": "conclusion" }, { "depth": 2, @@ -12585,26 +10037,25 @@ } ], "stats": { - "chars": 8855, - "words": 1100, - "headings": 9, - "estimated_token_count_total": 2300 + "chars": 31207, + "words": 3688, + "headings": 22, + "estimated_token_count_total": 6967 }, - "hash": "sha256:ba24e31e2ad94fbf1d73f1878da92dd2e1476db00170780bbdf0e65ab18bc961", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:b200f93a9179f0b2588ba722dd4c118536136faf3c39eabccf4abf5c346f78a8", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-light-clients", - "title": "Light Clients", - "slug": "reference-tools-light-clients", + "id": "smart-contracts-cookbook-eth-dapps-uniswap-v2", + "title": "Deploying Uniswap V2 on Polkadot", + "slug": "smart-contracts-cookbook-eth-dapps-uniswap-v2", "categories": [ - "Parachains", + "dApps", "Tooling" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-light-clients.md", - "html_url": "https://docs.polkadot.com/reference/tools/light-clients/", - "preview": "Light clients enable secure and efficient blockchain interaction without running a full node. They provide a trust-minimized alternative to JSON-RPC by verifying data through cryptographic proofs rather than blindly trusting remote nodes.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-eth-dapps-uniswap-v2.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/eth-dapps/uniswap-v2/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", "outline": [ { "depth": 2, @@ -12613,56 +10064,54 @@ }, { "depth": 2, - "title": "Light Clients Workflow", - "anchor": "light-clients-workflow" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "JSON-RPC and Light Client Comparison", - "anchor": "json-rpc-and-light-client-comparison" + "title": "Set Up the Project", + "anchor": "set-up-the-project" }, { "depth": 2, - "title": "Using Light Clients", - "anchor": "using-light-clients" + "title": "Understanding Uniswap V2 Architecture", + "anchor": "understanding-uniswap-v2-architecture" }, { - "depth": 3, - "title": "PAPI Light Client Support", - "anchor": "papi-light-client-support" + "depth": 2, + "title": "Test the Contracts", + "anchor": "test-the-contracts" }, { - "depth": 3, - "title": "Substrate Connect - Browser Extension", - "anchor": "substrate-connect-browser-extension" + "depth": 2, + "title": "Deploy the Contracts", + "anchor": "deploy-the-contracts" }, { "depth": 2, - "title": "Resources", - "anchor": "resources" + "title": "Conclusion", + "anchor": "conclusion" } ], "stats": { - "chars": 6490, - "words": 870, + "chars": 11280, + "words": 1560, "headings": 7, - "estimated_token_count_total": 1430 + "estimated_token_count_total": 2671 }, - "hash": "sha256:1284c42be692167e01bcc44e2e134ec20615402675fac26df246c00aa1588d80", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:2a42198668c759f63aa602115bf2d290ec7d03bbc3a3df20e30e85027e1b1cc3", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-moonwall", - "title": "E2E Testing with Moonwall", - "slug": "reference-tools-moonwall", + "id": "smart-contracts-cookbook-smart-contracts-.deploy-basic-pvm", + "title": "Deploy a Basic Contract to Polkadot Hub", + "slug": "smart-contracts-cookbook-smart-contracts-.deploy-basic-pvm", "categories": [ - "Parachains", - "Tooling" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-moonwall.md", - "html_url": "https://docs.polkadot.com/reference/tools/moonwall/", - "preview": "Moonwall is an end-to-end testing framework designed explicitly for Polkadot SDK-based blockchain networks. It addresses one of the most significant challenges in blockchain development: managing complex test environments and network configurations.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-.deploy-basic-pvm.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/.deploy-basic-pvm/", + "preview": "Deploying smart contracts to [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\\_blank} can be accomplished through various tools and environments, each suited to different development workflows. This guide demonstrates how to deploy a basic PolkaVM (PVM) smart contract using four popular approaches: JavaScript with [Ethers.js](https://docs.ethers.org/v6/){target=\\_blank}, [Remix IDE](https://remix.live/){target=\\_blank}, [Hardhat](https://hardhat.org/){target=\\_blank}", "outline": [ { "depth": 2, @@ -12671,332 +10120,547 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "JavaScript with Ethers.js", + "anchor": "javascript-with-ethersjs" }, { - "depth": 2, - "title": "Install Moonwall", - "anchor": "install-moonwall" + "depth": 3, + "title": "Setup", + "anchor": "setup" }, { "depth": 3, - "title": "Global Installation", - "anchor": "global-installation" + "title": "Create and Compile Your Contract", + "anchor": "create-and-compile-your-contract" }, { "depth": 3, - "title": "Local Installation", - "anchor": "local-installation" + "title": "Deploy the Contract", + "anchor": "deploy-the-contract" }, { "depth": 2, - "title": "Initialize Moonwall", - "anchor": "initialize-moonwall" + "title": "Remix IDE", + "anchor": "remix-ide" + }, + { + "depth": 3, + "title": "Access Remix", + "anchor": "access-remix" + }, + { + "depth": 3, + "title": "Compile", + "anchor": "compile" + }, + { + "depth": 3, + "title": "Deploy", + "anchor": "deploy" }, { "depth": 2, - "title": "Writing Tests", - "anchor": "writing-tests" + "title": "Hardhat", + "anchor": "hardhat" + }, + { + "depth": 3, + "title": "Setup", + "anchor": "setup-2" + }, + { + "depth": 3, + "title": "Configure Hardhat", + "anchor": "configure-hardhat" + }, + { + "depth": 3, + "title": "Create Your Contract", + "anchor": "create-your-contract" + }, + { + "depth": 3, + "title": "Compile", + "anchor": "compile-2" + }, + { + "depth": 3, + "title": "Set Up Deployment", + "anchor": "set-up-deployment" + }, + { + "depth": 3, + "title": "Deploy", + "anchor": "deploy-2" }, { "depth": 2, - "title": "Running the Tests", - "anchor": "running-the-tests" + "title": "Foundry", + "anchor": "foundry" + }, + { + "depth": 3, + "title": "Setup", + "anchor": "setup-3" + }, + { + "depth": 3, + "title": "Configure Foundry", + "anchor": "configure-foundry" + }, + { + "depth": 3, + "title": "Create Your Contract", + "anchor": "create-your-contract-2" + }, + { + "depth": 3, + "title": "Compile", + "anchor": "compile-3" + }, + { + "depth": 3, + "title": "Deploy", + "anchor": "deploy-3" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Conclusion", + "anchor": "conclusion" + }, + { + "depth": 3, + "title": "Next Steps", + "anchor": "next-steps" } ], "stats": { - "chars": 10240, - "words": 1295, - "headings": 9, - "estimated_token_count_total": 2453 + "chars": 13872, + "words": 1640, + "headings": 24, + "estimated_token_count_total": 3228 }, - "hash": "sha256:2c77cfb38bb2e466a8f56dabbb706fcd2e90cf1634fc9beb7f0ee95a75735653", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:8f29b0f0b56f8c136206211a858cdc5bc27bcd9119eab179a6cd306182d910cb", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-omninode", - "title": "Polkadot Omni Node", - "slug": "reference-tools-omninode", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-ethers-js", + "title": "JavaScript with Ethers.js", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-ethers-js", "categories": [ - "Parachains", - "Tooling" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-omninode.md", - "html_url": "https://docs.polkadot.com/reference/tools/omninode/", - "preview": "The [`polkadot-omni-node`](https://crates.io/crates/polkadot-omni-node/0.7.0){target=\\_blank} crate is a versatile, pre-built binary designed to simplify running parachains in the Polkadot ecosystem. Unlike traditional node binaries that are tightly coupled to specific runtime code, the `polkadot-omni-node` operates using an external [chain specification](/polkadot-protocol/glossary#chain-specification){target=\\_blank} file, allowing it to adapt dynamically to different parachains.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-ethers-js.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/deploy-basic-ethers-js/", + "preview": "[Ethers.js](https://docs.ethers.org/v6/){target=\\_blank} provides a lightweight approach for deploying contracts using pure JavaScript. This method is ideal for developers who want programmatic control over the deployment process or need to integrate contract deployment into existing applications.", "outline": [ { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "depth": 3, + "title": "Setup", + "anchor": "setup" }, { - "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "depth": 3, + "title": "Create and Compile Your Contract", + "anchor": "create-and-compile-your-contract" + }, + { + "depth": 3, + "title": "Deploy the Contract", + "anchor": "deploy-the-contract" + }, + { + "depth": 3, + "title": "Next Steps", + "anchor": "next-steps" + } + ], + "stats": { + "chars": 6935, + "words": 767, + "headings": 4, + "estimated_token_count_total": 1490 + }, + "hash": "sha256:b0af34b460192f665ca70e7d7985e87b9f59a1a359888f6d14d651daedbcd711", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-foundry", + "title": "Foundry", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-foundry", + "categories": [ + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-foundry.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/deploy-basic-foundry/", + "preview": "[Foundry](https://getfoundry.sh/){target=\\_blank} offers a fast, modular toolkit written in Rust. It's perfect for developers who prefer command-line interfaces and need high-performance compilation and deployment.", + "outline": [ + { + "depth": 3, + "title": "Setup", + "anchor": "setup" + }, + { + "depth": 3, + "title": "Configure Foundry", + "anchor": "configure-foundry" + }, + { + "depth": 3, + "title": "Create Your Contract", + "anchor": "create-your-contract" + }, + { + "depth": 3, + "title": "Compile", + "anchor": "compile" + }, + { + "depth": 3, + "title": "Deploy", + "anchor": "deploy" }, { - "depth": 2, - "title": "Install Polkadot Omni Node", - "anchor": "install-polkadot-omni-node" + "depth": 3, + "title": "Next Steps", + "anchor": "next-steps" + } + ], + "stats": { + "chars": 2125, + "words": 276, + "headings": 6, + "estimated_token_count_total": 429 + }, + "hash": "sha256:f7687b9a1e80ab381cf4fb24f37cccfb98ddf139bf687e8832af99364ef0a8a9", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-hardhat", + "title": "hardhat", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-hardhat", + "categories": [ + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-hardhat.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/deploy-basic-hardhat/", + "preview": "[Hardhat](https://hardhat.org/){target=\\_blank} provides a comprehensive development environment with built-in testing, debugging, and deployment capabilities. It's ideal for professional development workflows and team projects.", + "outline": [ + { + "depth": 3, + "title": "Setup", + "anchor": "setup" }, { - "depth": 2, - "title": "Obtain Chain Specifications", - "anchor": "obtain-chain-specifications" + "depth": 3, + "title": "Configure Hardhat", + "anchor": "configure-hardhat" }, { - "depth": 2, - "title": "Run a Parachain Full Node", - "anchor": "run-a-parachain-full-node" + "depth": 3, + "title": "Create Your Contract", + "anchor": "create-your-contract" }, { - "depth": 2, - "title": "Interact with the Node", - "anchor": "interact-with-the-node" + "depth": 3, + "title": "Compile", + "anchor": "compile" }, { - "depth": 2, - "title": "Parachain Compatibility", - "anchor": "parachain-compatibility" + "depth": 3, + "title": "Set Up Deployment", + "anchor": "set-up-deployment" }, { "depth": 3, - "title": "Required Runtime APIs", - "anchor": "required-runtime-apis" + "title": "Deploy", + "anchor": "deploy" }, { "depth": 3, - "title": "Required Pallets", - "anchor": "required-pallets" + "title": "Next Steps", + "anchor": "next-steps" } ], "stats": { - "chars": 8916, - "words": 1165, - "headings": 9, - "estimated_token_count_total": 2018 + "chars": 3336, + "words": 375, + "headings": 7, + "estimated_token_count_total": 672 }, - "hash": "sha256:a87815deff81936d7f50842f8600004990076c1a33e7e6b408ab954b6ce47259", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:93ca24da15095dd0bb03657f53d27771934aee055c11af529445a50e161f79a3", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-papi", - "title": "Polkadot-API", - "slug": "reference-tools-papi", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-remix", + "title": "Remix IDE", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-remix", "categories": [ - "Tooling", - "Dapps" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-papi.md", - "html_url": "https://docs.polkadot.com/reference/tools/papi/", - "preview": "[Polkadot-API](https://github.com/polkadot-api/polkadot-api){target=\\_blank} (PAPI) is a set of libraries built to be modular, composable, and grounded in a “light-client first” approach. Its primary aim is to equip dApp developers with an extensive toolkit for building fully decentralized applications.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-contract-deploy-basic-remix.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-contract/deploy-basic-remix/", + "preview": "[Remix IDE](https://remix.live/){target=\\_blank} offers a visual, browser-based environment perfect for rapid prototyping and learning. It requires no local installation and provides an intuitive interface for contract development.", "outline": [ - { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" - }, - { - "depth": 2, - "title": "Get Started", - "anchor": "get-started" - }, { "depth": 3, - "title": "API Instantiation", - "anchor": "api-instantiation" + "title": "Access Remix", + "anchor": "access-remix" }, { "depth": 3, - "title": "Reading Chain Data", - "anchor": "reading-chain-data" + "title": "Compile", + "anchor": "compile" }, { "depth": 3, - "title": "Sending Transactions", - "anchor": "sending-transactions" + "title": "Deploy", + "anchor": "deploy" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "depth": 3, + "title": "Next Steps", + "anchor": "next-steps" } ], "stats": { - "chars": 8957, - "words": 1156, - "headings": 6, - "estimated_token_count_total": 1987 + "chars": 2473, + "words": 363, + "headings": 4, + "estimated_token_count_total": 527 }, - "hash": "sha256:2ca93b09d3bb9159bbf53816886a9b242bb3c13b996c51fd52962e049e2d5477", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:56d730c8a6d2ccf0324caf1c3f30929a93904f80e482cfcb457541e04482dbad", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-paraspell", - "title": "ParaSpell XCM SDK", - "slug": "reference-tools-paraspell", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-ethers-js", + "title": "JavaScript with Ethers.js", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-ethers-js", "categories": [ - "Uncategorized" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-paraspell.md", - "html_url": "https://docs.polkadot.com/reference/tools/paraspell/", - "preview": "[ParaSpell](https://paraspell.github.io/docs/){target=\\_blank} is a comprehensive suite of open-source tools designed to simplify cross-chain interactions within the Polkadot ecosystem. At its core, ParaSpell is dedicated to enhancing the functionality of the [XCM (Cross-Consensus Messaging)](/parachains/interoperability/get-started/){target=\\_blank} protocol by providing developers with a unified and streamlined experience for building interoperable decentralized applications (dApps).", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-ethers-js.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-contract-evm/deploy-basic-ethers-js/", + "preview": "[Ethers.js](https://docs.ethers.org/v6/){target=\\_blank} provides a lightweight approach for deploying contracts using pure JavaScript. This method is ideal for developers who want programmatic control over the deployment process or need to integrate contract deployment into existing applications.", "outline": [ { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "depth": 3, + "title": "Setup", + "anchor": "setup" }, { "depth": 3, - "title": "ParaSpell XCM SDK", - "anchor": "paraspell-xcm-sdk" + "title": "Create and Compile Your Contract", + "anchor": "create-and-compile-your-contract" + }, + { + "depth": 3, + "title": "Deploy the Contract", + "anchor": "deploy-the-contract" + }, + { + "depth": 3, + "title": "Next Steps", + "anchor": "next-steps" } ], "stats": { - "chars": 3005, - "words": 433, - "headings": 2, - "estimated_token_count_total": 669 + "chars": 6935, + "words": 767, + "headings": 4, + "estimated_token_count_total": 1490 }, - "hash": "sha256:a7f9c4a03153ee637a0557d2cea0b622c849667ce793b1294bb3299cf036197d", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:b0af34b460192f665ca70e7d7985e87b9f59a1a359888f6d14d651daedbcd711", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-polkadart", - "title": "Polkadart", - "slug": "reference-tools-polkadart", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-foundry", + "title": "Foundry", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-foundry", "categories": [ - "Tooling", - "Dapps" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-polkadart.md", - "html_url": "https://docs.polkadot.com/reference/tools/polkadart/", - "preview": "Polkadart is the most comprehensive Dart/Flutter SDK for interacting with Polkadot, Substrate, and other compatible blockchain networks. Designed with a Dart-first approach and type-safe APIs, it provides everything developers need to build powerful decentralized applications.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-foundry.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-contract-evm/deploy-basic-foundry/", + "preview": "[Foundry](https://getfoundry.sh/){target=\\_blank} offers a fast, modular toolkit written in Rust. It's perfect for developers who prefer command-line interfaces and need high-performance compilation and deployment.", "outline": [ { - "depth": 2, - "title": "Installation", - "anchor": "installation" + "depth": 3, + "title": "Setup", + "anchor": "setup" }, { - "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "depth": 3, + "title": "Configure Foundry", + "anchor": "configure-foundry" }, { "depth": 3, - "title": "Type Generation", - "anchor": "type-generation" + "title": "Create Your Contract", + "anchor": "create-your-contract" }, { "depth": 3, - "title": "Run Generator", - "anchor": "run-generator" + "title": "Compile", + "anchor": "compile" }, { "depth": 3, - "title": "Use Generated Types", - "anchor": "use-generated-types" + "title": "Deploy", + "anchor": "deploy" }, { "depth": 3, - "title": "Creating an API Instance", - "anchor": "creating-an-api-instance" + "title": "Next Steps", + "anchor": "next-steps" + } + ], + "stats": { + "chars": 2125, + "words": 276, + "headings": 6, + "estimated_token_count_total": 429 + }, + "hash": "sha256:f7687b9a1e80ab381cf4fb24f37cccfb98ddf139bf687e8832af99364ef0a8a9", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-hardhat", + "title": "hardhat", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-hardhat", + "categories": [ + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-hardhat.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-contract-evm/deploy-basic-hardhat/", + "preview": "[Hardhat](https://hardhat.org/){target=\\_blank} provides a comprehensive development environment with built-in testing, debugging, and deployment capabilities. It's ideal for professional development workflows and team projects.", + "outline": [ + { + "depth": 3, + "title": "Setup", + "anchor": "setup" }, { "depth": 3, - "title": "Reading Chain Data", - "anchor": "reading-chain-data" + "title": "Configure Hardhat", + "anchor": "configure-hardhat" }, { "depth": 3, - "title": "Subscribe to New Blocks", - "anchor": "subscribe-to-new-blocks" + "title": "Create Your Contract", + "anchor": "create-your-contract" }, { "depth": 3, - "title": "Send a Transaction", - "anchor": "send-a-transaction" + "title": "Compile", + "anchor": "compile" }, { - "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "depth": 3, + "title": "Set Up Deployment", + "anchor": "set-up-deployment" + }, + { + "depth": 3, + "title": "Deploy", + "anchor": "deploy" + }, + { + "depth": 3, + "title": "Next Steps", + "anchor": "next-steps" } ], "stats": { - "chars": 5178, - "words": 624, - "headings": 10, - "estimated_token_count_total": 1084 + "chars": 3336, + "words": 375, + "headings": 7, + "estimated_token_count_total": 672 }, - "hash": "sha256:7f533abe61586af8438e350c41b741d74a8edb839f9dc4139bc4619ba3748258", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:93ca24da15095dd0bb03657f53d27771934aee055c11af529445a50e161f79a3", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-polkadot-js-api", - "title": "Polkadot.js API", - "slug": "reference-tools-polkadot-js-api", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-remix", + "title": "Remix IDE", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-remix", "categories": [ - "Tooling", - "Dapps" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-polkadot-js-api.md", - "html_url": "https://docs.polkadot.com/reference/tools/polkadot-js-api/", - "preview": "!!! warning \"Maintenance Mode Only\" The Polkadot.js API is now in maintenance mode and is no longer actively developed. New projects should use [Dedot](/develop/toolkit/api-libraries/dedot){target=\\_blank} (TypeScript-first API) or [Polkadot API](/develop/toolkit/api-libraries/papi){target=\\_blank} (modern, type-safe API) as actively maintained alternatives.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-contract-evm-deploy-basic-remix.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-contract-evm/deploy-basic-remix/", + "preview": "[Remix IDE](https://remix.live/){target=\\_blank} offers a visual, browser-based environment perfect for rapid prototyping and learning. It requires no local installation and provides an intuitive interface for contract development.", "outline": [ { - "depth": 2, - "title": "Introduction", - "anchor": "introduction" + "depth": 3, + "title": "Access Remix", + "anchor": "access-remix" }, { "depth": 3, - "title": "Dynamic API Generation", - "anchor": "dynamic-api-generation" + "title": "Compile", + "anchor": "compile" }, { "depth": 3, - "title": "Available API Categories", - "anchor": "available-api-categories" + "title": "Deploy", + "anchor": "deploy" }, + { + "depth": 3, + "title": "Next Steps", + "anchor": "next-steps" + } + ], + "stats": { + "chars": 2473, + "words": 363, + "headings": 4, + "estimated_token_count_total": 527 + }, + "hash": "sha256:56d730c8a6d2ccf0324caf1c3f30929a93904f80e482cfcb457541e04482dbad", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-ethers", + "title": "Deploy a Basic Contract with Ethers.js", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-ethers", + "categories": [ + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-ethers.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic/ethers/", + "preview": "This guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub using [Ethers.js](https://docs.ethers.org/v6/){target=\\_blank}, which provides a lightweight approach for deploying contracts using pure JavaScript. This method is ideal for developers who want programmatic control over the deployment process or need to integrate contract deployment into existing applications.", + "outline": [ { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 3, - "title": "Creating an API Instance", - "anchor": "creating-an-api-instance" + "depth": 2, + "title": "Set Up Your Project", + "anchor": "set-up-your-project" }, { - "depth": 3, - "title": "Reading Chain Data", - "anchor": "reading-chain-data" + "depth": 2, + "title": "Create Your Contract", + "anchor": "create-your-contract" }, { - "depth": 3, - "title": "Sending Transactions", - "anchor": "sending-transactions" + "depth": 2, + "title": "Compile", + "anchor": "compile" + }, + { + "depth": 2, + "title": "Deploy", + "anchor": "deploy" }, { "depth": 2, @@ -13005,26 +10669,24 @@ } ], "stats": { - "chars": 5042, - "words": 684, - "headings": 9, - "estimated_token_count_total": 1166 + "chars": 7370, + "words": 823, + "headings": 7, + "estimated_token_count_total": 1729 }, - "hash": "sha256:ed3986f30880fefca5975fcdc847c68b4aca65862c63e3002b25391b0521781d", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:ff8975b44870613c3aef0907df365f1ac981de74ec83019df232fe4bda6d9dbe", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-py-substrate-interface", - "title": "Python Substrate Interface", - "slug": "reference-tools-py-substrate-interface", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-evm", + "title": "Deploy a Basic Contract to EVM", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-evm", "categories": [ - "Tooling", - "Dapps" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-py-substrate-interface.md", - "html_url": "https://docs.polkadot.com/reference/tools/py-substrate-interface/", - "preview": "The [Python Substrate Interface](https://github.com/polkascan/py-substrate-interface){target=\\_blank} is a powerful library that enables interaction with Polkadot SDK-based chains. It provides essential functionality for:", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-evm.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-evm/", + "preview": "Deploying smart contracts to the [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\\_blank} can be accomplished using standard EVM development tools and workflows. This guide demonstrates how to deploy a basic smart contract using four popular EVM approaches: JavaScript with [Ethers.js](https://docs.ethers.org/v6/){target=\\_blank}, [Remix IDE](https://remix.live/){target=\\_blank}, [Hardhat](https://hardhat.org/){target=\\_blank}, and [Foundry](https://getfoundry.sh/){ta", "outline": [ { "depth": 2, @@ -13033,28 +10695,69 @@ }, { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Deployment options", + "anchor": "deployment-options" }, { "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "title": "Conclusion", + "anchor": "conclusion" }, { "depth": 3, - "title": "Establishing Connection", - "anchor": "establishing-connection" + "title": "Next Steps", + "anchor": "next-steps" + } + ], + "stats": { + "chars": 15629, + "words": 1659, + "headings": 4, + "estimated_token_count_total": 3341 + }, + "hash": "sha256:a4fd853afb897985602e0356551edacbce77db60bbc6556de3b6ae5af3fbc9e5", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-foundry", + "title": "Deploy a Basic Contract with Foundry", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-foundry", + "categories": [ + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-foundry.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic/foundry/", + "preview": "This guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub using [Foundry](https://getfoundry.sh/){target=\\_blank}, which offers a fast, modular toolkit written in Rust. It's perfect for developers who prefer command-line interfaces and need high-performance compilation and deployment.", + "outline": [ + { + "depth": 2, + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 3, - "title": "Reading Chain State", - "anchor": "reading-chain-state" + "depth": 2, + "title": "Set Up Your Project", + "anchor": "set-up-your-project" }, { - "depth": 3, - "title": "Submitting Transactions", - "anchor": "submitting-transactions" + "depth": 2, + "title": "Configure Foundry", + "anchor": "configure-foundry" + }, + { + "depth": 2, + "title": "Create Your Contract", + "anchor": "create-your-contract" + }, + { + "depth": 2, + "title": "Compile", + "anchor": "compile" + }, + { + "depth": 2, + "title": "Deploy", + "anchor": "deploy" }, { "depth": 2, @@ -13063,26 +10766,24 @@ } ], "stats": { - "chars": 4302, - "words": 541, + "chars": 2731, + "words": 355, "headings": 7, - "estimated_token_count_total": 942 + "estimated_token_count_total": 598 }, - "hash": "sha256:8987fc35cd28602054ee018031f773e2e3837425107c51d0e2ac68a94b86e9c0", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:63defd84f302f0778c90129abbe69ecd2a5d9d83c622f2b7e5c2ffc9bcb3312f", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-sidecar", - "title": "Sidecar REST API", - "slug": "reference-tools-sidecar", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-hardhat", + "title": "Deploy a Basic Contract with Hardhat", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-hardhat", "categories": [ - "Tooling", - "Dapps" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-sidecar.md", - "html_url": "https://docs.polkadot.com/reference/tools/sidecar/", - "preview": "The [Sidecar REST API](https://github.com/paritytech/substrate-api-sidecar){target=\\_blank} is a service that provides a REST interface for interacting with Polkadot SDK-based blockchains. With this API, developers can easily access a broad range of endpoints for nodes, accounts, transactions, parachains, and more.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-hardhat.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat/", + "preview": "This guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub using [Hardhat](https://hardhat.org/){target=\\_blank}, which provides a comprehensive development environment with built-in testing, debugging, and deployment capabilities. It's ideal for professional development workflows and team projects.", "outline": [ { "depth": 2, @@ -13096,18 +10797,33 @@ }, { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Set Up Your Project", + "anchor": "set-up-your-project" }, { "depth": 2, - "title": "Usage", - "anchor": "usage" + "title": "Configure Hardhat", + "anchor": "configure-hardhat" }, { - "depth": 3, - "title": "Endpoints", - "anchor": "endpoints" + "depth": 2, + "title": "Create Your Contract", + "anchor": "create-your-contract" + }, + { + "depth": 2, + "title": "Compile", + "anchor": "compile" + }, + { + "depth": 2, + "title": "Set Up Deployment", + "anchor": "set-up-deployment" + }, + { + "depth": 2, + "title": "Deploy the Contract", + "anchor": "deploy-the-contract" }, { "depth": 2, @@ -13116,26 +10832,24 @@ } ], "stats": { - "chars": 7309, - "words": 1033, - "headings": 6, - "estimated_token_count_total": 1945 + "chars": 4051, + "words": 475, + "headings": 9, + "estimated_token_count_total": 981 }, - "hash": "sha256:0795462182cb97256bb5c2acb035855fe0d6557185de8ac99482725ecb4f94c1", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:98f5c5c1a26db913e1c4c435062d214ca8c4b5f2dbed5b64d2e54c3435f06452", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-subxt", - "title": "Subxt Rust API", - "slug": "reference-tools-subxt", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-pvm", + "title": "Deploy a Basic Contract to Polkadot Hub", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-pvm", "categories": [ - "Tooling", - "Dapps" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-subxt.md", - "html_url": "https://docs.polkadot.com/reference/tools/subxt/", - "preview": "Subxt is a Rust library designed to interact with Polkadot SDK-based blockchains. It provides a type-safe interface for submitting transactions, querying on-chain state, and performing other blockchain interactions. By leveraging Rust's strong type system, subxt ensures that your code is validated at compile time, reducing runtime errors and improving reliability.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-pvm.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic-pvm/", + "preview": "Deploying smart contracts to [Polkadot Hub](/smart-contracts/overview/#smart-contract-development){target=\\_blank} can be accomplished through various tools and environments, each suited to different development workflows. This guide demonstrates how to deploy a basic PolkaVM (PVM) smart contract using four popular approaches: JavaScript with [Ethers.js](https://docs.ethers.org/v6/){target=\\_blank}, [Remix IDE](https://remix.live/){target=\\_blank}, [Hardhat](https://hardhat.org/){target=\\_blank}", "outline": [ { "depth": 2, @@ -13144,72 +10858,139 @@ }, { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "JavaScript with Ethers.js", + "anchor": "javascript-with-ethersjs" + }, + { + "depth": 3, + "title": "Setup", + "anchor": "setup" + }, + { + "depth": 3, + "title": "Create and Compile Your Contract", + "anchor": "create-and-compile-your-contract" + }, + { + "depth": 3, + "title": "Deploy the Contract", + "anchor": "deploy-the-contract" }, { "depth": 2, - "title": "Installation", - "anchor": "installation" + "title": "Remix IDE", + "anchor": "remix-ide" + }, + { + "depth": 3, + "title": "Access Remix", + "anchor": "access-remix" + }, + { + "depth": 3, + "title": "Compile", + "anchor": "compile" + }, + { + "depth": 3, + "title": "Deploy", + "anchor": "deploy" }, { "depth": 2, - "title": "Get Started", - "anchor": "get-started" + "title": "Hardhat", + "anchor": "hardhat" }, { "depth": 3, - "title": "Download Chain Metadata", - "anchor": "download-chain-metadata" + "title": "Setup", + "anchor": "setup-2" }, { "depth": 3, - "title": "Generate Type-Safe Interfaces", - "anchor": "generate-type-safe-interfaces" + "title": "Configure Hardhat", + "anchor": "configure-hardhat" }, { "depth": 3, - "title": "Initialize the Subxt Client", - "anchor": "initialize-the-subxt-client" + "title": "Create Your Contract", + "anchor": "create-your-contract" }, { "depth": 3, - "title": "Read Chain Data", - "anchor": "read-chain-data" + "title": "Compile", + "anchor": "compile-2" }, { "depth": 3, - "title": "Submit Transactions", - "anchor": "submit-transactions" + "title": "Set Up Deployment", + "anchor": "set-up-deployment" + }, + { + "depth": 3, + "title": "Deploy", + "anchor": "deploy-2" }, { "depth": 2, - "title": "Where to Go Next", - "anchor": "where-to-go-next" + "title": "Foundry", + "anchor": "foundry" + }, + { + "depth": 3, + "title": "Setup", + "anchor": "setup-3" + }, + { + "depth": 3, + "title": "Configure Foundry", + "anchor": "configure-foundry" + }, + { + "depth": 3, + "title": "Create Your Contract", + "anchor": "create-your-contract-2" + }, + { + "depth": 3, + "title": "Compile", + "anchor": "compile-3" + }, + { + "depth": 3, + "title": "Deploy", + "anchor": "deploy-3" + }, + { + "depth": 2, + "title": "Conclusion", + "anchor": "conclusion" + }, + { + "depth": 3, + "title": "Next Steps", + "anchor": "next-steps" } ], "stats": { - "chars": 9174, - "words": 1175, - "headings": 10, - "estimated_token_count_total": 2187 + "chars": 13872, + "words": 1640, + "headings": 24, + "estimated_token_count_total": 3228 }, - "hash": "sha256:56269d9ea47f5b4e92cd7d5a1e65ab06d181a9c380f90bb3ef285529b12299f7", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:8f29b0f0b56f8c136206211a858cdc5bc27bcd9119eab179a6cd306182d910cb", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-xcm-tools", - "title": "XCM Tools", - "slug": "reference-tools-xcm-tools", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic-remix", + "title": "Deploy a Basic Contract with Remix IDE", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic-remix", "categories": [ - "Basics", - "Tooling", - "Dapps" + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-xcm-tools.md", - "html_url": "https://docs.polkadot.com/reference/tools/xcm-tools/", - "preview": "As described in the [Interoperability](/develop/interoperability){target=\\_blank} section, XCM (Cross-Consensus Messaging) is a protocol used in the Polkadot and Kusama ecosystems to enable communication and interaction between chains. It facilitates cross-chain communication, allowing assets, data, and messages to flow seamlessly across the ecosystem.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic-remix.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic/remix/", + "preview": "This guide demonstrates how to deploy a basic Solidity smart contract to Polkadot Hub using [Remix IDE](https://remix.ethereum.org/){target=\\_blank}, which offers a visual, browser-based environment perfect for rapid prototyping and learning. It requires no local installation and provides an intuitive interface for contract development.", "outline": [ { "depth": 2, @@ -13218,54 +10999,48 @@ }, { "depth": 2, - "title": "Popular XCM Tools", - "anchor": "popular-xcm-tools" - }, - { - "depth": 3, - "title": "Moonsong Labs XCM Tools", - "anchor": "moonsong-labs-xcm-tools" + "title": "Prerequisites", + "anchor": "prerequisites" }, { - "depth": 3, - "title": "ParaSpell", - "anchor": "paraspell" + "depth": 2, + "title": "Access Remix", + "anchor": "access-remix" }, { - "depth": 3, - "title": "Astar XCM Tools", - "anchor": "astar-xcm-tools" + "depth": 2, + "title": "Compile", + "anchor": "compile" }, { - "depth": 3, - "title": "Chopsticks", - "anchor": "chopsticks" + "depth": 2, + "title": "Deploy", + "anchor": "deploy" }, { - "depth": 3, - "title": "Moonbeam XCM SDK", - "anchor": "moonbeam-xcm-sdk" + "depth": 2, + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 7524, - "words": 1043, - "headings": 7, - "estimated_token_count_total": 1700 + "chars": 2978, + "words": 430, + "headings": 6, + "estimated_token_count_total": 738 }, - "hash": "sha256:47328231d6ff4dc52cd93aaf1baf5d0bc2d9fc372f3d79339d87aafa0dabd1b8", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:0c00544ba0be9c0a6fa0c54bdb38045d64e95af714785b86e57f885a03b4b17a", "token_estimator": "heuristic-v1" }, { - "id": "reference-tools-zombienet", - "title": "reference-tools-zombienet", - "slug": "reference-tools-zombienet", + "id": "smart-contracts-cookbook-smart-contracts-deploy-basic", + "title": "smart-contracts-cookbook-smart-contracts-deploy-basic", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic", "categories": [ "Uncategorized" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-zombienet.md", - "html_url": "https://docs.polkadot.com/reference/tools/zombienet/", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic/", "preview": "TODO", "outline": [], "stats": { @@ -13275,29 +11050,49 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:15+00:00", "token_estimator": "heuristic-v1" }, { - "id": "smart-contracts-connect", - "title": "Connect to Polkadot", - "slug": "smart-contracts-connect", + "id": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-remix", + "title": "Deploy an ERC-20 to Polkadot Hub", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-remix", "categories": [ + "Basics", "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-connect.md", - "html_url": "https://docs.polkadot.com/smart-contracts/connect/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-remix.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-remix/", + "preview": "[ERC-20](https://eips.ethereum.org/EIPS/eip-20){target=\\_blank} tokens are fungible tokens commonly used for creating cryptocurrencies, governance tokens, and staking mechanisms. Polkadot Hub enables easy token deployment with Ethereum-compatible smart contracts and tools via the EVM backend.", "outline": [ { "depth": 2, - "title": "Networks Details", - "anchor": "networks-details" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Test Tokens", - "anchor": "test-tokens" + "title": "Prerequisites", + "anchor": "prerequisites" + }, + { + "depth": 2, + "title": "Create Your Contract", + "anchor": "create-your-contract" + }, + { + "depth": 2, + "title": "Compile", + "anchor": "compile" + }, + { + "depth": 2, + "title": "Deploy", + "anchor": "deploy" + }, + { + "depth": 2, + "title": "Interact with Your Contract", + "anchor": "interact-with-your-contract" }, { "depth": 2, @@ -13306,131 +11101,108 @@ } ], "stats": { - "chars": 3459, - "words": 476, - "headings": 3, - "estimated_token_count_total": 558 + "chars": 9109, + "words": 1260, + "headings": 7, + "estimated_token_count_total": 2182 }, - "hash": "sha256:a2490223926957381913ae0ed22e2df3611a6713ec9d77a3015d1cd6a578b3f6", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:0cb418d465a51230ece5d3a56d64754f979bc6c4ad78f2cc3df537b99739e627", "token_estimator": "heuristic-v1" }, { - "id": "smart-contracts-cookbook-dapps-zero-to-hero", - "title": "Zero to Hero Smart Contract DApp", - "slug": "smart-contracts-cookbook-dapps-zero-to-hero", + "id": "smart-contracts-cookbook-smart-contracts-deploy-erc20", + "title": "Deploy an ERC-20 to Polkadot Hub", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-erc20", "categories": [ - "dApp", - "Tooling" + "Basics", + "dApps", + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md", - "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/dapps/zero-to-hero/", - "preview": "Decentralized applications (dApps) are a key component of the Web3 ecosystem, enabling developers to build applications that communicate directly with blockchain networks. Polkadot Hub, a blockchain with smart contract support, serves as a robust platform for deploying and interacting with dApps.", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-erc20/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", "outline": [ { "depth": 2, - "title": "Prerequisites", - "anchor": "prerequisites" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Project Overview", - "anchor": "project-overview" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "Create and Deploy the Storage Contract", - "anchor": "create-and-deploy-the-storage-contract" - }, - { - "depth": 3, - "title": "Set Up Hardhat Project", - "anchor": "set-up-hardhat-project" - }, - { - "depth": 3, - "title": "Create the Storage Contract", - "anchor": "create-the-storage-contract" - }, - { - "depth": 3, - "title": "Configure Hardhat for Polkadot Hub", - "anchor": "configure-hardhat-for-polkadot-hub" + "title": "Create the ERC-20 Contract", + "anchor": "create-the-erc-20-contract" }, { - "depth": 3, + "depth": 2, "title": "Compile the Contract", "anchor": "compile-the-contract" }, { - "depth": 3, + "depth": 2, "title": "Deploy the Contract", "anchor": "deploy-the-contract" }, - { - "depth": 3, - "title": "Export the Contract ABI", - "anchor": "export-the-contract-abi" - }, - { - "depth": 2, - "title": "Set Up the dApp Project", - "anchor": "set-up-the-dapp-project" - }, - { - "depth": 2, - "title": "Install Dependencies", - "anchor": "install-dependencies" - }, { "depth": 2, - "title": "Connect to Polkadot Hub", - "anchor": "connect-to-polkadot-hub" - }, + "title": "Interact with Your ERC-20 Contract", + "anchor": "interact-with-your-erc-20-contract" + } + ], + "stats": { + "chars": 8926, + "words": 1207, + "headings": 6, + "estimated_token_count_total": 2107 + }, + "hash": "sha256:296cba75b1d49aefa1b8636ba95ca20c3431b7eb0e93b0658add671ef5801732", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-cookbook-smart-contracts-deploy-nft-ethers", + "title": "Deploy an NFT to Polkadot Hub with Ethers.js", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-nft-ethers", + "categories": [ + "Basics", + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-ethers.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-nft/ethers/", + "preview": "Non-Fungible Tokens (NFTs) represent unique digital assets commonly used for digital art, collectibles, gaming, and identity verification.", + "outline": [ { "depth": 2, - "title": "Set Up the Smart Contract Interface", - "anchor": "set-up-the-smart-contract-interface" + "title": "Introduction", + "anchor": "introduction" }, { "depth": 2, - "title": "Create the Wallet Connection Component", - "anchor": "create-the-wallet-connection-component" + "title": "Prerequisites", + "anchor": "prerequisites" }, { "depth": 2, - "title": "Create the Read Contract Component", - "anchor": "create-the-read-contract-component" + "title": "Set Up Your Project", + "anchor": "set-up-your-project" }, { "depth": 2, - "title": "Create the Write Contract Component", - "anchor": "create-the-write-contract-component" + "title": "Create Your Contract", + "anchor": "create-your-contract" }, { "depth": 2, - "title": "How It Works", - "anchor": "how-it-works" - }, - { - "depth": 3, - "title": "Wallet Connection", - "anchor": "wallet-connection" - }, - { - "depth": 3, - "title": "Data Reads", - "anchor": "data-reads" - }, - { - "depth": 3, - "title": "Data Writes", - "anchor": "data-writes" + "title": "Compile", + "anchor": "compile" }, { "depth": 2, - "title": "Conclusion", - "anchor": "conclusion" + "title": "Deploy", + "anchor": "deploy" }, { "depth": 2, @@ -13439,26 +11211,25 @@ } ], "stats": { - "chars": 31203, - "words": 3688, - "headings": 22, - "estimated_token_count_total": 6967 + "chars": 8114, + "words": 912, + "headings": 7, + "estimated_token_count_total": 2015 }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:fdd65f6fe6d109043f11a26f1477e2bbbce1a440dbcb2b191eacfa79a28766e9", "token_estimator": "heuristic-v1" }, { - "id": "smart-contracts-cookbook-eth-dapps-uniswap-v2", - "title": "Deploying Uniswap V2 on Polkadot", - "slug": "smart-contracts-cookbook-eth-dapps-uniswap-v2", + "id": "smart-contracts-cookbook-smart-contracts-deploy-nft-foundry", + "title": "Deploy an NFT to Polkadot Hub with Foundry", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-nft-foundry", "categories": [ - "dApps", - "Tooling" + "Basics", + "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-eth-dapps-uniswap-v2.md", - "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/eth-dapps/uniswap-v2/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-foundry.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-nft/foundry/", + "preview": "Non-Fungible Tokens (NFTs) represent unique digital assets commonly used for digital art, collectibles, gaming, and identity verification.", "outline": [ { "depth": 2, @@ -13472,73 +11243,55 @@ }, { "depth": 2, - "title": "Set Up the Project", - "anchor": "set-up-the-project" + "title": "Set Up Your Project", + "anchor": "set-up-your-project" }, { "depth": 2, - "title": "Understanding Uniswap V2 Architecture", - "anchor": "understanding-uniswap-v2-architecture" + "title": "Configure Foundry", + "anchor": "configure-foundry" }, { "depth": 2, - "title": "Test the Contracts", - "anchor": "test-the-contracts" + "title": "Create Your Contract", + "anchor": "create-your-contract" }, { "depth": 2, - "title": "Deploy the Contracts", - "anchor": "deploy-the-contracts" + "title": "Compile", + "anchor": "compile" }, { "depth": 2, - "title": "Conclusion", - "anchor": "conclusion" + "title": "Deploy", + "anchor": "deploy" + }, + { + "depth": 2, + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 11280, - "words": 1560, - "headings": 7, - "estimated_token_count_total": 2671 - }, - "hash": "sha256:2a42198668c759f63aa602115bf2d290ec7d03bbc3a3df20e30e85027e1b1cc3", - "last_modified": "2025-10-28T14:42:15+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "smart-contracts-cookbook-smart-contracts-deploy-basic", - "title": "smart-contracts-cookbook-smart-contracts-deploy-basic", - "slug": "smart-contracts-cookbook-smart-contracts-deploy-basic", - "categories": [ - "Uncategorized" - ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic.md", - "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-basic/", - "preview": "TODO", - "outline": [], - "stats": { - "chars": 5, - "words": 1, - "headings": 0, - "estimated_token_count_total": 0 + "chars": 3489, + "words": 438, + "headings": 8, + "estimated_token_count_total": 847 }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:c4b410125946db479b9c262a5132a31bb7730a778501c3a95910ad9d38007cf4", "token_estimator": "heuristic-v1" }, { - "id": "smart-contracts-cookbook-smart-contracts-deploy-erc20", - "title": "Deploy an ERC-20 to Polkadot Hub", - "slug": "smart-contracts-cookbook-smart-contracts-deploy-erc20", + "id": "smart-contracts-cookbook-smart-contracts-deploy-nft-hardhat", + "title": "Deploy an NFT to Polkadot Hub with Hardhat", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-nft-hardhat", "categories": [ "Basics", - "dApps", "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20.md", - "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-erc20/", - "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-hardhat.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-nft/hardhat/", + "preview": "Non-Fungible Tokens (NFTs) represent unique digital assets commonly used for digital art, collectibles, gaming, and identity verification.", "outline": [ { "depth": 2, @@ -13552,45 +11305,59 @@ }, { "depth": 2, - "title": "Create the ERC-20 Contract", - "anchor": "create-the-erc-20-contract" + "title": "Set Up Your Project", + "anchor": "set-up-your-project" }, { "depth": 2, - "title": "Compile the Contract", - "anchor": "compile-the-contract" + "title": "Configure Hardhat", + "anchor": "configure-hardhat" }, { "depth": 2, - "title": "Deploy the Contract", - "anchor": "deploy-the-contract" + "title": "Create Your Contract", + "anchor": "create-your-contract" }, { "depth": 2, - "title": "Interact with Your ERC-20 Contract", - "anchor": "interact-with-your-erc-20-contract" + "title": "Compile", + "anchor": "compile" + }, + { + "depth": 2, + "title": "Set Up Deployment", + "anchor": "set-up-deployment" + }, + { + "depth": 2, + "title": "Deploy", + "anchor": "deploy" + }, + { + "depth": 2, + "title": "Where to Go Next", + "anchor": "where-to-go-next" } ], "stats": { - "chars": 8926, - "words": 1207, - "headings": 6, - "estimated_token_count_total": 2107 + "chars": 4745, + "words": 550, + "headings": 9, + "estimated_token_count_total": 1137 }, - "hash": "sha256:296cba75b1d49aefa1b8636ba95ca20c3431b7eb0e93b0658add671ef5801732", - "last_modified": "2025-10-28T14:42:15+00:00", + "hash": "sha256:f787f9c66787c53aa5c6fccf30d622b2b617794d1292641ea256e0896d418b28", "token_estimator": "heuristic-v1" }, { - "id": "smart-contracts-cookbook-smart-contracts-deploy-nft-ethers", - "title": "Deploy an NFT to Polkadot Hub with Ethers.js", - "slug": "smart-contracts-cookbook-smart-contracts-deploy-nft-ethers", + "id": "smart-contracts-cookbook-smart-contracts-deploy-nft-remix", + "title": "Deploy an NFT to Polkadot Hub with Remix", + "slug": "smart-contracts-cookbook-smart-contracts-deploy-nft-remix", "categories": [ "Basics", "Smart Contracts" ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-ethers.md", - "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-nft/ethers/", + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-remix.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-nft/remix/", "preview": "Non-Fungible Tokens (NFTs) represent unique digital assets commonly used for digital art, collectibles, gaming, and identity verification.", "outline": [ { @@ -13605,8 +11372,8 @@ }, { "depth": 2, - "title": "Set Up Your Project", - "anchor": "set-up-your-project" + "title": "Access Remix", + "anchor": "access-remix" }, { "depth": 2, @@ -13630,13 +11397,50 @@ } ], "stats": { - "chars": 8114, - "words": 912, + "chars": 3754, + "words": 505, "headings": 7, - "estimated_token_count_total": 2015 + "estimated_token_count_total": 928 + }, + "hash": "sha256:12a8debfbc05c5ac0e2c94daa40167adab837dc4e1b2731f5b48ae8bc9bc2c93", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-cookbook", + "title": "Smart Contracts Cookbook Index", + "slug": "smart-contracts-cookbook", + "categories": [ + "Basics", + "dApps", + "Smart Contracts" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook.md", + "html_url": "https://docs.polkadot.com/smart-contracts/cookbook/", + "preview": "Welcome to the Polkadot smart contracts cookbook index.", + "outline": [ + { + "depth": 2, + "title": "Get Tokens from the Faucet", + "anchor": "get-tokens-from-the-faucet" + }, + { + "depth": 2, + "title": "EVM/PVM Smart Contracts", + "anchor": "evmpvm-smart-contracts" + }, + { + "depth": 2, + "title": "Port Ethereum DApps", + "anchor": "port-ethereum-dapps" + } + ], + "stats": { + "chars": 1586, + "words": 204, + "headings": 3, + "estimated_token_count_total": 406 }, - "hash": "sha256:4e3ac6affdbe93ce9d132cbb838be1dfaf7a629b0e1f10ce4d90cc3899d656cb", - "last_modified": "2025-10-28T14:42:16+00:00", + "hash": "sha256:ea0d085c376117436a9cf68e786da942cf88993651d4e06550f9ee03d2e810f4", "token_estimator": "heuristic-v1" }, { @@ -13657,7 +11461,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13678,7 +11481,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13755,7 +11557,6 @@ "estimated_token_count_total": 6228 }, "hash": "sha256:72e41f816f07026d96c803f399c71852aa1151c464e79cec3e1746b282d5eaae", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13776,7 +11577,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13797,7 +11597,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13818,7 +11617,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13839,7 +11637,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13860,7 +11657,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13938,7 +11734,6 @@ "estimated_token_count_total": 4190 }, "hash": "sha256:1729ad83ad381a90752540644d400c60add3555e5da296ab455442be81d32f8c", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13959,7 +11754,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -13980,7 +11774,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14001,7 +11794,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14043,7 +11835,6 @@ "estimated_token_count_total": 2430 }, "hash": "sha256:e3d8b84cb2cee7010978582998b2269296a042aec53fb016388690ab6adf355e", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14064,7 +11855,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14127,7 +11917,6 @@ "estimated_token_count_total": 1347 }, "hash": "sha256:7589fa1dbdbf5748892ab6d42fc784d833f33e254bd3f95ee58424effcd38323", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14148,7 +11937,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14169,7 +11957,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14212,7 +11999,6 @@ "estimated_token_count_total": 309 }, "hash": "sha256:93e8a3043d65583e3d66f8f5f0ed6f4ef89a908ef85da2b6ca906a1100b7dded", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14249,7 +12035,6 @@ "estimated_token_count_total": 313 }, "hash": "sha256:c609bc98cba5efa2d2a808548cf93ad9d0a06455b35a8fd9f534daf52824f506", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14317,7 +12102,6 @@ "estimated_token_count_total": 1818 }, "hash": "sha256:f50cd1177dd4aff8eb031d6f21cb640f8187a7f2dd0edcaef5c73354a378e44d", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14380,7 +12164,6 @@ "estimated_token_count_total": 1182 }, "hash": "sha256:9542f40acae725e628f4c3155ad1e7e0e18b2eb518484856ad439a1d9f86d1f3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14463,7 +12246,6 @@ "estimated_token_count_total": 1133 }, "hash": "sha256:0792e3956242eb8e08ab82e2d73964c381074cc8b1ea46f396d136856fa6cc07", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14577,7 +12359,6 @@ "estimated_token_count_total": 1046 }, "hash": "sha256:dd29fab6e3c00d720b10effa4e50373a6fe9ab4b7bfd3aea892c7fa9c84318a2", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14774,28 +12555,87 @@ "estimated_token_count_total": 9750 }, "hash": "sha256:1fb7a20bc4a799a771954720428029419ec73afa640e589590c43dd041a7e307", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { "id": "smart-contracts-for-eth-devs-migration", - "title": "smart-contracts-for-eth-devs-migration", + "title": "Migration FAQs and Considerations", "slug": "smart-contracts-for-eth-devs-migration", "categories": [ - "Uncategorized" + "Smart Contracts" ], "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-migration.md", "html_url": "https://docs.polkadot.com/smart-contracts/for-eth-devs/migration/", - "preview": "TODO", - "outline": [], + "preview": "This guide helps Ethereum developers migrate their smart contracts to Polkadot Hub. Most contracts work without modifications on the REVM backend, while the PolkaVM backend offers enhanced performance with minimal adaptation for standard patterns.", + "outline": [ + { + "depth": 2, + "title": "Introduction", + "anchor": "introduction" + }, + { + "depth": 2, + "title": "Migration Considerations", + "anchor": "migration-considerations" + }, + { + "depth": 2, + "title": "Migration Checklist", + "anchor": "migration-checklist" + }, + { + "depth": 2, + "title": "Migration FAQs", + "anchor": "migration-faqs" + }, + { + "depth": 3, + "title": "Which backend should I choose?", + "anchor": "which-backend-should-i-choose" + }, + { + "depth": 3, + "title": "Do I need to rewrite my Solidity code?", + "anchor": "do-i-need-to-rewrite-my-solidity-code" + }, + { + "depth": 3, + "title": "What about factory contracts?", + "anchor": "what-about-factory-contracts" + }, + { + "depth": 3, + "title": "How do gas costs compare?", + "anchor": "how-do-gas-costs-compare" + }, + { + "depth": 3, + "title": "Which Solidity features are not supported?", + "anchor": "which-solidity-features-are-not-supported" + }, + { + "depth": 3, + "title": "How do I handle the existential deposit?", + "anchor": "how-do-i-handle-the-existential-deposit" + }, + { + "depth": 3, + "title": "Can I use my existing development tools?", + "anchor": "can-i-use-my-existing-development-tools" + }, + { + "depth": 2, + "title": "Conclusion", + "anchor": "conclusion" + } + ], "stats": { - "chars": 5, - "words": 1, - "headings": 0, - "estimated_token_count_total": 0 + "chars": 6247, + "words": 803, + "headings": 12, + "estimated_token_count_total": 1322 }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", + "hash": "sha256:bf9b21750158389c387b92f2165947e5f5cff752f5d163680ee37493710e81d7", "token_estimator": "heuristic-v1" }, { @@ -14853,7 +12693,6 @@ "estimated_token_count_total": 2840 }, "hash": "sha256:224a9f69d4613a5f1afdbc1f05379add8321fe159e32c71db003bbe08ff8e976", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14874,7 +12713,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14895,7 +12733,6 @@ "estimated_token_count_total": 0 }, "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -14948,7 +12785,6 @@ "estimated_token_count_total": 1627 }, "hash": "sha256:65809486f62f60c6a6ac8109f9f027361683c23f639991a045ec5c057b665026", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15036,7 +12872,6 @@ "estimated_token_count_total": 4474 }, "hash": "sha256:c74a28d8d62369591c5734535136508db3d1f7380e486fd214f98d433cafd6e7", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15129,7 +12964,6 @@ "estimated_token_count_total": 3891 }, "hash": "sha256:e27657e4e4a14fe86f424b96631946ec36fb90d277e6010b6cbd64c4769aba8a", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15202,7 +13036,6 @@ "estimated_token_count_total": 3250 }, "hash": "sha256:bc771f912627fa09cad64adab1bc81c052f650d6c5a3b4f0c91883a98f6628da", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15275,7 +13108,6 @@ "estimated_token_count_total": 3035 }, "hash": "sha256:f0d36333d0d3afff7f6374a61d0f6d1fb878c9ef4c4e4c24447745661dbe59d0", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15328,7 +13160,6 @@ "estimated_token_count_total": 2509 }, "hash": "sha256:205892e350168b3d0da7ccc280c67c3217ad1e45e87a53d124fa1dd69661aa5e", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15401,7 +13232,6 @@ "estimated_token_count_total": 1122 }, "hash": "sha256:ee87115c828928c82937de26f5f938cecd4c3bb1225fdb61627e8092e6ea5951", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15413,37 +13243,36 @@ ], "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-precompiles-eth-native.md", "html_url": "https://docs.polkadot.com/smart-contracts/precompiles/eth-native/", - "preview": "TODO", - "outline": [], - "stats": { - "chars": 5, - "words": 1, - "headings": 0, - "estimated_token_count_total": 0 - }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", - "token_estimator": "heuristic-v1" - }, - { - "id": "smart-contracts-precompiles-staking", - "title": "smart-contracts-precompiles-staking", - "slug": "smart-contracts-precompiles-staking", - "categories": [ - "Uncategorized" + "preview": "Ethereum-native precompiles are special contract implementations that provide essential cryptographic and utility functions at the runtime level. These precompiles are available at predefined addresses and offer optimized, native implementations of commonly used operations that would be computationally expensive or impractical to implement in pure contract code.", + "outline": [ + { + "depth": 2, + "title": "Introduction", + "anchor": "introduction" + }, + { + "depth": 2, + "title": "How to Use Precompiles", + "anchor": "how-to-use-precompiles" + }, + { + "depth": 2, + "title": "Standard Precompiles in Polkadot Hub", + "anchor": "standard-precompiles-in-polkadot-hub" + }, + { + "depth": 2, + "title": "Conclusion", + "anchor": "conclusion" + } ], - "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-precompiles-staking.md", - "html_url": "https://docs.polkadot.com/smart-contracts/precompiles/staking/", - "preview": "TODO", - "outline": [], "stats": { "chars": 5232, "words": 532, "headings": 4, "estimated_token_count_total": 1192 }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", - "last_modified": "2025-10-28T14:42:16+00:00", + "hash": "sha256:f17db5daca8feae70ce428e03a5a4870ef87dfc8571b07376327cd80d057b759", "token_estimator": "heuristic-v1" }, { @@ -15509,8 +13338,43 @@ "headings": 9, "estimated_token_count_total": 2325 }, - "hash": "sha256:4856172c6356357818234a3b7f0828716bd32e6192f3609c51de0cafcc5a75e7", - "last_modified": "2025-10-28T14:42:16+00:00", + "hash": "sha256:c084190ea7d676128e7e399e8fe88598ca150f88d684db279a687ee1c3956120", + "token_estimator": "heuristic-v1" + }, + { + "id": "smart-contracts-precompiles", + "title": "Advanced Functionalities via Precompiles", + "slug": "smart-contracts-precompiles", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-precompiles.md", + "html_url": "https://docs.polkadot.com/smart-contracts/precompiles/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. ## Introduction", + "outline": [ + { + "depth": 2, + "title": "Introduction", + "anchor": "introduction" + }, + { + "depth": 2, + "title": "What are Precompiles?", + "anchor": "what-are-precompiles" + }, + { + "depth": 2, + "title": "Conclusion", + "anchor": "conclusion" + } + ], + "stats": { + "chars": 2525, + "words": 328, + "headings": 3, + "estimated_token_count_total": 412 + }, + "hash": "sha256:a40e3f34f70db22bfe39e40d68dc5a53a726ce47cb73b602d8605355c61ffd22", "token_estimator": "heuristic-v1" }, { @@ -15577,7 +13441,6 @@ "estimated_token_count_total": 2249 }, "hash": "sha256:1368f6d49bccb7ba0e642cc58ea2c97ca95ae45e390cb9fa2ab11b0b41de52f4", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15608,9 +13471,7 @@ "headings": 2, "estimated_token_count_total": 198 }, - "hash": "sha256:96acff10be56dea76acdb5c915c1dde0eb15eb12eb95e7871eef56bab6cda273", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:467765777cace42ab4e3f1bb36c94f97e655c5d2cd570e00dd747c6a3db043f7", "token_estimator": "heuristic-v1" }, { @@ -15646,9 +13507,7 @@ "headings": 3, "estimated_token_count_total": 208 }, - "hash": "sha256:61bc251929352f2299ca1d413d05aa9c3672b914575a285d73c7ba53dbd75bff", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:3a6704a6330c6e35aa98fe8d615e2e27beb870a48c68bda02c217e6ae77274d2", "token_estimator": "heuristic-v1" }, { @@ -15709,9 +13568,7 @@ "headings": 8, "estimated_token_count_total": 2764 }, - "hash": "sha256:370ed10155cee84889a6d230d0bc3476597448f88a2a271ab87ef893a3268c18", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:a2bba0ba575bd7e3f7199282ea5994087acf2c62e828f316e6eb62c9a43449e1", "token_estimator": "heuristic-v1" }, { @@ -15737,9 +13594,7 @@ "headings": 1, "estimated_token_count_total": 12 }, - "hash": "sha256:086a87823ab67ceac102358030e316583cd733c0ec326316e7f29061fe7f6934", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:917ce0777f8ac5a4288e54ce4086432d320b127a7fc753ade5392d766a1f3c33", "token_estimator": "heuristic-v1" }, { @@ -15780,8 +13635,7 @@ "headings": 4, "estimated_token_count_total": 339 }, - "hash": "sha256:a2bba0ba575bd7e3f7199282ea5994087acf2c62e828f316e6eb62c9a43449e1", - "last_modified": "2025-10-28T14:42:16+00:00", + "hash": "sha256:9559f240b9433b496bfea92b57394a75c28bc743bb756c231f0137dfdf077e4a", "token_estimator": "heuristic-v1" }, { @@ -15863,7 +13717,6 @@ "estimated_token_count_total": 34492 }, "hash": "sha256:bef820acfe429d4a847a8de82de6c70155ac6b3ad5ebdd574a2157923b45f688", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -15894,9 +13747,7 @@ "headings": 2, "estimated_token_count_total": 125 }, - "hash": "sha256:d2f3ab658ab29514ac161b17df23e0e7c1f63a7fa4fefcef451ef80b413ab757", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:c675e4231537732f24d1dd93f2b248398248a77c9877860fe53926e255ed0710", "token_estimator": "heuristic-v1" }, { @@ -15989,7 +13840,6 @@ "estimated_token_count_total": 5338 }, "hash": "sha256:b3530f5fc5c9e916181dbc259a7fbae9c60100cb0450fc6d47bbb0d140afa075", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16061,7 +13911,6 @@ "estimated_token_count_total": 4358 }, "hash": "sha256:87b19f6e881611329b7015e8d8187d7d85b2b2ef14b01e832c8b8e20897e3b40", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16118,7 +13967,6 @@ "estimated_token_count_total": 2138 }, "hash": "sha256:ff2c267284959711782c0d6ecb4b439c3a6cc31f763d5e1ff2cc3b1f6efb62b2", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16169,12 +14017,7 @@ "headings": 6, "estimated_token_count_total": 2837 }, -<<<<<<< HEAD "hash": "sha256:ad43951deac53a539a3d8a2317500aec351aa7e85f3cc49b386aa30baf6bcc09", -======= - "hash": "sha256:df60044893f48dd7f37a11de275a16bf32adb31317ed70a789fd7fac64150e1a", - "last_modified": "2025-10-28T14:42:16+00:00", ->>>>>>> staging/product-ia "token_estimator": "heuristic-v1" }, { @@ -16266,7 +14109,6 @@ "estimated_token_count_total": 4789 }, "hash": "sha256:81750202081ff24447f4e129c49230eedb315d1b44c740b677c3495a8f7adb9a", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16348,7 +14190,6 @@ "estimated_token_count_total": 2452 }, "hash": "sha256:1eb463c6b2732ebed0d16165425cde438688d21cc302f759b40250850c2a5e83", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16411,7 +14252,6 @@ "estimated_token_count_total": 3255 }, "hash": "sha256:fe94de6f97fb588552f6cbc6b1a4c7399e91f5f31585f61a0dee66f5f50ff8a0", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16437,9 +14277,7 @@ "headings": 1, "estimated_token_count_total": 42 }, - "hash": "sha256:2f11054e0d31c003ebae5d990b559bd56741d190ca409f6ad060216245fa2d17", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:06acc146698c1d3224544987d7ee52da498e3179228f98a494e385c5786a3a2c", "token_estimator": "heuristic-v1" }, { @@ -16475,9 +14313,7 @@ "headings": 3, "estimated_token_count_total": 107 }, - "hash": "sha256:a6a535f4f5e145d3e2a7518739f752ee3ed37b7745483f414e21c97792331d18", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:fdd391227992c966de25b9240f5492135a9993859ec42b77952c1aa3d2e39ed9", "token_estimator": "heuristic-v1" }, { @@ -16518,9 +14354,7 @@ "headings": 4, "estimated_token_count_total": 400 }, - "hash": "sha256:3ad540d8ad636304705cccb08bc1fdf21fe2fc7dc0f99bd509b23ae96d20e0ba", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:2fc6f513fd8b269e586b754b2bdbd2af9df5178624a028fab940a385f3fee577", "token_estimator": "heuristic-v1" }, { @@ -16556,8 +14390,7 @@ "headings": 3, "estimated_token_count_total": 211 }, - "hash": "sha256:388c988338ed84589c546bb1606d08641fb931dae307d3df92aeccd2e4986080", - "last_modified": "2025-10-28T14:15:59+00:00", + "hash": "sha256:5d45ec9f8efda8c4bc2d0c21399a036d017a03540e7efab60d4710cb7eb33eb3", "token_estimator": "heuristic-v1" }, { @@ -16626,7 +14459,6 @@ "estimated_token_count_total": 2702 }, "hash": "sha256:1f8ab387f721d865a7ca75eaa2528f1f2ebd4528a7d65ffeb27c68953100a3cb", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16695,7 +14527,6 @@ "estimated_token_count_total": 2564 }, "hash": "sha256:97dadddf4c27f469f552875461fc54d331fa151e4656401e15d6d4173115eecf", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16726,9 +14557,7 @@ "headings": 2, "estimated_token_count_total": 80 }, - "hash": "sha256:07629376480e74afc7fe4d91df539b6ab22453df0f8143df11cc51ef9a78f736", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:1dfbb8c3cfa27f92e982b4ce705415e117c50eb38f641691129863b474741da7", "token_estimator": "heuristic-v1" }, { @@ -16764,9 +14593,7 @@ "headings": 3, "estimated_token_count_total": 256 }, - "hash": "sha256:cf9197d6909dd8865e8838cad95e3692fefaecc3d2f4773b26809a02051d620f", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:d63121126e51c785f0dfd4ae4ecd49cb71640515d39df69a0689f30a7ab8122f", "token_estimator": "heuristic-v1" }, { @@ -16792,9 +14619,7 @@ "headings": 1, "estimated_token_count_total": 12 }, - "hash": "sha256:aa6371024bb78c3eeedb6820a37859670046fd0e4f756ad417b20c39fb2983b9", - "last_modified": "2025-10-27T18:04:05+00:00", - "last_modified": "2025-10-27T18:04:05+00:00", + "hash": "sha256:94dbafb2d78b87d5f0f0c75de002501b8210ac8d66072bc07989f685837cbac5", "token_estimator": "heuristic-v1" }, { @@ -16847,7 +14672,6 @@ "estimated_token_count_total": 1760 }, "hash": "sha256:9cf70459e921b8b231a3f2e7a7c1d47a4917e45f0c4d0fe873ad4062fd540a9a", - "last_modified": "2025-10-28T14:42:16+00:00", "token_estimator": "heuristic-v1" }, { @@ -16920,7 +14744,6 @@ "estimated_token_count_total": 5118 }, "hash": "sha256:de7fde61d4cac9c28634ee496dcabe116fe44b1b87408f202103290d78247c05", - "last_modified": "2025-10-28T14:42:18+00:00", "token_estimator": "heuristic-v1" }, { @@ -17003,7 +14826,6 @@ "estimated_token_count_total": 6206 }, "hash": "sha256:cb8ddb4a61f6a62182420b69382f1c7ab2adc2f4ae643f7f68c6867680afe81f", - "last_modified": "2025-10-28T14:42:19+00:00", "token_estimator": "heuristic-v1" }, { @@ -17066,7 +14888,114 @@ "estimated_token_count_total": 4135 }, "hash": "sha256:ca1d65d450f086a0eb7b81e9589e9894e04b217fe9709a1b464f09beb3ca9dc2", - "last_modified": "2025-10-28T14:42:20+00:00", + "token_estimator": "heuristic-v1" + }, + { + "id": "tutorials-smart-contracts-launch-your-first-project", + "title": "Launch Your First Project", + "slug": "tutorials-smart-contracts-launch-your-first-project", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/tutorials-smart-contracts-launch-your-first-project.md", + "html_url": "https://docs.polkadot.com/tutorials/smart-contracts/launch-your-first-project/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Kickstart your journey into smart contract development with this comprehensive guide. Learn how to create, deploy, and interact with contracts on Polkadot. Whether you're new to smart contracts or refining your skills, these guides provide a structured approach to launching your project.", + "outline": [ + { + "depth": 2, + "title": "Development Pathway", + "anchor": "development-pathway" + }, + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 1211, + "words": 161, + "headings": 2, + "estimated_token_count_total": 77 + }, + "hash": "sha256:8d8fc5f794d4c793586cd3d412627f5e2fe76f182c75c3687abcf33deed5d65e", + "token_estimator": "heuristic-v1" + }, + { + "id": "tutorials-smart-contracts", + "title": "Smart Contracts", + "slug": "tutorials-smart-contracts", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/tutorials-smart-contracts.md", + "html_url": "https://docs.polkadot.com/tutorials/smart-contracts/", + "preview": "!!! smartcontract \"PolkaVM Preview Release\" PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**. Get started with deploying and interacting with smart contracts on Polkadot through practical, hands-on tutorials. Whether you're a beginner or an experienced developer, these guides will help you navigate the entire development lifecycle.", + "outline": [ + { + "depth": 2, + "title": "What to Expect from These Tutorials", + "anchor": "what-to-expect-from-these-tutorials" + }, + { + "depth": 2, + "title": "Start Building", + "anchor": "start-building" + }, + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 1057, + "words": 145, + "headings": 3, + "estimated_token_count_total": 130 + }, + "hash": "sha256:66bc34a12c50539dde2ffc69fe66891f73d3e1a2da5833ada15e26744ff32209", + "token_estimator": "heuristic-v1" + }, + { + "id": "tutorials", + "title": "Tutorials", + "slug": "tutorials", + "categories": [ + "Uncategorized" + ], + "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/tutorials.md", + "html_url": "https://docs.polkadot.com/tutorials/", + "preview": "Welcome to the Polkadot Tutorials hub! Whether you’re building parachains, integrating system chains, or developing decentralized applications, these step-by-step guides are designed to help you achieve your goals efficiently and effectively.", + "outline": [ + { + "depth": 2, + "title": "Polkadot Zero to Hero", + "anchor": "polkadot-zero-to-hero" + }, + { + "depth": 3, + "title": "Parachain Developers", + "anchor": "parachain-developers" + }, + { + "depth": 2, + "title": "Featured Tutorials", + "anchor": "featured-tutorials" + }, + { + "depth": 2, + "title": "In This Section", + "anchor": "in-this-section" + } + ], + "stats": { + "chars": 2501, + "words": 355, + "headings": 4, + "estimated_token_count_total": 590 + }, + "hash": "sha256:a1d7789d44e4653e98ed41b8a13ea69e7733803c598ca850c9e2fc8f27a2b410", "token_estimator": "heuristic-v1" } ] \ No newline at end of file diff --git a/llms-full.jsonl b/llms-full.jsonl index 0189ac1c7..3eb5c5fac 100644 --- a/llms-full.jsonl +++ b/llms-full.jsonl @@ -26,14 +26,14 @@ {"page_id": "chain-interactions-send-transactions-interoperability-estimate-xcm-fees", "page_title": "XCM Fee Estimation", "index": 7, "depth": 2, "title": "Full Code", "anchor": "full-code", "start_char": 22403, "end_char": 33766, "estimated_token_count": 2142, "token_estimator": "heuristic-v1", "text": "## Full Code\n\nThe full code for the complete implementation is the following:\n\n??? code \"Teleport from Asset Hub to Bridge Hub\"\n\n ```typescript title=\"teleport-ah-to-bridge-hub.ts\"\n import { paseoAssetHub, paseoBridgeHub } from '@polkadot-api/descriptors';\n import { createClient, FixedSizeBinary, Enum } from 'polkadot-api';\n import { getWsProvider } from 'polkadot-api/ws-provider/node';\n import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat';\n import {\n XcmVersionedLocation,\n XcmVersionedAssetId,\n XcmV3Junctions,\n XcmV3MultiassetFungibility,\n XcmVersionedXcm,\n XcmV5Instruction,\n XcmV5Junctions,\n XcmV5Junction,\n XcmV5AssetFilter,\n XcmV5WildAsset,\n } from '@polkadot-api/descriptors';\n\n // 1 PAS = 10^10 units\n const PAS_UNITS = 10_000_000_000n; // 1 PAS\n const PAS_CENTS = 100_000_000n; // 0.01 PAS\n\n // Paseo Asset Hub constants\n const PASEO_ASSET_HUB_RPC_ENDPOINT = 'ws://localhost:8001';\n const ASSET_HUB_ACCOUNT = '15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5'; // Alice (Paseo Asset Hub)\n\n // Bridge Hub destination\n const BRIDGE_HUB_RPC_ENDPOINT = 'ws://localhost:8000';\n const BRIDGE_HUB_PARA_ID = 1002;\n const BRIDGE_HUB_BENEFICIARY =\n '14E5nqKAp3oAJcmzgZhUD2RcptBeUBScxKHgJKU4HPNcKVf3'; // Bob (Bridge Hub)\n\n // Create the XCM message for teleport (Asset Hub → Bridge Hub)\n function createTeleportXcmToBridgeHub(paraId: number) {\n return XcmVersionedXcm.V5([\n // Withdraw PAS from Asset Hub (PAS on parachains is parents:1, interior: Here)\n XcmV5Instruction.WithdrawAsset([\n {\n id: { parents: 1, interior: XcmV5Junctions.Here() },\n fun: XcmV3MultiassetFungibility.Fungible(1n * PAS_UNITS), // 1 PAS\n },\n ]),\n // Pay local fees on Asset Hub in PAS\n XcmV5Instruction.PayFees({\n asset: {\n id: { parents: 1, interior: XcmV5Junctions.Here() },\n fun: XcmV3MultiassetFungibility.Fungible(10n * PAS_CENTS), // 0.01 PAS\n },\n }),\n // Send to Bridge Hub parachain (parents:1, interior: X1(Parachain(paraId)))\n XcmV5Instruction.InitiateTransfer({\n destination: {\n parents: 1,\n interior: XcmV5Junctions.X1(XcmV5Junction.Parachain(paraId)),\n },\n remote_fees: Enum(\n 'Teleport',\n XcmV5AssetFilter.Definite([\n {\n id: { parents: 1, interior: XcmV5Junctions.Here() },\n fun: XcmV3MultiassetFungibility.Fungible(10n * PAS_CENTS), // 0.01 PAS\n },\n ]),\n ),\n preserve_origin: false,\n remote_xcm: [\n XcmV5Instruction.DepositAsset({\n assets: XcmV5AssetFilter.Wild(XcmV5WildAsset.AllCounted(1)),\n beneficiary: {\n parents: 0,\n interior: XcmV5Junctions.X1(\n XcmV5Junction.AccountId32({\n network: undefined,\n id: FixedSizeBinary.fromAccountId32(BRIDGE_HUB_BENEFICIARY),\n }),\n ),\n },\n }),\n ],\n assets: [\n Enum('Teleport', XcmV5AssetFilter.Wild(XcmV5WildAsset.AllCounted(1))), // Send everything.\n ],\n }),\n ]);\n }\n\n async function estimateXcmFeesFromAssetHubToBridgeHub(\n xcm: any,\n assetHubApi: any,\n ) {\n console.log('=== Fee Estimation Process (Asset Hub → Bridge Hub) ===');\n\n // 1. LOCAL EXECUTION FEES on Asset Hub\n console.log('1. Calculating local execution fees on Asset Hub...');\n let localExecutionFees = 0n;\n\n const weightResult =\n await assetHubApi.apis.XcmPaymentApi.query_xcm_weight(xcm);\n if (weightResult.success) {\n console.log('✓ XCM weight (Asset Hub):', weightResult.value);\n\n // Convert weight to PAS fees from Asset Hub's perspective (parents:1, Here)\n const executionFeesResult =\n await assetHubApi.apis.XcmPaymentApi.query_weight_to_asset_fee(\n weightResult.value,\n XcmVersionedAssetId.V4({\n parents: 1,\n interior: XcmV3Junctions.Here(),\n }),\n );\n\n if (executionFeesResult.success) {\n localExecutionFees = executionFeesResult.value;\n console.log(\n '✓ Local execution fees (Asset Hub):',\n localExecutionFees.toString(),\n 'PAS units',\n );\n } else {\n console.log(\n '✗ Failed to calculate local execution fees:',\n executionFeesResult.value,\n );\n }\n } else {\n console.log(\n '✗ Failed to query XCM weight on Asset Hub:',\n weightResult.value,\n );\n }\n\n // 2. DELIVERY FEES + REMOTE EXECUTION FEES\n console.log('\\n2. Calculating delivery and remote execution fees...');\n let deliveryFees = 0n;\n let remoteExecutionFees = 0n; // Skipped (Bridge Hub descriptor not available)\n\n // Origin from Asset Hub perspective\n const origin = XcmVersionedLocation.V5({\n parents: 0,\n interior: XcmV5Junctions.X1(\n XcmV5Junction.AccountId32({\n id: FixedSizeBinary.fromAccountId32(ASSET_HUB_ACCOUNT),\n network: undefined,\n }),\n ),\n });\n\n // Dry run the XCM locally on Asset Hub\n const dryRunResult = await assetHubApi.apis.DryRunApi.dry_run_xcm(\n origin,\n xcm,\n );\n\n if (\n dryRunResult.success &&\n dryRunResult.value.execution_result.type === 'Complete'\n ) {\n console.log('✓ Local dry run on Asset Hub successful');\n\n const { forwarded_xcms: forwardedXcms } = dryRunResult.value;\n\n // Find the XCM message sent to Bridge Hub (parents:1, interior: X1(Parachain(1002)))\n const bridgeHubXcmEntry = forwardedXcms.find(\n ([location, _]: [any, any]) =>\n (location.type === 'V4' || location.type === 'V5') &&\n location.value.parents === 1 &&\n location.value.interior?.type === 'X1' &&\n location.value.interior.value?.type === 'Parachain' &&\n location.value.interior.value.value === BRIDGE_HUB_PARA_ID,\n );\n\n if (bridgeHubXcmEntry) {\n const [destination, messages] = bridgeHubXcmEntry;\n const remoteXcm = messages[0];\n\n console.log('✓ Found XCM message to Bridge Hub');\n\n // Calculate delivery fees from Asset Hub to Bridge Hub\n const deliveryFeesResult =\n await assetHubApi.apis.XcmPaymentApi.query_delivery_fees(\n destination,\n remoteXcm,\n );\n\n if (\n deliveryFeesResult.success &&\n deliveryFeesResult.value.type === 'V5' &&\n deliveryFeesResult.value.value[0]?.fun?.type === 'Fungible'\n ) {\n deliveryFees = deliveryFeesResult.value.value[0].fun.value;\n console.log('✓ Delivery fees:', deliveryFees.toString(), 'PAS units');\n } else {\n console.log('✗ Failed to calculate delivery fees:', deliveryFeesResult);\n }\n\n // 3. REMOTE EXECUTION FEES on Bridge Hub\n console.log('\\n3. Calculating remote execution fees on Bridge Hub');\n try {\n const bridgeHubClient = createClient(\n withPolkadotSdkCompat(getWsProvider(BRIDGE_HUB_RPC_ENDPOINT)),\n );\n const bridgeHubApi = bridgeHubClient.getTypedApi(paseoBridgeHub);\n const remoteWeightResult =\n await bridgeHubApi.apis.XcmPaymentApi.query_xcm_weight(remoteXcm);\n const remoteFeesResult =\n await bridgeHubApi.apis.XcmPaymentApi.query_weight_to_asset_fee(\n remoteWeightResult.value as {\n ref_time: bigint;\n proof_size: bigint;\n },\n XcmVersionedAssetId.V4({\n parents: 1,\n interior: XcmV3Junctions.Here(),\n }),\n );\n bridgeHubClient.destroy();\n remoteExecutionFees = remoteFeesResult.value as bigint;\n console.log(\n '✓ Remote execution fees:',\n remoteExecutionFees.toString(),\n 'PAS units',\n );\n } catch (error) {\n console.error(\n 'Error calculating remote execution fees on Bridge Hub:',\n error,\n );\n }\n } else {\n console.log('✗ No XCM message found to Bridge Hub');\n }\n } else {\n console.log('✗ Local dry run failed on Asset Hub:', dryRunResult.value);\n }\n\n // 4. TOTAL FEES\n const totalFees = localExecutionFees + deliveryFees + remoteExecutionFees;\n\n console.log('\\n=== Fee Summary (Asset Hub → Bridge Hub) ===');\n console.log(\n 'Local execution fees:',\n localExecutionFees.toString(),\n 'PAS units',\n );\n console.log('Delivery fees:', deliveryFees.toString(), 'PAS units');\n console.log(\n 'Remote execution fees:',\n remoteExecutionFees.toString(),\n 'PAS units',\n );\n console.log('TOTAL FEES:', totalFees.toString(), 'PAS units');\n console.log(\n 'TOTAL FEES:',\n (Number(totalFees) / Number(PAS_UNITS)).toFixed(4),\n 'PAS',\n );\n\n return {\n localExecutionFees,\n deliveryFees,\n remoteExecutionFees,\n totalFees,\n };\n }\n\n async function main() {\n // Connect to the Asset Hub parachain\n const assetHubClient = createClient(\n withPolkadotSdkCompat(getWsProvider(PASEO_ASSET_HUB_RPC_ENDPOINT)),\n );\n\n // Get the typed API for Asset Hub\n const assetHubApi = assetHubClient.getTypedApi(paseoAssetHub);\n\n try {\n // Create the XCM message for teleport (Asset Hub → Bridge Hub)\n const xcm = createTeleportXcmToBridgeHub(BRIDGE_HUB_PARA_ID);\n\n console.log('=== XCM Teleport: Paseo Asset Hub → Bridge Hub ===');\n console.log('From:', ASSET_HUB_ACCOUNT, '(Alice on Asset Hub)');\n console.log('To:', BRIDGE_HUB_BENEFICIARY, '(Beneficiary on Bridge Hub)');\n console.log('Amount:', '1 PAS');\n console.log('');\n\n // Estimate all fees\n const fees = await estimateXcmFeesFromAssetHubToBridgeHub(xcm, assetHubApi);\n void fees; // prevent unused var under isolatedModules\n\n // Create the execute transaction on Asset Hub\n const tx = assetHubApi.tx.PolkadotXcm.execute({\n message: xcm,\n max_weight: {\n ref_time: 6000000000n,\n proof_size: 65536n,\n },\n });\n\n console.log('\\n=== Transaction Details ===');\n console.log('Transaction hex:', (await tx.getEncodedData()).asHex());\n console.log('Ready to submit!');\n } catch (error) {\n console.log('Error stack:', (error as Error).stack);\n console.error('Error occurred:', (error as Error).message);\n if ((error as Error).cause) {\n console.dir((error as Error).cause, { depth: null });\n }\n } finally {\n // Ensure client is always destroyed\n assetHubClient.destroy();\n }\n }\n\n main().catch(console.error);\n\n ```"} {"page_id": "chain-interactions-send-transactions-interoperability-estimate-xcm-fees", "page_title": "XCM Fee Estimation", "index": 8, "depth": 2, "title": "Running the Script", "anchor": "running-the-script", "start_char": 33766, "end_char": 38015, "estimated_token_count": 950, "token_estimator": "heuristic-v1", "text": "## Running the Script\n\nBefore running the script, you can use chopsticks to fork the Paseo Asset Hub and Paseo Bridge Hub chains locally. To do so, you can use the following files and commands:\n\n1. Create a new directory called `.chopsticks` and add the files:\n\n ??? code \"paseo-bridge-hub.yml\"\n\n {% raw %}\n ```yaml title=\".chopsticks/paseo-bridge-hub.yml\"\n endpoint: wss://bridge-hub-paseo.dotters.network\n mock-signature-host: true\n block: ${env.PASEO_BRIDGE_HUB_BLOCK_NUMBER}\n db: ./db.sqlite\n\n import-storage:\n Sudo:\n Key: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice\n System:\n Account:\n -\n -\n - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\n - providers: 1\n data:\n free: '10000000000000000000'\n ```\n {% endraw %}\n \n ??? code \"paseo-asset-hub.yml\"\n\n {% raw %}\n ```yaml title=\".chopsticks/paseo-asset-hub.yml\"\n endpoint: wss://asset-hub-paseo-rpc.n.dwellir.com\n mock-signature-host: true\n block: ${env.PASEO_ASSET_HUB_BLOCK_NUMBER}\n db: ./db.sqlite\n\n import-storage:\n Sudo:\n Key: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice\n System:\n Account:\n -\n -\n - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\n - providers: 1\n data:\n free: '10000000000000000000'\n ```\n {% endraw %}\n\n2. Run the following command to fork the Paseo Bridge Hub chain:\n\n ```bash\n chopsticks --config=.chopsticks/paseo-bridge-hub.yml\n ```\n\n After running the command, you will see the following output:\n\n
\n chopsticks --config=.chopsticks/paseo-bridge-hub.yml\n [15:55:22.770] INFO: Paseo Bridge Hub RPC listening on http://[::]:8000 and ws://[::]:8000\n app: \"chopsticks\"\n
\n\n3. Run the following command to fork the Paseo Asset Hub chain:\n\n ```bash\n chopsticks --config=.chopsticks/paseo-asset-hub.yml\n ```\n\n After running the commands, you will see the following output:\n\n
\n chopsticks --config=.chopsticks/paseo-asset-hub.yml\n [15:55:22.770] INFO: Paseo Asset Hub Testnet RPC listening on http://[::]:8001 and ws://[::]:8001\n app: \"chopsticks\"\n
\n\n4. Run the script:\n\n ```bash\n npx ts-node teleport-ah-to-bridge-hub.ts\n ```\n\nAfter running the script, you will see the following output:\n\n
\n npx ts-node teleport-ah-to-bridge-hub.ts\n
\n=== XCM Teleport: Paseo Asset Hub → Bridge Hub ===\nFrom: 15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5 (Alice on Asset Hub)\nTo: 14E5nqKAp3oAJcmzgZhUD2RcptBeUBScxKHgJKU4HPNcKVf3 (Beneficiary on Bridge Hub)\nAmount: 1 PAS\n\n=== Fee Estimation Process (Asset Hub → Bridge Hub) ===\n1. Calculating local execution fees on Asset Hub...\n✓ XCM weight (Asset Hub): { ref_time: 1462082000n, proof_size: 19578n }\n✓ Local execution fees (Asset Hub): 97890000 PAS units\n\n2. Calculating delivery and remote execution fees...\n✓ Local dry run on Asset Hub successful\n✓ Found XCM message to Bridge Hub\n✓ Delivery fees: 305150000 PAS units\n\n3. Calculating remote execution fees on Bridge Hub\n✓ Remote execution fees: 17965000 PAS units\n\n=== Fee Summary (Asset Hub → Bridge Hub) ===\nLocal execution fees: 97890000 PAS units\nDelivery fees: 305150000 PAS units\nRemote execution fees: 17965000 PAS units\nTOTAL FEES: 421005000 PAS units\nTOTAL FEES: 0.0421 PAS\n\n=== Transaction Details ===\nTransaction hex: 0x1f03050c00040100000700e40b54023001000002286bee31010100a90f0100000401000002286bee000400010204040d010204000101008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a480700bca0650102000400\nReady to submit!\n\n\n
"} {"page_id": "chain-interactions-send-transactions-interoperability-estimate-xcm-fees", "page_title": "XCM Fee Estimation", "index": 9, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 38015, "end_char": 38625, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nThis approach provides accurate fee estimation for XCM teleports from Asset Hub to Bridge Hub Chain by properly simulating execution on both chains and utilizing dedicated runtime APIs for fee calculation. The fee breakdown helps you understand the cost structure of reverse cross-chain operations (parachain → bridge hub chain) and ensures your transactions have sufficient funds to complete successfully.\n\nThe key insight is understanding how asset references change based on the perspective of each chain in the XCM ecosystem, which is crucial for proper fee estimation and XCM construction."} -{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Tokens Between Parachains", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 38, "end_char": 1022, "estimated_token_count": 230, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThis guide walks you through transferring tokens between two parachains using the [ParaSpell XCM SDK](https://paraspell.github.io/docs/){target=\\_blank}. This example utilizes [Asset Hub](/polkadot-protocol/architecture/system-chains/asset-hub/){target=\\_blank} and the [People Chain](/polkadot-protocol/architecture/system-chains/people/){target=\\_blank}. However, the same approach can be applied to transfers between other parachains.\n\nFor development purposes, this guide will use the [Polkadot TestNet](/develop/networks/#paseo){target=\\_blank}, so the transferred token will be PAS.\n\nIn this guide, you will:\n\n- Build an XCM transfer transaction using ParaSpell XCM SDK.\n- Perform a dry run to validate the transfer.\n- Verify the [Existential Deposit (ED)](/polkadot-protocol/glossary/#existential-deposit){target=\\_blank} requirement on the destination chain.\n- Retrieve information regarding the transfer, along with fee estimates.\n- Submit the transaction."} -{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Tokens Between Parachains", "index": 1, "depth": 3, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 1022, "end_char": 1448, "estimated_token_count": 108, "token_estimator": "heuristic-v1", "text": "### Prerequisites\n\nBefore you begin, ensure you have the following:\n\n- Knowledge of the [fundamentals of Polkadot](/polkadot-protocol/parachain-basics/){target=\\_blank}.\n- Basic understanding of [XCM](/develop/interoperability/intro-to-xcm/){target=\\_blank}.\n- Basic familiarity with JavaScript or TypeScript.\n- Installed [bun](https://bun.com/docs/installation){target=\\_blank}, a JavaScript and TypeScript package manager."} -{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Tokens Between Parachains", "index": 2, "depth": 2, "title": "Initialize Your Project", "anchor": "initialize-your-project", "start_char": 1448, "end_char": 3143, "estimated_token_count": 387, "token_estimator": "heuristic-v1", "text": "## Initialize Your Project\n\nCreate the project folder:\n\n```bash\nmkdir paraspell-transfer\ncd paraspell-transfer\n```\n\nInitialize the JavaScript project:\n\n```bash\nbun init -y\n```\n\nInstall the required dependencies:\n\n```bash\nbun add @paraspell/sdk@11.3.2 polkadot-api@1.17.1 @polkadot-labs/hdkd-helpers@0.0.25 @polkadot-labs/hdkd@0.0.24\n```\n\nNow add the following setup code to `index.ts`:\n\n```ts title=\"index.ts\"\nimport { Builder, hasDryRunSupport } from '@paraspell/sdk';\nimport {\n entropyToMiniSecret,\n mnemonicToEntropy,\n ss58Address,\n} from '@polkadot-labs/hdkd-helpers';\nimport { getPolkadotSigner } from 'polkadot-api/signer';\nimport { sr25519CreateDerive } from '@polkadot-labs/hdkd';\nimport { inspect } from 'util';\n\n// PAS token has 10 decimals\nconst PAS_UNITS = 10_000_000_000n;\n\nconst SEED_PHRASE =\n 'INSERT_YOUR_SEED_PHRASE';\n\n// Create Sr25519 signer from mnemonic\nfunction getSigner() {\n const entropy = mnemonicToEntropy(SEED_PHRASE);\n const miniSecret = entropyToMiniSecret(entropy);\n const derive = sr25519CreateDerive(miniSecret);\n const keyPair = derive('');\n return getPolkadotSigner(keyPair.publicKey, 'Sr25519', keyPair.sign);\n}\n\nconst RECIPIENT_ADDRESS = ss58Address(getSigner().publicKey);\nconst SENDER_ADDRESS = ss58Address(getSigner().publicKey);\n```\n\nReplace the `INSERT_YOUR_SEED_PHRASE` with the seed phrase from your Polkadot development account.\n\nBe sure to fund this account with some PAS tokens on the Paseo Asset Hub using the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1000){target=_blank}.\n\n!!!warning \"Security Warning\"\n Never commit your mnemonic phrase to production code. Use environment variables or secure key management systems."} -{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Tokens Between Parachains", "index": 3, "depth": 2, "title": "Build a Token Transfer Transaction", "anchor": "build-a-token-transfer-transaction", "start_char": 3143, "end_char": 4056, "estimated_token_count": 229, "token_estimator": "heuristic-v1", "text": "## Build a Token Transfer Transaction\n\nThe next step is to build the transaction that you intend to execute.\n\nIn this example, you will transfer 10 PAS tokens from Paseo's Asset Hub to Paseo's People Chain system parachain.\n\nAdd the ParaSpell transaction code to your `index.ts` file:\n\n```ts title=\"index.ts\"\nasync function transfer() {\n const signer = getSigner();\n\n const tx = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS, // 10 PAS\n })\n .address(RECIPIENT_ADDRESS)\n .build();\n\n console.log('Built transaction:', inspect(tx, { colors: true, depth: null }));\n\n const result = await tx.signAndSubmit(signer);\n console.log(inspect(result, { colors: true, depth: null }));\n process.exit(0);\n}\n```\n\nDo not execute it just yet. You will perform a dry run of this transaction first to ensure it works as expected."} -{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Tokens Between Parachains", "index": 4, "depth": 2, "title": "Perform a Dry Run", "anchor": "perform-a-dry-run", "start_char": 4056, "end_char": 8550, "estimated_token_count": 832, "token_estimator": "heuristic-v1", "text": "## Perform a Dry Run\n\nDry runs simulate the transaction without broadcasting it, allowing you to confirm success in advance.\n\nAdd the following dry run code to your `index.ts` script:\n\n```ts title=\"index.ts\"\nasync function dryRunTransfer() {\n if (!hasDryRunSupport('AssetHubPaseo')) {\n console.log('Dry run is not supported on AssetHubPaseo.');\n return;\n }\n\n const tx = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .dryRun();\n\n console.log(inspect(tx, { colors: true, depth: null }));\n process.exit(0);\n}\n\ndryRunTransfer();\n```\nRun the script using the following command:\n\n```bash\nbun run index.ts\n```\n\nThe result of the dry run will look similar to the following example output:\n\n
\n bun run index.ts\n {\n failureReason: undefined,\n failureChain: undefined,\n origin: {\n success: true,\n fee: 17965000n,\n currency: 'PAS',\n asset: {\n symbol: 'PAS',\n isNative: true,\n decimals: 10,\n existentialDeposit: '100000000',\n location: { parents: 1, interior: { Here: null } },\n isFeeAsset: true,\n amount: 100000000000n\n },\n weight: undefined,\n forwardedXcms: [\n {\n type: 'V3',\n value: {\n parents: 1,\n interior: { type: 'X1', value: { type: 'Parachain', value: 1004 } }\n }\n },\n [\n {\n type: 'V3',\n value: [\n {\n type: 'ReceiveTeleportedAsset',\n value: [\n {\n id: {\n type: 'Concrete',\n value: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n }\n },\n fun: { type: 'Fungible', value: 100000000000n }\n }\n ]\n },\n { type: 'ClearOrigin', value: undefined },\n {\n type: 'BuyExecution',\n value: {\n fees: {\n id: {\n type: 'Concrete',\n value: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n }\n },\n fun: { type: 'Fungible', value: 100000000000n }\n },\n weight_limit: { type: 'Unlimited', value: undefined }\n }\n },\n {\n type: 'DepositAsset',\n value: {\n assets: {\n type: 'Wild',\n value: { type: 'AllCounted', value: 1 }\n },\n beneficiary: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: undefined,\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n }\n }\n },\n {\n type: 'SetTopic',\n value: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n ]\n }\n ]\n ],\n destParaId: 1004\n },\n assetHub: undefined,\n bridgeHub: undefined,\n destination: {\n success: true,\n fee: 817598n,\n currency: 'PAS',\n asset: {\n symbol: 'PAS',\n isNative: true,\n decimals: 10,\n existentialDeposit: '1000000000',\n location: { parents: 1, interior: { Here: null } },\n isFeeAsset: true\n },\n weight: { refTime: 176858000n, proofSize: 0n },\n forwardedXcms: [],\n destParaId: undefined\n },\n hops: []\n}\n
"} -{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Tokens Between Parachains", "index": 5, "depth": 2, "title": "Verify the Existential Deposit", "anchor": "verify-the-existential-deposit", "start_char": 8550, "end_char": 9732, "estimated_token_count": 316, "token_estimator": "heuristic-v1", "text": "## Verify the Existential Deposit\n\nCheck if the recipient account meets the [Existential Deposit (ED)](/polkadot-protocol/glossary/#existential-deposit){target=\\_blank} requirement before sending by using [`verifyEdOnDestination`](https://paraspell.github.io/docs/sdk/xcmUtils.html#verify-ed-on-destination){target=\\_blank}:\n\n```ts title=\"index.ts\"\nasync function verifyED() {\n const isValid = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .verifyEdOnDestination();\n\n console.log(`ED verification ${isValid ? 'successful' : 'failed'}.`);\n process.exit(0);\n}\n\nverifyED();\n```\nComment out the `dryRunTransfer()` function so that it is not executed again. Then, execute the `verifyED()` by running the following command:\n\n```bash\nbun run index.ts\n```\n\nAfter that, you will get output confirming the ED which will look similar to the following:\n\n
\n bun run index.ts\n ED verification successful.\n
"} -{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Tokens Between Parachains", "index": 6, "depth": 2, "title": "Get Transfer Info and Fee Estimates", "anchor": "get-transfer-info-and-fee-estimates", "start_char": 9732, "end_char": 26283, "estimated_token_count": 3019, "token_estimator": "heuristic-v1", "text": "## Get Transfer Info and Fee Estimates\n\nBefore sending an XCM transaction, it is helpful to estimate the fees associated with executing and delivering the cross-chain message.\n\nParaSpell has a helpful function for this: [`getTransferInfo()`](https://paraspell.github.io/docs/sdk/xcmUtils.html#xcm-transfer-info){target=\\_blank}. This function returns an estimate of the associated XCM fees, along with the account's balance before and after the fees are paid.\n\n```ts title=\"index.ts\"\nasync function XcmTransferInfo() {\n const info = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .getTransferInfo();\n\n console.log('Transfer Info:', info);\n process.exit(0);\n}\n\nXcmTransferInfo();\n```\n\nComment out the `verifyED()` function so it doesn't execute again. Then, execute the `XcmTransferInfo()` function by running the following command:\n\n```bash\nbun run index.ts\n```\n\nYou will see all the information for your transfer similar to the following example:\n\n
\n bun run index.ts\n Transfer Info: {\n chain: {\n origin: \"AssetHubPaseo\",\n destination: \"PeoplePaseo\",\n ecosystem: \"PAS\",\n },\n origin: {\n selectedCurrency: {\n sufficient: true,\n balance: 9799197260420n,\n balanceAfter: 9699197260420n,\n currencySymbol: \"PAS\",\n asset: [Object ...],\n existentialDeposit: 100000000n,\n },\n xcmFee: {\n sufficient: true,\n fee: 17965000n,\n balance: 9799197260420n,\n balanceAfter: 9799179295420n,\n currencySymbol: \"PAS\",\n asset: [Object ...],\n },\n },\n assetHub: undefined,\n bridgeHub: undefined,\n hops: [],\n destination: {\n receivedCurrency: {\n sufficient: true,\n receivedAmount: 99999182402n,\n balance: 199998364804n,\n balanceAfter: 299997547206n,\n currencySymbol: \"PAS\",\n asset: [Object ...],\n existentialDeposit: 1000000000n,\n },\n xcmFee: {\n fee: 817598n,\n balance: 199998364804n,\n balanceAfter: 299997547206n,\n currencySymbol: \"PAS\",\n asset: [Object ...],\n },\n },\n}\n
\nNow that you have:\n\n- Completed a successful dry run of the transaction.\n- Verified the existential deposit on the recipient account.\n- Obtained an estimate of the associated XCM fees.\n\nYou can execute the transfer function by adding the following function call:\n\n```typescript title=\"index.ts\"\ntransfer();\n```\n\nComment out the `XcmTransferInfo()` function so it doesn't execute again. Then, execute the transfer by running the following command: \n\n```bash\nbun run index.ts\n```\n\nYour `transfer` function will submit the transaction, and you will get the following output:\n\n
\n bun run index.ts\n ...\n Built transaction: {\n getPaymentInfo: [AsyncFunction: getPaymentInfo],\n getEstimatedFees: [AsyncFunction: getEstimatedFees],\n decodedCall: {\n type: 'PolkadotXcm',\n value: {\n type: 'limited_teleport_assets',\n value: {\n dest: {\n type: 'V5',\n value: {\n parents: 1,\n interior: { type: 'X1', value: { type: 'Parachain', value: 1004 } }\n }\n },\n beneficiary: {\n type: 'V5',\n value: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: undefined,\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n }\n },\n assets: {\n type: 'V5',\n value: [\n {\n id: { parents: 1, interior: { type: 'Here', value: null } },\n fun: { type: 'Fungible', value: 100000000000n }\n }\n ]\n },\n fee_asset_item: 0,\n weight_limit: { type: 'Unlimited' }\n }\n }\n },\n getEncodedData: [Function: getEncodedData],\n sign: [Function: sign],\n signSubmitAndWatch: [Function: signSubmitAndWatch],\n signAndSubmit: [Function: signAndSubmit]\n}\n
\nOnce the transaction is successfully included in a block, you will see the recipient's account balance updated, and you will receive output similar to the following.\n\n???- code \"Successful Transaction Submission\"\n This output will be returned once the transaction has been successfully included in a block.\n\n
\n ...\n {\n txHash: '0x6fbecc0b284adcff46ab39872659c2567395c865adef5f8cbea72f25b6042609',\n block: {\n index: 2,\n number: 2524809,\n hash: '0xa39a96d5921402c6e8f67e48b8395d6b21382c72d4d30f8497a0e9f890bc0d4c'\n },\n ok: true,\n events: [\n {\n type: 'Balances',\n value: {\n type: 'Withdraw',\n value: {\n who: '15DMtB5BDCJqw4uZtByTWXGqViAVx7XjRsxWbTH5tfrHLe8j',\n amount: 15668864n\n }\n },\n topics: []\n },\n {\n type: 'Balances',\n value: {\n type: 'Burned',\n value: {\n who: '15DMtB5BDCJqw4uZtByTWXGqViAVx7XjRsxWbTH5tfrHLe8j',\n amount: 100000000000n\n }\n },\n topics: []\n },\n {\n type: 'PolkadotXcm',\n value: {\n type: 'Attempted',\n value: {\n outcome: {\n type: 'Complete',\n value: { used: { ref_time: 190990000n, proof_size: 3593n } }\n }\n }\n },\n topics: []\n },\n {\n type: 'Balances',\n value: {\n type: 'Burned',\n value: {\n who: '15DMtB5BDCJqw4uZtByTWXGqViAVx7XjRsxWbTH5tfrHLe8j',\n amount: 304850000n\n }\n },\n topics: []\n },\n {\n type: 'Balances',\n value: {\n type: 'Minted',\n value: {\n who: '14xmwinmCEz6oRrFdczHKqHgWNMiCysE2KrA4jXXAAM1Eogk',\n amount: 304850000n\n }\n },\n topics: []\n },\n {\n type: 'PolkadotXcm',\n value: {\n type: 'FeesPaid',\n value: {\n paying: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: { type: 'Polkadot', value: undefined },\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n },\n fees: [\n {\n id: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n },\n fun: { type: 'Fungible', value: 304850000n }\n }\n ]\n }\n },\n topics: []\n },\n {\n type: 'XcmpQueue',\n value: {\n type: 'XcmpMessageSent',\n value: {\n message_hash: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n },\n topics: []\n },\n {\n type: 'PolkadotXcm',\n value: {\n type: 'Sent',\n value: {\n origin: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: { type: 'Polkadot', value: undefined },\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n },\n destination: {\n parents: 1,\n interior: { type: 'X1', value: { type: 'Parachain', value: 1002 } }\n },\n message: [\n {\n type: 'ReceiveTeleportedAsset',\n value: [\n {\n id: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n },\n fun: { type: 'Fungible', value: 100000000000n }\n }\n ]\n },\n { type: 'ClearOrigin', value: undefined },\n {\n type: 'BuyExecution',\n value: {\n fees: {\n id: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n },\n fun: { type: 'Fungible', value: 100000000000n }\n },\n weight_limit: { type: 'Unlimited', value: undefined }\n }\n },\n {\n type: 'DepositAsset',\n value: {\n assets: {\n type: 'Wild',\n value: { type: 'AllCounted', value: 1 }\n },\n beneficiary: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: undefined,\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n }\n }\n }\n ],\n message_id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n },\n topics: []\n },\n {\n type: 'Balances',\n value: {\n type: 'Deposit',\n value: {\n who: '13UVJyLgBASGhE2ok3TvxUfaQBGUt88JCcdYjHvUhvQkFTTx',\n amount: 15668864n\n }\n },\n topics: []\n },\n {\n type: 'TransactionPayment',\n value: {\n type: 'TransactionFeePaid',\n value: {\n who: '15DMtB5BDCJqw4uZtByTWXGqViAVx7XjRsxWbTH5tfrHLe8j',\n actual_fee: 15668864n,\n tip: 0n\n }\n },\n topics: []\n },\n {\n type: 'System',\n value: {\n type: 'ExtrinsicSuccess',\n value: {\n dispatch_info: {\n weight: { ref_time: 952851000n, proof_size: 13382n },\n class: { type: 'Normal', value: undefined },\n pays_fee: { type: 'Yes', value: undefined }\n }\n }\n },\n topics: []\n }\n ]\n }\n
\nAfter executing the transfer, check the account balance on [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fsys.turboflakes.io%2Fasset-hub-paseo){target=\\_blank} for [Paseo's Asset Hub](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fsys.turboflakes.io%2Fasset-hub-paseo#/accounts){target=\\_blank} and [Paseo's People Chain](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fsys.ibp.network%2Fpeople-paseo#/accounts){target=\\_blank}.\n\nYou should see:\n\n- The recipient account now has 10 more PAS tokens.\n- The sender account has the transfer amount (10 PAS) + the fees amount debited from their account balance.\n\nYou have now successfully created and sent a cross-chain transfer using the ParaSpell XCM SDK!\n\n???- code \"Full Code\"\n\n ```typescript title=\"index.ts\"\n import { Builder, hasDryRunSupport } from '@paraspell/sdk';\n import {\n entropyToMiniSecret,\n mnemonicToEntropy,\n ss58Address,\n } from '@polkadot-labs/hdkd-helpers';\n import { getPolkadotSigner } from 'polkadot-api/signer';\n import { sr25519CreateDerive } from '@polkadot-labs/hdkd';\n import { inspect } from 'util';\n\n // PAS token has 10 decimals\n const PAS_UNITS = 10_000_000_000n;\n\n const SEED_PHRASE =\n 'INSERT_YOUR_SEED_PHRASE';\n\n // Create Sr25519 signer from mnemonic\n function getSigner() {\n const entropy = mnemonicToEntropy(SEED_PHRASE);\n const miniSecret = entropyToMiniSecret(entropy);\n const derive = sr25519CreateDerive(miniSecret);\n const keyPair = derive('');\n return getPolkadotSigner(keyPair.publicKey, 'Sr25519', keyPair.sign);\n }\n\n const RECIPIENT_ADDRESS = ss58Address(getSigner().publicKey);\n const SENDER_ADDRESS = ss58Address(getSigner().publicKey);\n\n async function transfer() {\n const signer = getSigner();\n\n const tx = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS, // 10 PAS\n })\n .address(RECIPIENT_ADDRESS)\n .build();\n\n console.log('Built transaction:', inspect(tx, { colors: true, depth: null }));\n\n const result = await tx.signAndSubmit(signer);\n console.log(inspect(result, { colors: true, depth: null }));\n process.exit(0);\n }\n\n async function dryRunTransfer() {\n if (!hasDryRunSupport('AssetHubPaseo')) {\n console.log('Dry run is not supported on AssetHubPaseo.');\n return;\n }\n\n const tx = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .dryRun();\n\n console.log(inspect(tx, { colors: true, depth: null }));\n process.exit(0);\n }\n\n dryRunTransfer();\n\n async function verifyED() {\n const isValid = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .verifyEdOnDestination();\n\n console.log(`ED verification ${isValid ? 'successful' : 'failed'}.`);\n process.exit(0);\n }\n\n verifyED();\n\n async function XcmTransferInfo() {\n const info = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .getTransferInfo();\n\n console.log('Transfer Info:', info);\n process.exit(0);\n }\n\n XcmTransferInfo();\n\n transfer();\n\n ```"} -{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Tokens Between Parachains", "index": 7, "depth": 2, "title": "Next Steps", "anchor": "next-steps", "start_char": 26283, "end_char": 26623, "estimated_token_count": 86, "token_estimator": "heuristic-v1", "text": "## Next Steps\n\n- Read the Docs: Dive deeper into the features of the [ParaSpell XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.html){target=\\_blank} documentation.\n\n- Learn about XCM: Understand the underlying protocol by visiting the [Introduction to XCM page](/develop/interoperability/intro-to-xcm/) in the Polkadot Docs."} +{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Assets Between Parachains", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 38, "end_char": 1008, "estimated_token_count": 223, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThis guide walks you through transferring tokens between two parachains using the [ParaSpell XCM SDK](/reference/tools/paraspell/){target=\\_blank}. This example utilizes [Asset Hub](/polkadot-protocol/architecture/system-chains/asset-hub/){target=\\_blank} and the [People Chain](/polkadot-protocol/architecture/system-chains/people/){target=\\_blank}. However, the same approach can be applied to transfers between other parachains.\n\nFor development purposes, this guide will use the [Polkadot TestNet](/develop/networks/#paseo){target=\\_blank}, so the transferred token will be PAS.\n\nIn this guide, you will:\n\n- Build an XCM transfer transaction using ParaSpell XCM SDK.\n- Perform a dry run to validate the transfer.\n- Verify the [Existential Deposit (ED)](/reference/glossary/#existential-deposit){target=\\_blank} requirement on the destination chain.\n- Retrieve information regarding the transfer, along with fee estimates.\n- Submit the transaction."} +{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Assets Between Parachains", "index": 1, "depth": 3, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 1008, "end_char": 1456, "estimated_token_count": 116, "token_estimator": "heuristic-v1", "text": "### Prerequisites\n\nBefore you begin, ensure you have the following:\n\n- Knowledge of the [fundamentals of Polkadot](/parachains/get-started/){target=\\_blank}.\n- Basic understanding of [XCM](/parachains/interoperability/get-started/){target=\\_blank}.\n- Basic familiarity with JavaScript or TypeScript.\n- Installed [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm){target=\\_blank}, a JavaScript and TypeScript package manager."} +{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Assets Between Parachains", "index": 2, "depth": 2, "title": "Initialize Your Project", "anchor": "initialize-your-project", "start_char": 1456, "end_char": 3282, "estimated_token_count": 438, "token_estimator": "heuristic-v1", "text": "## Initialize Your Project\n\nCreate the project folder:\n\n```bash\nmkdir paraspell-transfer && \\\ncd paraspell-transfer\n```\n\nInitialize the JavaScript project:\n\n```bash\nnpm init -y\n```\n\nInstall dev dependencies:\n\n```bash\nnpm install --save-dev @types/node@^22.12.0 tsx@^4.20.6 typescript@^5.7.3\n```\n\nInstall the required dependencies:\n\n```bash\nnpm install --save @paraspell/sdk@11.12.6 polkadot-api@1.20.0 @polkadot-labs/hdkd-helpers@0.0.26 @polkadot-labs/hdkd@0.0.25\n```\n\nNow add the following setup code to `index.ts`:\n\n```ts title=\"index.ts\"\nimport { Builder, hasDryRunSupport } from '@paraspell/sdk';\nimport {\n entropyToMiniSecret,\n mnemonicToEntropy,\n ss58Address,\n} from '@polkadot-labs/hdkd-helpers';\nimport { getPolkadotSigner } from 'polkadot-api/signer';\nimport { sr25519CreateDerive } from '@polkadot-labs/hdkd';\nimport { inspect } from 'util';\n\n// PAS token has 10 decimals\nconst PAS_UNITS = 10_000_000_000n;\n\nconst SEED_PHRASE =\n 'INSERT_YOUR_SEED_PHRASE';\n\n// Create Sr25519 signer from mnemonic\nfunction getSigner() {\n const entropy = mnemonicToEntropy(SEED_PHRASE);\n const miniSecret = entropyToMiniSecret(entropy);\n const derive = sr25519CreateDerive(miniSecret);\n const keyPair = derive('');\n return getPolkadotSigner(keyPair.publicKey, 'Sr25519', keyPair.sign);\n}\n\nconst RECIPIENT_ADDRESS = ss58Address(getSigner().publicKey);\nconst SENDER_ADDRESS = ss58Address(getSigner().publicKey);\n```\n\nReplace the `INSERT_YOUR_SEED_PHRASE` with the seed phrase from your Polkadot development account.\n\nBe sure to fund this account with some PAS tokens on the Paseo Asset Hub using the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1000){target=_blank}.\n\n!!!warning \"Security Warning\"\n Never commit your mnemonic phrase to production code. Use environment variables or secure key management systems."} +{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Assets Between Parachains", "index": 3, "depth": 2, "title": "Build a Token Transfer Transaction", "anchor": "build-a-token-transfer-transaction", "start_char": 3282, "end_char": 4195, "estimated_token_count": 229, "token_estimator": "heuristic-v1", "text": "## Build a Token Transfer Transaction\n\nThe next step is to build the transaction that you intend to execute.\n\nIn this example, you will transfer 10 PAS tokens from Paseo's Asset Hub to Paseo's People Chain system parachain.\n\nAdd the ParaSpell transaction code to your `index.ts` file:\n\n```ts title=\"index.ts\"\nasync function transfer() {\n const signer = getSigner();\n\n const tx = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS, // 10 PAS\n })\n .address(RECIPIENT_ADDRESS)\n .build();\n\n console.log('Built transaction:', inspect(tx, { colors: true, depth: null }));\n\n const result = await tx.signAndSubmit(signer);\n console.log(inspect(result, { colors: true, depth: null }));\n process.exit(0);\n}\n```\n\nDo not execute it just yet. You will perform a dry run of this transaction first to ensure it works as expected."} +{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Assets Between Parachains", "index": 4, "depth": 2, "title": "Perform a Dry Run", "anchor": "perform-a-dry-run", "start_char": 4195, "end_char": 8689, "estimated_token_count": 832, "token_estimator": "heuristic-v1", "text": "## Perform a Dry Run\n\nDry runs simulate the transaction without broadcasting it, allowing you to confirm success in advance.\n\nAdd the following dry run code to your `index.ts` script:\n\n```ts title=\"index.ts\"\nasync function dryRunTransfer() {\n if (!hasDryRunSupport('AssetHubPaseo')) {\n console.log('Dry run is not supported on AssetHubPaseo.');\n return;\n }\n\n const tx = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .dryRun();\n\n console.log(inspect(tx, { colors: true, depth: null }));\n process.exit(0);\n}\n\ndryRunTransfer();\n```\nRun the script using the following command:\n\n```bash\nnpx tsx index.ts\n```\n\nThe result of the dry run will look similar to the following example output:\n\n
\n npx tsx index.ts\n {\n failureReason: undefined,\n failureChain: undefined,\n origin: {\n success: true,\n fee: 17965000n,\n currency: 'PAS',\n asset: {\n symbol: 'PAS',\n isNative: true,\n decimals: 10,\n existentialDeposit: '100000000',\n location: { parents: 1, interior: { Here: null } },\n isFeeAsset: true,\n amount: 100000000000n\n },\n weight: undefined,\n forwardedXcms: [\n {\n type: 'V3',\n value: {\n parents: 1,\n interior: { type: 'X1', value: { type: 'Parachain', value: 1004 } }\n }\n },\n [\n {\n type: 'V3',\n value: [\n {\n type: 'ReceiveTeleportedAsset',\n value: [\n {\n id: {\n type: 'Concrete',\n value: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n }\n },\n fun: { type: 'Fungible', value: 100000000000n }\n }\n ]\n },\n { type: 'ClearOrigin', value: undefined },\n {\n type: 'BuyExecution',\n value: {\n fees: {\n id: {\n type: 'Concrete',\n value: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n }\n },\n fun: { type: 'Fungible', value: 100000000000n }\n },\n weight_limit: { type: 'Unlimited', value: undefined }\n }\n },\n {\n type: 'DepositAsset',\n value: {\n assets: {\n type: 'Wild',\n value: { type: 'AllCounted', value: 1 }\n },\n beneficiary: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: undefined,\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n }\n }\n },\n {\n type: 'SetTopic',\n value: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n ]\n }\n ]\n ],\n destParaId: 1004\n },\n assetHub: undefined,\n bridgeHub: undefined,\n destination: {\n success: true,\n fee: 817598n,\n currency: 'PAS',\n asset: {\n symbol: 'PAS',\n isNative: true,\n decimals: 10,\n existentialDeposit: '1000000000',\n location: { parents: 1, interior: { Here: null } },\n isFeeAsset: true\n },\n weight: { refTime: 176858000n, proofSize: 0n },\n forwardedXcms: [],\n destParaId: undefined\n },\n hops: []\n}\n
"} +{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Assets Between Parachains", "index": 5, "depth": 2, "title": "Verify the Existential Deposit", "anchor": "verify-the-existential-deposit", "start_char": 8689, "end_char": 9871, "estimated_token_count": 316, "token_estimator": "heuristic-v1", "text": "## Verify the Existential Deposit\n\nCheck if the recipient account meets the [Existential Deposit (ED)](/polkadot-protocol/glossary/#existential-deposit){target=\\_blank} requirement before sending by using [`verifyEdOnDestination`](https://paraspell.github.io/docs/sdk/xcmUtils.html#verify-ed-on-destination){target=\\_blank}:\n\n```ts title=\"index.ts\"\nasync function verifyED() {\n const isValid = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .verifyEdOnDestination();\n\n console.log(`ED verification ${isValid ? 'successful' : 'failed'}.`);\n process.exit(0);\n}\n\nverifyED();\n```\nComment out the `dryRunTransfer()` function so that it is not executed again. Then, execute the `verifyED()` by running the following command:\n\n```bash\nnpx tsx index.ts\n```\n\nAfter that, you will get output confirming the ED which will look similar to the following:\n\n
\n npx tsx index.ts\n ED verification successful.\n
"} +{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Assets Between Parachains", "index": 6, "depth": 2, "title": "Get Transfer Info and Fee Estimates", "anchor": "get-transfer-info-and-fee-estimates", "start_char": 9871, "end_char": 26422, "estimated_token_count": 3019, "token_estimator": "heuristic-v1", "text": "## Get Transfer Info and Fee Estimates\n\nBefore sending an XCM transaction, it is helpful to estimate the fees associated with executing and delivering the cross-chain message.\n\nParaSpell has a helpful function for this: [`getTransferInfo()`](https://paraspell.github.io/docs/sdk/xcmUtils.html#xcm-transfer-info){target=\\_blank}. This function returns an estimate of the associated XCM fees, along with the account's balance before and after the fees are paid.\n\n```ts title=\"index.ts\"\nasync function XcmTransferInfo() {\n const info = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .getTransferInfo();\n\n console.log('Transfer Info:', info);\n process.exit(0);\n}\n\nXcmTransferInfo();\n```\n\nComment out the `verifyED()` function so it doesn't execute again. Then, execute the `XcmTransferInfo()` function by running the following command:\n\n```bash\nnpx tsx index.ts\n```\n\nYou will see all the information for your transfer similar to the following example:\n\n
\n npx tsx index.ts\n Transfer Info: {\n chain: {\n origin: \"AssetHubPaseo\",\n destination: \"PeoplePaseo\",\n ecosystem: \"PAS\",\n },\n origin: {\n selectedCurrency: {\n sufficient: true,\n balance: 9799197260420n,\n balanceAfter: 9699197260420n,\n currencySymbol: \"PAS\",\n asset: [Object ...],\n existentialDeposit: 100000000n,\n },\n xcmFee: {\n sufficient: true,\n fee: 17965000n,\n balance: 9799197260420n,\n balanceAfter: 9799179295420n,\n currencySymbol: \"PAS\",\n asset: [Object ...],\n },\n },\n assetHub: undefined,\n bridgeHub: undefined,\n hops: [],\n destination: {\n receivedCurrency: {\n sufficient: true,\n receivedAmount: 99999182402n,\n balance: 199998364804n,\n balanceAfter: 299997547206n,\n currencySymbol: \"PAS\",\n asset: [Object ...],\n existentialDeposit: 1000000000n,\n },\n xcmFee: {\n fee: 817598n,\n balance: 199998364804n,\n balanceAfter: 299997547206n,\n currencySymbol: \"PAS\",\n asset: [Object ...],\n },\n },\n}\n
\nNow that you have:\n\n- Completed a successful dry run of the transaction.\n- Verified the existential deposit on the recipient account.\n- Obtained an estimate of the associated XCM fees.\n\nYou can execute the transfer function by adding the following function call:\n\n```typescript title=\"index.ts\"\ntransfer();\n```\n\nComment out the `XcmTransferInfo()` function so it doesn't execute again. Then, execute the transfer by running the following command: \n\n```bash\nnpx tsx index.ts\n```\n\nYour `transfer` function will submit the transaction, and you will get the following output:\n\n
\n npx tsx index.ts\n ...\n Built transaction: {\n getPaymentInfo: [AsyncFunction: getPaymentInfo],\n getEstimatedFees: [AsyncFunction: getEstimatedFees],\n decodedCall: {\n type: 'PolkadotXcm',\n value: {\n type: 'limited_teleport_assets',\n value: {\n dest: {\n type: 'V5',\n value: {\n parents: 1,\n interior: { type: 'X1', value: { type: 'Parachain', value: 1004 } }\n }\n },\n beneficiary: {\n type: 'V5',\n value: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: undefined,\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n }\n },\n assets: {\n type: 'V5',\n value: [\n {\n id: { parents: 1, interior: { type: 'Here', value: null } },\n fun: { type: 'Fungible', value: 100000000000n }\n }\n ]\n },\n fee_asset_item: 0,\n weight_limit: { type: 'Unlimited' }\n }\n }\n },\n getEncodedData: [Function: getEncodedData],\n sign: [Function: sign],\n signSubmitAndWatch: [Function: signSubmitAndWatch],\n signAndSubmit: [Function: signAndSubmit]\n}\n
\nOnce the transaction is successfully included in a block, you will see the recipient's account balance updated, and you will receive output similar to the following.\n\n???- code \"Successful Transaction Submission\"\n This output will be returned once the transaction has been successfully included in a block.\n\n
\n ...\n {\n txHash: '0x6fbecc0b284adcff46ab39872659c2567395c865adef5f8cbea72f25b6042609',\n block: {\n index: 2,\n number: 2524809,\n hash: '0xa39a96d5921402c6e8f67e48b8395d6b21382c72d4d30f8497a0e9f890bc0d4c'\n },\n ok: true,\n events: [\n {\n type: 'Balances',\n value: {\n type: 'Withdraw',\n value: {\n who: '15DMtB5BDCJqw4uZtByTWXGqViAVx7XjRsxWbTH5tfrHLe8j',\n amount: 15668864n\n }\n },\n topics: []\n },\n {\n type: 'Balances',\n value: {\n type: 'Burned',\n value: {\n who: '15DMtB5BDCJqw4uZtByTWXGqViAVx7XjRsxWbTH5tfrHLe8j',\n amount: 100000000000n\n }\n },\n topics: []\n },\n {\n type: 'PolkadotXcm',\n value: {\n type: 'Attempted',\n value: {\n outcome: {\n type: 'Complete',\n value: { used: { ref_time: 190990000n, proof_size: 3593n } }\n }\n }\n },\n topics: []\n },\n {\n type: 'Balances',\n value: {\n type: 'Burned',\n value: {\n who: '15DMtB5BDCJqw4uZtByTWXGqViAVx7XjRsxWbTH5tfrHLe8j',\n amount: 304850000n\n }\n },\n topics: []\n },\n {\n type: 'Balances',\n value: {\n type: 'Minted',\n value: {\n who: '14xmwinmCEz6oRrFdczHKqHgWNMiCysE2KrA4jXXAAM1Eogk',\n amount: 304850000n\n }\n },\n topics: []\n },\n {\n type: 'PolkadotXcm',\n value: {\n type: 'FeesPaid',\n value: {\n paying: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: { type: 'Polkadot', value: undefined },\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n },\n fees: [\n {\n id: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n },\n fun: { type: 'Fungible', value: 304850000n }\n }\n ]\n }\n },\n topics: []\n },\n {\n type: 'XcmpQueue',\n value: {\n type: 'XcmpMessageSent',\n value: {\n message_hash: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n },\n topics: []\n },\n {\n type: 'PolkadotXcm',\n value: {\n type: 'Sent',\n value: {\n origin: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: { type: 'Polkadot', value: undefined },\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n },\n destination: {\n parents: 1,\n interior: { type: 'X1', value: { type: 'Parachain', value: 1002 } }\n },\n message: [\n {\n type: 'ReceiveTeleportedAsset',\n value: [\n {\n id: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n },\n fun: { type: 'Fungible', value: 100000000000n }\n }\n ]\n },\n { type: 'ClearOrigin', value: undefined },\n {\n type: 'BuyExecution',\n value: {\n fees: {\n id: {\n parents: 1,\n interior: { type: 'Here', value: undefined }\n },\n fun: { type: 'Fungible', value: 100000000000n }\n },\n weight_limit: { type: 'Unlimited', value: undefined }\n }\n },\n {\n type: 'DepositAsset',\n value: {\n assets: {\n type: 'Wild',\n value: { type: 'AllCounted', value: 1 }\n },\n beneficiary: {\n parents: 0,\n interior: {\n type: 'X1',\n value: {\n type: 'AccountId32',\n value: {\n network: undefined,\n id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n }\n }\n }\n }\n }\n ],\n message_id: FixedSizeBinary {\n asText: [Function (anonymous)],\n asHex: [Function (anonymous)],\n asOpaqueHex: [Function (anonymous)],\n asBytes: [Function (anonymous)],\n asOpaqueBytes: [Function (anonymous)]\n }\n }\n },\n topics: []\n },\n {\n type: 'Balances',\n value: {\n type: 'Deposit',\n value: {\n who: '13UVJyLgBASGhE2ok3TvxUfaQBGUt88JCcdYjHvUhvQkFTTx',\n amount: 15668864n\n }\n },\n topics: []\n },\n {\n type: 'TransactionPayment',\n value: {\n type: 'TransactionFeePaid',\n value: {\n who: '15DMtB5BDCJqw4uZtByTWXGqViAVx7XjRsxWbTH5tfrHLe8j',\n actual_fee: 15668864n,\n tip: 0n\n }\n },\n topics: []\n },\n {\n type: 'System',\n value: {\n type: 'ExtrinsicSuccess',\n value: {\n dispatch_info: {\n weight: { ref_time: 952851000n, proof_size: 13382n },\n class: { type: 'Normal', value: undefined },\n pays_fee: { type: 'Yes', value: undefined }\n }\n }\n },\n topics: []\n }\n ]\n }\n
\nAfter executing the transfer, check the account balance on [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fsys.turboflakes.io%2Fasset-hub-paseo){target=\\_blank} for [Paseo's Asset Hub](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fsys.turboflakes.io%2Fasset-hub-paseo#/accounts){target=\\_blank} and [Paseo's People Chain](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fsys.ibp.network%2Fpeople-paseo#/accounts){target=\\_blank}.\n\nYou should see:\n\n- The recipient account now has 10 more PAS tokens.\n- The sender account has the transfer amount (10 PAS) + the fees amount debited from their account balance.\n\nYou have now successfully created and sent a cross-chain transfer using the ParaSpell XCM SDK!\n\n???- code \"Full Code\"\n\n ```typescript title=\"index.ts\"\n import { Builder, hasDryRunSupport } from '@paraspell/sdk';\n import {\n entropyToMiniSecret,\n mnemonicToEntropy,\n ss58Address,\n } from '@polkadot-labs/hdkd-helpers';\n import { getPolkadotSigner } from 'polkadot-api/signer';\n import { sr25519CreateDerive } from '@polkadot-labs/hdkd';\n import { inspect } from 'util';\n\n // PAS token has 10 decimals\n const PAS_UNITS = 10_000_000_000n;\n\n const SEED_PHRASE =\n 'INSERT_YOUR_SEED_PHRASE';\n\n // Create Sr25519 signer from mnemonic\n function getSigner() {\n const entropy = mnemonicToEntropy(SEED_PHRASE);\n const miniSecret = entropyToMiniSecret(entropy);\n const derive = sr25519CreateDerive(miniSecret);\n const keyPair = derive('');\n return getPolkadotSigner(keyPair.publicKey, 'Sr25519', keyPair.sign);\n }\n\n const RECIPIENT_ADDRESS = ss58Address(getSigner().publicKey);\n const SENDER_ADDRESS = ss58Address(getSigner().publicKey);\n\n async function transfer() {\n const signer = getSigner();\n\n const tx = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS, // 10 PAS\n })\n .address(RECIPIENT_ADDRESS)\n .build();\n\n console.log('Built transaction:', inspect(tx, { colors: true, depth: null }));\n\n const result = await tx.signAndSubmit(signer);\n console.log(inspect(result, { colors: true, depth: null }));\n process.exit(0);\n }\n\n async function dryRunTransfer() {\n if (!hasDryRunSupport('AssetHubPaseo')) {\n console.log('Dry run is not supported on AssetHubPaseo.');\n return;\n }\n\n const tx = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .dryRun();\n\n console.log(inspect(tx, { colors: true, depth: null }));\n process.exit(0);\n }\n\n dryRunTransfer();\n\n async function verifyED() {\n const isValid = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .verifyEdOnDestination();\n\n console.log(`ED verification ${isValid ? 'successful' : 'failed'}.`);\n process.exit(0);\n }\n\n verifyED();\n\n async function XcmTransferInfo() {\n const info = await Builder()\n .from('AssetHubPaseo')\n .to('PeoplePaseo')\n .currency({\n symbol: 'PAS',\n amount: 10n * PAS_UNITS,\n })\n .address(RECIPIENT_ADDRESS)\n .senderAddress(SENDER_ADDRESS)\n .getTransferInfo();\n\n console.log('Transfer Info:', info);\n process.exit(0);\n }\n\n XcmTransferInfo();\n\n transfer();\n\n ```"} +{"page_id": "chain-interactions-send-transactions-interoperability-transfer-assets-parachains", "page_title": "Transfer Assets Between Parachains", "index": 7, "depth": 2, "title": "Next Steps", "anchor": "next-steps", "start_char": 26422, "end_char": 26764, "estimated_token_count": 84, "token_estimator": "heuristic-v1", "text": "## Next Steps\n\n- Read the Docs: Dive deeper into the features of the [ParaSpell XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.html){target=\\_blank} documentation.\n\n- Learn about XCM: Understand the underlying protocol by visiting the [Introduction to XCM page](/parachains/interoperability/get-started/) in the Polkadot Docs."} {"page_id": "chain-interactions-send-transactions-pay-fees-with-different-tokens", "page_title": "Send a Transaction While Paying the Fee with a Different Token", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 66, "end_char": 389, "estimated_token_count": 58, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThe Asset Hub provides a powerful feature that allows users to pay transaction fees using alternative tokens instead of the native token of the chain.\n\nThis tutorial demonstrates how to send a DOT transfer transaction while paying the fees using a different token (USDT in this example) on the Asset Hub."} {"page_id": "chain-interactions-send-transactions-pay-fees-with-different-tokens", "page_title": "Send a Transaction While Paying the Fee with a Different Token", "index": 1, "depth": 2, "title": "Environment Setup", "anchor": "environment-setup", "start_char": 389, "end_char": 1465, "estimated_token_count": 288, "token_estimator": "heuristic-v1", "text": "## Environment Setup\n\nLet's set up the development environment for this tutorial:\n\n1. Create a new directory and initialize the project:\n\n ```bash\n mkdir fee-payment-tutorial && \\\n cd fee-payment-tutorial\n ```\n\n2. Initialize the project:\n\n ```bash\n npm init -y\n ```\n\n3. Install dev dependencies:\n\n ```bash\n npm install --save-dev @types/node@^22.12.0 ts-node@^10.9.2 typescript@^5.7.3\n ```\n\n4. Install dependencies:\n\n ```bash\n npm install --save @polkadot-labs/hdkd@^0.0.13 @polkadot-labs/hdkd-helpers@^0.0.13 polkadot-api@1.9.5\n ```\n\n5. Create TypeScript configuration:\n\n ```bash\n npx tsc --init && npm pkg set type=module\n ```\n\n The command `npm pkg set type=module` is used to set the type of the project to module. This is necessary to use the `import` statement in the TypeScript code.\n\n6. Generate Polkadot API types for Asset Hub:\n\n ```bash\n npx papi add assetHub -n polkadot_asset_hub\n ```\n\n7. Create a new file called `fee-payment-transaction.ts`:\n\n ```bash\n touch fee-payment-transaction.ts\n ```"} {"page_id": "chain-interactions-send-transactions-pay-fees-with-different-tokens", "page_title": "Send a Transaction While Paying the Fee with a Different Token", "index": 2, "depth": 2, "title": "Local Asset Hub Setup", "anchor": "local-asset-hub-setup", "start_char": 1465, "end_char": 2109, "estimated_token_count": 162, "token_estimator": "heuristic-v1", "text": "## Local Asset Hub Setup\n\nBefore running the script, you'll need to fork the Asset Hub locally using Chopsticks:\n\n```bash\nchopsticks -c polkadot-asset-hub\n```\n\nThis command forks the Asset Hub chain, making it available at `ws://localhost:8000`. By running `polkadot-asset-hub`, you're using the Asset Hub fork with the configuration specified in the [`polkadot-asset-hub.yml`](https://github.com/AcalaNetwork/chopsticks/blob/master/configs/polkadot-asset-hub.yml){target=_blank} file. This configuration defines Alice's account with USDT assets. If you want to use a different chain, ensure the account you're using has the necessary assets."} @@ -552,10 +552,22 @@ {"page_id": "parachains-customize-runtime-add-pallet-instances", "page_title": "Add Multiple Pallet Instances", "index": 18, "depth": 3, "title": "Interact with Both Pallet Instances", "anchor": "interact-with-both-pallet-instances", "start_char": 15206, "end_char": 16561, "estimated_token_count": 358, "token_estimator": "heuristic-v1", "text": "### Interact with Both Pallet Instances\n\nUse the Polkadot.js Apps interface to verify you can interact with both pallet instances independently.\n\nTo interact with the pallet instances:\n\n1. Navigate to [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/extrinsics){target=\\_blank}.\n2. Ensure you're connected to your local node at `ws://127.0.0.1:9944`.\n3. Go to the **Developer** > **Extrinsics** tab.\n4. In the **submit the following extrinsic** section, open the pallet dropdown. Verify that both pallet instances appear and contain the expected extrinsics.\n\n === \"Technical Committee\"\n\n Select **`technicalCommittee`** and open the extrinsics dropdown.\n\n ![](/images/parachains/customize-runtime/add-pallet-instances/add-pallet-instances-01.webp)\n\n === \"Council\"\n\n Select **`council`** and open the extrinsics dropdown.\n\n ![](/images/parachains/customize-runtime/add-pallet-instances/add-pallet-instances-02.webp)\n\nEach instance should display the following extrinsics (this is not an exhaustive list):\n\n- **`close(proposalHash, index, proposalWeightBound, lengthBound)`**: Close voting.\n- **`propose(threshold, proposal, lengthBound)`**: Submit a proposal.\n- **`setMembers(newMembers, prime, oldCount)`**: Update membership.\n- **`vote(proposal, index, approve)`**: Vote on a proposal."} {"page_id": "parachains-customize-runtime-add-pallet-instances", "page_title": "Add Multiple Pallet Instances", "index": 19, "depth": 3, "title": "Test Instance Independence", "anchor": "test-instance-independence", "start_char": 16561, "end_char": 17619, "estimated_token_count": 227, "token_estimator": "heuristic-v1", "text": "### Test Instance Independence\n\nVerify that both instances operate independently by testing their separate functionality.\n\nTo test instance independence:\n\n1. In Polkadot.js Apps, go to **Developer** > **Chain state**.\n2. Query storage for each instance:\n\n === \"Technical Committee\"\n\n Select **`technicalCommittee` > `members()`** to view technical committee members.\n\n ![](/images/parachains/customize-runtime/add-pallet-instances/add-pallet-instances-03.webp)\n\n === \"Council\"\n\n Select **`council` > `members()`** to view council members.\n\n ![](/images/parachains/customize-runtime/add-pallet-instances/add-pallet-instances-04.webp)\n\n3. Verify that:\n - Each instance maintains separate storage.\n - Changes to one instance don't affect the other.\n - Both instances can process proposals simultaneously.\n\nYou can now use both collective instances for different governance purposes in your parachain, such as technical decisions that require expertise and general governance decisions that require broader consensus."} {"page_id": "parachains-customize-runtime-add-pallet-instances", "page_title": "Add Multiple Pallet Instances", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 17619, "end_char": 17923, "estimated_token_count": 82, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Make a Custom Pallet__\n\n ---\n\n Learn how to create custom pallets using FRAME.\n\n [:octicons-arrow-right-24: Reference](/parachains/customize-runtime/pallet-development/create-a-pallet/)\n\n
"} -{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 36, "end_char": 704, "estimated_token_count": 118, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nWhen building your custom blockchain with the Polkadot SDK, you have the flexibility to add smart contract capabilities through specialized pallets. These pallets allow blockchain users to deploy and execute smart contracts, enhancing your chain's functionality and programmability.\n\nPolkadot SDK-based blockchains support two distinct smart contract execution environments: [EVM (Ethereum Virtual Machine)](#evm-smart-contracts) and [Wasm (WebAssembly)](#wasm-smart-contracts). Each environment allows developers to deploy and execute different types of smart contracts, providing flexibility in choosing the most suitable solution for their needs."} -{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 1, "depth": 2, "title": "EVM Smart Contracts", "anchor": "evm-smart-contracts", "start_char": 704, "end_char": 1957, "estimated_token_count": 327, "token_estimator": "heuristic-v1", "text": "## EVM Smart Contracts\n\nTo enable Ethereum-compatible smart contracts in your blockchain, you'll need to integrate [Frontier](https://github.com/polkadot-evm/frontier){target=\\_blank}, the Ethereum compatibility layer for Polkadot SDK-based chains. This requires adding two essential pallets to your runtime:\n\n- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\\_blank}**: Provides the EVM execution environment.\n- **[`pallet-ethereum`](https://github.com/polkadot-evm/frontier/tree/master/frame/ethereum){target=\\_blank}**: Handles Ethereum-formatted transactions and RPC capabilities.\n\nFor step-by-step guidance on adding these pallets to your runtime, refer to [Add a Pallet to the Runtime](/parachains/customize-runtime/add-existing-pallets/){target=\\_blank}.\n\nFor a real-world example of how these pallets are implemented in production, you can check Moonbeam's implementation of [`pallet-evm`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L532){target=\\_blank} and [`pallet-ethereum`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L698){target=\\_blank}."} -{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 2, "depth": 2, "title": "Wasm Smart Contracts", "anchor": "wasm-smart-contracts", "start_char": 1957, "end_char": 2772, "estimated_token_count": 197, "token_estimator": "heuristic-v1", "text": "## Wasm Smart Contracts\n\nTo support Wasm-based smart contracts, you'll need to integrate:\n\n- **[`pallet-contracts`](https://docs.rs/pallet-contracts/latest/pallet_contracts/index.html#contracts-pallet){target=\\_blank}**: Provides the Wasm smart contract execution environment.\n\nThis pallet enables the deployment and execution of Wasm-based smart contracts on your blockchain. For detailed instructions on adding this pallet to your runtime, see [Add a Pallet to the Runtime](/parachains/customize-runtime/add-existing-pallets/){target=\\_blank}.\n\nFor a real-world example of how this pallet is implemented in production, you can check Astar's implementation of [`pallet-contracts`](https://github.com/AstarNetwork/Astar/blob/b6f7a408d31377130c3713ed52941a06b5436402/runtime/astar/src/lib.rs#L693){target=\\_blank}."} -{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 3, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 2772, "end_char": 3865, "estimated_token_count": 259, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nNow that you understand how to enable smart contract functionality in your blockchain, you might want to:\n\n
\n\n- Guide __Get Started with Smart Contracts__\n\n ---\n\n Learn how developers can build smart contracts on Polkadot by leveraging the PolkaVM, Wasm/ink! or EVM contracts across many parachains.\n\n [:octicons-arrow-right-24: Reference](/smart-contracts/get-started/)\n\n- Guide __Wasm (ink!) Contracts__\n\n ---\n\n Learn to build Wasm smart contracts with ink!, a Rust-based eDSL. Explore installation, contract structure, and key features.\n\n [:octicons-arrow-right-24: Reference](/smart-contracts/overview/#wasm-ink)\n \n- Guide __EVM Contracts__\n\n ---\n\n Learn how Polkadot parachains such as Moonbeam, Astar, Acala, and Manta leverage the Ethereum Virtual Machine (EVM) and integrate it into their parachains.\n\n [:octicons-arrow-right-24: Reference](/smart-contracts/overview/#parachain-contracts)\n\n
"} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 36, "end_char": 724, "estimated_token_count": 139, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nWhen building your custom blockchain with the Polkadot SDK, you can add smart contract capabilities through specialized pallets. These pallets enable users to deploy and execute smart contracts, enhancing your chain's programmability and allowing developers to build decentralized applications on your network.\n\nThis guide covers three approaches to adding smart contracts to your blockchain:\n\n- **[`pallet-revive`](#pallet-revive)**: Modern unified solution supporting both PolkaVM and EVM bytecode\n- **[Frontier](#frontier)**: Ethereum compatibility layer for Polkadot SDK-based chains\n- **[`pallet-contracts`](#pallet-contracts-legacy)**: Wasm smart contract support"} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 1, "depth": 2, "title": "pallet-revive", "anchor": "pallet-revive", "start_char": 724, "end_char": 1046, "estimated_token_count": 74, "token_estimator": "heuristic-v1", "text": "## pallet-revive\n\n[`pallet-revive`](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame/revive){target=\\_blank} is the modern smart contract solution for Polkadot SDK-based chains. It provides a unified execution environment that supports both PolkaVM and EVM bytecode through dual execution backends."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 2, "depth": 3, "title": "Core Components", "anchor": "core-components", "start_char": 1046, "end_char": 1841, "estimated_token_count": 230, "token_estimator": "heuristic-v1", "text": "### Core Components\n\n**Essential Pallet:**\n**[`pallet-revive`](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame/revive){target=\\_blank}** provides the core smart contract execution environment with [PolkaVM](https://github.com/polkadot-developers/polkadot-docs/blob/71e1b51bb42ef55e20c2f3b953db86e8c26cd591/smart-contracts/for-eth-devs/dual-vm-stack.md#upgrade-to-polkavm){target=\\_blank} and [REVM](https://github.com/polkadot-developers/polkadot-docs/blob/71e1b51bb42ef55e20c2f3b953db86e8c26cd591/smart-contracts/for-eth-devs/dual-vm-stack.md#migrate-from-evm){target=\\_blank} backends.\n\n**RPC Adapter:**\n**[`pallet-revive-eth-rpc`](https://crates.io/crates/pallet-revive-eth-rpc){target=\\_blank}** adds full Ethereum RPC compatibility for Ethereum tooling integration."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 3, "depth": 3, "title": "Supported Languages and Compilers", "anchor": "supported-languages-and-compilers", "start_char": 1841, "end_char": 2463, "estimated_token_count": 196, "token_estimator": "heuristic-v1", "text": "### Supported Languages and Compilers\n\n`pallet-revive` accepts smart contracts from multiple languages and compilation paths:\n\n| Language | Compiler | Output Bytecode | Execution Backend |\n|----------|----------|-----------------|-------------------|\n| Solidity | `resolc` | PolkaVM | PolkaVM |\n| Solidity | `solc` | EVM | REVM |\n| Rust (ink!) | `cargo-contract` | PolkaVM | PolkaVM | \n\nAny language that can compile to PolkaVM bytecode and utilize `pallet-revive`'s host functions (via [`pallet-revive-uapi`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive_uapi/index.html){target=\\_blank}) is supported."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 4, "depth": 3, "title": "How It Works", "anchor": "how-it-works", "start_char": 2463, "end_char": 2723, "estimated_token_count": 54, "token_estimator": "heuristic-v1", "text": "### How It Works\n\n**Dual Execution Model:**\n\n1. **PolkaVM Backend**: Executes PolkaVM bytecode with native performance optimization.\n2. **REVM Backend**: Implements EVM bytecode for compatibility with existing Ethereum contracts, ensuring seamless migration."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 5, "depth": 3, "title": "Key Benefits", "anchor": "key-benefits", "start_char": 2723, "end_char": 3199, "estimated_token_count": 106, "token_estimator": "heuristic-v1", "text": "### Key Benefits\n\n- **Unified platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet.\n- **Performance**: PolkaVM execution provides improved performance compared to the traditional EVM, leveraging the [RISC-V](https://en.wikipedia.org/wiki/RISC-V){target=\\_blank} architecture to map instructions to the CPU and requires little transpiling.\n- **Ethereum compatibility**: Supports full integration with Ethereum tooling via RPC adapter."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 6, "depth": 3, "title": "Implementation Examples", "anchor": "implementation-examples", "start_char": 3199, "end_char": 3489, "estimated_token_count": 69, "token_estimator": "heuristic-v1", "text": "### Implementation Examples\n\nSee a real-world implementation in the [Polkadot Hub TestNet](https://github.com/paseo-network/runtimes/blob/c965c42a4e0bc9d1e9cc0a340322bc3b8e347bcf/system-parachains/asset-hub-paseo/src/lib.rs#L1122-L1157){target=\\_blank} in the Polkadot Fellows repository."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 7, "depth": 2, "title": "Frontier", "anchor": "frontier", "start_char": 3489, "end_char": 3786, "estimated_token_count": 62, "token_estimator": "heuristic-v1", "text": "## Frontier\n\n[Frontier](https://github.com/polkadot-evm/frontier){target=\\_blank} is the Ethereum compatibility layer designed for maximum compatibility with the Ethereum ecosystem. It's the ideal choice when you need seamless integration with existing Ethereum tools, dApps, and infrastructure."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 8, "depth": 3, "title": "Integration Options", "anchor": "integration-options", "start_char": 3786, "end_char": 3888, "estimated_token_count": 15, "token_estimator": "heuristic-v1", "text": "### Integration Options\n\nFrontier offers flexible integration depending on your compatibility needs:"} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 9, "depth": 3, "title": "EVM Execution Only", "anchor": "evm-execution-only", "start_char": 3888, "end_char": 4228, "estimated_token_count": 82, "token_estimator": "heuristic-v1", "text": "### EVM Execution Only\n\nFor basic EVM support using Polkadot SDK native APIs:\n\n- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\\_blank}**: Provides the core EVM execution environment.\n\nThis configuration allows EVM contract execution but requires using Polkadot SDK-specific APIs for interaction."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 10, "depth": 3, "title": "Full Ethereum Compatibility", "anchor": "full-ethereum-compatibility", "start_char": 4228, "end_char": 4798, "estimated_token_count": 165, "token_estimator": "heuristic-v1", "text": "### Full Ethereum Compatibility\n\nFor complete Ethereum ecosystem integration with Ethereum RPC support:\n\n- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\\_blank}**: Integrates core EVM execution environment.\n- **[`pallet-ethereum`](https://github.com/polkadot-evm/frontier/tree/master/frame/ethereum){target=\\_blank}**: Emulates Ethereum blocks and handles Ethereum-formatted transactions.\n- **[`fc-rpc`](https://github.com/polkadot-evm/frontier/tree/master/client/rpc){target=\\_blank}**: Provides Ethereum JSON-RPC endpoints."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 11, "depth": 3, "title": "Key Benefits", "anchor": "key-benefits-2", "start_char": 4798, "end_char": 5253, "estimated_token_count": 93, "token_estimator": "heuristic-v1", "text": "### Key Benefits\n\n- **Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Foundry, and other Ethereum development tools.\n- **Minimal-friction migration**: Deployment of existing Ethereum dApps with minimal or no modifications.\n- **Native Ethereum formats**: Support for Ethereum transaction formats, signatures, and gas mechanics.\n- **Block emulation**: Ethereum-style block structure within Substrate's block production."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 12, "depth": 3, "title": "Implementation Examples", "anchor": "implementation-examples-2", "start_char": 5253, "end_char": 5720, "estimated_token_count": 114, "token_estimator": "heuristic-v1", "text": "### Implementation Examples\n\nProduction implementations demonstrate Frontier's capabilities:\n\n- **Moonbeam**: See their implementation of [`pallet-evm`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L532){target=\\_blank} and [`pallet-ethereum`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L698){target=\\_blank}."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 13, "depth": 2, "title": "pallet-contracts (Legacy)", "anchor": "pallet-contracts-legacy", "start_char": 5720, "end_char": 6051, "estimated_token_count": 81, "token_estimator": "heuristic-v1", "text": "## pallet-contracts (Legacy)\n\n[`pallet-contracts`](https://docs.rs/pallet-contracts/latest/pallet_contracts/index.html#contracts-pallet){target=\\_blank} is the original Wasm-based smart contract pallet for Polkadot SDK chains. While still functional, it's considered legacy as development efforts have shifted to `pallet-revive`."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 14, "depth": 3, "title": "Implementation Example", "anchor": "implementation-example", "start_char": 6051, "end_char": 6304, "estimated_token_count": 59, "token_estimator": "heuristic-v1", "text": "### Implementation Example\n\nFor reference, Astar's implementation of [`pallet-contracts`](https://github.com/AstarNetwork/Astar/blob/b6f7a408d31377130c3713ed52941a06b5436402/runtime/astar/src/lib.rs#L693){target=\\_blank} demonstrates production usage."} +{"page_id": "parachains-customize-runtime-add-smart-contract-functionality", "page_title": "Add Smart Contract Functionality", "index": 15, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6304, "end_char": 6655, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Add a Pallet to the Runtime__\n\n ---\n\n Learn the step-by-step process for integrating Polkadot SDK pallets into your blockchain's runtime.\n\n [:octicons-arrow-right-24: Get Started](/parachains/customize-runtime/add-existing-pallets/)\n\n
"} {"page_id": "parachains-customize-runtime-pallet-development-add-pallet-to-runtime", "page_title": "Add Pallets to the Runtime", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 30, "end_char": 866, "estimated_token_count": 192, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nIn 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.\n\nThis 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."} {"page_id": "parachains-customize-runtime-pallet-development-add-pallet-to-runtime", "page_title": "Add Pallets to the Runtime", "index": 1, "depth": 2, "title": "Add the Pallets as Dependencies", "anchor": "add-the-pallets-as-dependencies", "start_char": 866, "end_char": 8510, "estimated_token_count": 1856, "token_estimator": "heuristic-v1", "text": "## Add the Pallets as Dependencies\n\nFirst, 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:\n\n1. 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:\n\n ```toml hl_lines=\"4\" title=\"runtime/Cargo.toml\"\n [dependencies]\n ...\n polkadot-sdk = { workspace = true, features = [\n \"pallet-utility\",\n ...\n ], default-features = false }\n ```\n\n2. In the same `[dependencies]` section, add the custom pallet that you built from scratch with the following line:\n\n ```toml hl_lines=\"3\" title=\"Cargo.toml\"\n [dependencies]\n ...\n custom-pallet = { path = \"../pallets/custom-pallet\", default-features = false }\n ```\n\n3. In the `[features]` section, add the custom pallet to the `std` feature list:\n\n ```toml hl_lines=\"5\" title=\"Cargo.toml\"\n [features]\n default = [\"std\"]\n std = [\n ...\n \"custom-pallet/std\",\n ...\n ]\n ```\n\n3. Save the changes and close the `Cargo.toml` file.\n\n Once you have saved your file, it should look like the following:\n\n ???- code \"runtime/Cargo.toml\"\n \n ```rust title=\"runtime/Cargo.toml\"\n [package]\n name = \"parachain-template-runtime\"\n description = \"A parachain runtime template built with Substrate and Cumulus, part of Polkadot Sdk.\"\n version = \"0.1.0\"\n license = \"Unlicense\"\n authors.workspace = true\n homepage.workspace = true\n repository.workspace = true\n edition.workspace = true\n publish = false\n\n [package.metadata.docs.rs]\n targets = [\"x86_64-unknown-linux-gnu\"]\n\n [build-dependencies]\n docify = { workspace = true }\n substrate-wasm-builder = { optional = true, workspace = true, default-features = true }\n\n [dependencies]\n codec = { features = [\"derive\"], workspace = true }\n cumulus-pallet-parachain-system.workspace = true\n docify = { workspace = true }\n hex-literal = { optional = true, workspace = true, default-features = true }\n log = { workspace = true }\n pallet-parachain-template = { path = \"../pallets/template\", default-features = false }\n polkadot-sdk = { workspace = true, features = [\n \"pallet-utility\",\n \"cumulus-pallet-aura-ext\",\n \"cumulus-pallet-session-benchmarking\",\n \"cumulus-pallet-weight-reclaim\",\n \"cumulus-pallet-xcm\",\n \"cumulus-pallet-xcmp-queue\",\n \"cumulus-primitives-aura\",\n \"cumulus-primitives-core\",\n \"cumulus-primitives-utility\",\n \"pallet-aura\",\n \"pallet-authorship\",\n \"pallet-balances\",\n \"pallet-collator-selection\",\n \"pallet-message-queue\",\n \"pallet-session\",\n \"pallet-sudo\",\n \"pallet-timestamp\",\n \"pallet-transaction-payment\",\n \"pallet-transaction-payment-rpc-runtime-api\",\n \"pallet-xcm\",\n \"parachains-common\",\n \"polkadot-parachain-primitives\",\n \"polkadot-runtime-common\",\n \"runtime\",\n \"staging-parachain-info\",\n \"staging-xcm\",\n \"staging-xcm-builder\",\n \"staging-xcm-executor\",\n ], default-features = false }\n scale-info = { features = [\"derive\"], workspace = true }\n serde_json = { workspace = true, default-features = false, features = [\n \"alloc\",\n ] }\n smallvec = { workspace = true, default-features = true }\n\n custom-pallet = { path = \"../pallets/custom-pallet\", default-features = false }\n\n [features]\n default = [\"std\"]\n std = [\n \"codec/std\",\n \"cumulus-pallet-parachain-system/std\",\n \"log/std\",\n \"pallet-parachain-template/std\",\n \"polkadot-sdk/std\",\n \"scale-info/std\",\n \"serde_json/std\",\n \"substrate-wasm-builder\",\n \"custom-pallet/std\",\n ]\n\n runtime-benchmarks = [\n \"cumulus-pallet-parachain-system/runtime-benchmarks\",\n \"hex-literal\",\n \"pallet-parachain-template/runtime-benchmarks\",\n \"polkadot-sdk/runtime-benchmarks\",\n ]\n\n try-runtime = [\n \"cumulus-pallet-parachain-system/try-runtime\",\n \"pallet-parachain-template/try-runtime\",\n \"polkadot-sdk/try-runtime\",\n ]\n\n # Enable the metadata hash generation.\n #\n # This is hidden behind a feature because it increases the compile time.\n # The wasm binary needs to be compiled twice, once to fetch the metadata,\n # generate the metadata hash and then a second time with the\n # `RUNTIME_METADATA_HASH` environment variable set for the `CheckMetadataHash`\n # extension.\n metadata-hash = [\"substrate-wasm-builder/metadata-hash\"]\n\n # A convenience feature for enabling things when doing a build\n # for an on-chain release.\n on-chain-release-build = [\"metadata-hash\"]\n\n ```\n\nUpdate your root parachain template's `Cargo.toml` file to include your custom pallet as a dependency. Follow these steps:\n\n1. Open the `./Cargo.toml` file and locate the `[workspace]` section. \n \n Make sure the `custom-pallet` is a member of the workspace:\n\n ```toml hl_lines=\"4\" title=\"Cargo.toml\"\n [workspace]\n default-members = [\"pallets/template\", \"runtime\"]\n members = [\n \"node\", \"pallets/custom-pallet\",\n \"pallets/template\",\n \"runtime\",\n ]\n ```\n\n???- code \"./Cargo.toml\"\n\n ```rust title=\"./Cargo.toml\"\n [workspace.package]\n license = \"MIT-0\"\n authors = [\"Parity Technologies \"]\n homepage = \"https://paritytech.github.io/polkadot-sdk/\"\n repository = \"https://github.com/paritytech/polkadot-sdk-parachain-template.git\"\n edition = \"2021\"\n\n [workspace]\n default-members = [\"pallets/template\", \"runtime\"]\n members = [\n \"node\", \"pallets/custom-pallet\",\n \"pallets/template\",\n \"runtime\",\n ]\n resolver = \"2\"\n\n [workspace.dependencies]\n parachain-template-runtime = { path = \"./runtime\", default-features = false }\n pallet-parachain-template = { path = \"./pallets/template\", default-features = false }\n clap = { version = \"4.5.13\" }\n color-print = { version = \"0.3.4\" }\n docify = { version = \"0.2.9\" }\n futures = { version = \"0.3.31\" }\n jsonrpsee = { version = \"0.24.3\" }\n log = { version = \"0.4.22\", default-features = false }\n polkadot-sdk = { version = \"2503.0.1\", default-features = false }\n prometheus-endpoint = { version = \"0.17.2\", default-features = false, package = \"substrate-prometheus-endpoint\" }\n serde = { version = \"1.0.214\", default-features = false }\n codec = { version = \"3.7.4\", default-features = false, package = \"parity-scale-codec\" }\n cumulus-pallet-parachain-system = { version = \"0.20.0\", default-features = false }\n hex-literal = { version = \"0.4.1\", default-features = false }\n scale-info = { version = \"2.11.6\", default-features = false }\n serde_json = { version = \"1.0.132\", default-features = false }\n smallvec = { version = \"1.11.0\", default-features = false }\n substrate-wasm-builder = { version = \"26.0.1\", default-features = false }\n frame = { version = \"0.9.1\", default-features = false, package = \"polkadot-sdk-frame\" }\n\n [profile.release]\n opt-level = 3\n panic = \"unwind\"\n\n [profile.production]\n codegen-units = 1\n inherits = \"release\"\n lto = true\n ```"} {"page_id": "parachains-customize-runtime-pallet-development-add-pallet-to-runtime", "page_title": "Add Pallets to the Runtime", "index": 2, "depth": 3, "title": "Update the Runtime Configuration", "anchor": "update-the-runtime-configuration", "start_char": 8510, "end_char": 10415, "estimated_token_count": 406, "token_estimator": "heuristic-v1", "text": "### Update the Runtime Configuration\n\nConfigure the pallets by implementing their `Config` trait and update the runtime macro to include the new pallets:\n\n1. Add the `OriginCaller` import:\n\n ```rust title=\"mod.rs\" hl_lines=\"8\"\n // Local module imports\n use super::OriginCaller;\n ...\n ```\n\n2. 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:\n\n ```rust title=\"mod.rs\" hl_lines=\"8-25\"\n ...\n /// Configure the pallet template in pallets/template.\n impl pallet_parachain_template::Config for Runtime {\n type RuntimeEvent = RuntimeEvent;\n type WeightInfo = pallet_parachain_template::weights::SubstrateWeight;\n }\n\n // Configure utility pallet.\n impl pallet_utility::Config for Runtime {\n type RuntimeEvent = RuntimeEvent;\n type RuntimeCall = RuntimeCall;\n type PalletsOrigin = OriginCaller;\n type WeightInfo = pallet_utility::weights::SubstrateWeight;\n }\n // Define counter max value runtime constant.\n parameter_types! {\n pub const CounterMaxValue: u32 = 500;\n }\n\n // Configure custom pallet.\n impl custom_pallet::Config for Runtime {\n type RuntimeEvent = RuntimeEvent;\n type CounterMaxValue = CounterMaxValue;\n }\n ```\n\n3. Locate the `#[frame_support::runtime]` macro in the `runtime/src/lib.rs` file and add the pallets:\n\n ```rust hl_lines=\"9-14\" title=\"lib.rs\"\n #[frame_support::runtime]\n mod runtime {\n #[runtime::runtime]\n #[runtime::derive(\n ...\n )]\n pub struct Runtime;\n #[runtime::pallet_index(51)]\n pub type Utility = pallet_utility;\n\n #[runtime::pallet_index(52)]\n pub type CustomPallet = custom_pallet;\n }\n ```"} @@ -571,61 +583,6 @@ {"page_id": "parachains-customize-runtime-pallet-development-benchmark-pallet", "page_title": "Benchmarking FRAME Pallets", "index": 6, "depth": 3, "title": "Add Benchmarks to Runtime", "anchor": "add-benchmarks-to-runtime", "start_char": 7718, "end_char": 9847, "estimated_token_count": 418, "token_estimator": "heuristic-v1", "text": "### Add Benchmarks to Runtime\n\nBefore running the benchmarking tool, you must integrate benchmarks with your runtime as follows:\n\n1. Navigate to your `runtime/src` directory and check if a `benchmarks.rs` file exists. If not, create one. This file will contain the macro that registers all pallets for benchmarking along with their respective configurations:\n\n ```rust title=\"benchmarks.rs\"\n frame_benchmarking::define_benchmarks!(\n [frame_system, SystemBench::]\n [pallet_parachain_template, TemplatePallet]\n [pallet_balances, Balances]\n [pallet_session, SessionBench::]\n [pallet_timestamp, Timestamp]\n [pallet_message_queue, MessageQueue]\n [pallet_sudo, Sudo]\n [pallet_collator_selection, CollatorSelection]\n [cumulus_pallet_parachain_system, ParachainSystem]\n [cumulus_pallet_xcmp_queue, XcmpQueue]\n );\n ```\n\n For example, to add a new pallet named `pallet_parachain_template` for benchmarking, include it in the macro as shown:\n ```rust title=\"benchmarks.rs\" hl_lines=\"3\"\n frame_benchmarking::define_benchmarks!(\n [frame_system, SystemBench::]\n [pallet_parachain_template, TemplatePallet]\n );\n ```\n\n !!!warning \"Updating `define_benchmarks!` macro is required\"\n Any pallet that needs to be benchmarked must be included in the [`define_benchmarks!`](https://paritytech.github.io/polkadot-sdk/master/frame_benchmarking/macro.define_benchmarks.html){target=\\_blank} macro. The CLI will only be able to access and benchmark pallets that are registered here.\n\n2. Check your runtime's `lib.rs` file to ensure the `benchmarks` module is imported. The import should look like this:\n\n ```rust title=\"lib.rs\"\n #[cfg(feature = \"runtime-benchmarks\")]\n mod benchmarks;\n ```\n\n The `runtime-benchmarks` feature gate ensures benchmark tests are isolated from production runtime code.\n\n3. Enable runtime benchmarking for your pallet in `runtime/Cargo.toml`:\n\n ```toml\n runtime-benchmarks = [\n # ...\n \"pallet_parachain_template/runtime-benchmarks\",\n ]\n\n ```"} {"page_id": "parachains-customize-runtime-pallet-development-benchmark-pallet", "page_title": "Benchmarking FRAME Pallets", "index": 7, "depth": 3, "title": "Run Benchmarks", "anchor": "run-benchmarks", "start_char": 9847, "end_char": 14232, "estimated_token_count": 1100, "token_estimator": "heuristic-v1", "text": "### Run Benchmarks\n\nYou can now compile your runtime with the `runtime-benchmarks` feature flag. This feature flag is crucial as the benchmarking tool will look for this feature being enabled to know when it should run benchmark tests. Follow these steps to compile the runtime with benchmarking enabled:\n\n1. Run `build` with the feature flag included:\n\n ```bash\n cargo build --features runtime-benchmarks --release\n ```\n\n2. Create a `weights.rs` file in your pallet's `src/` directory. This file will store the auto-generated weight calculations:\n\n ```bash\n touch weights.rs\n ```\n\n3. Before running the benchmarking tool, you'll need a template file that defines how weight information should be formatted. Download the official template from the Polkadot SDK repository and save it in your project folders for future use:\n\n ```bash\n curl https://raw.githubusercontent.com/paritytech/polkadot-sdk/refs/tags/polkadot-stable2412/substrate/.maintain/frame-weight-template.hbs \\\n --output ./pallets/benchmarking/frame-weight-template.hbs\n ```\n\n4. Run the benchmarking tool to measure extrinsic weights:\n\n ```bash\n frame-omni-bencher v1 benchmark pallet \\\n --runtime INSERT_PATH_TO_WASM_RUNTIME \\\n --pallet INSERT_NAME_OF_PALLET \\\n --extrinsic \"\" \\\n --template ./frame-weight-template.hbs \\\n --output weights.rs\n ```\n\n !!! tip \"Flag definitions\"\n - **`--runtime`**: The path to your runtime's Wasm.\n - **`--pallet`**: The name of the pallet you wish to benchmark. This pallet must be configured in your runtime and defined in `define_benchmarks`.\n - **`--extrinsic`**: Which extrinsic to test. Using `\"\"` implies all extrinsics will be benchmarked.\n - **`--template`**: Defines how weight information should be formatted.\n - **`--output`**: Where the output of the auto-generated weights will reside.\n\nThe generated `weights.rs` file contains weight annotations for your extrinsics, ready to be added to your pallet. The output should be similar to the following. Some output is omitted for brevity:\n\n
\n frame-omni-bencher v1 benchmark pallet \\\n --runtime INSERT_PATH_TO_WASM_RUNTIME \\\n --pallet \"INSERT_NAME_OF_PALLET\" \\\n --extrinsic \"\" \\\n --template ./frame-weight-template.hbs \\\n --output ./weights.rs\n ...\n 2025-01-15T16:41:33.557045Z INFO polkadot_sdk_frame::benchmark::pallet: [ 0 % ] Starting benchmark: pallet_parachain_template::do_something\n 2025-01-15T16:41:33.564644Z INFO polkadot_sdk_frame::benchmark::pallet: [ 50 % ] Starting benchmark: pallet_parachain_template::cause_error\n ...\n Created file: \"weights.rs\"\n \n
\n\n#### Add Benchmark Weights to Pallet\n\nOnce the `weights.rs` is generated, you must integrate it with your pallet. \n\n1. To begin the integration, import the `weights` module and the `WeightInfo` trait, then add both to your pallet's `Config` trait. Complete the following steps to set up the configuration:\n\n ```rust title=\"lib.rs\"\n pub mod weights;\n use crate::weights::WeightInfo;\n\n /// Configure the pallet by specifying the parameters and types on which it depends.\n #[pallet::config]\n pub trait Config: frame_system::Config {\n // ...\n /// A type representing the weights required by the dispatchables of this pallet.\n type WeightInfo: WeightInfo;\n }\n ```\n\n2. Next, you must add this to the `#[pallet::weight]` annotation in all the extrinsics via the `Config` as follows:\n\n ```rust hl_lines=\"2\" title=\"lib.rs\"\n #[pallet::call_index(0)]\n #[pallet::weight(T::WeightInfo::do_something())]\n pub fn do_something(origin: OriginFor) -> DispatchResultWithPostInfo { Ok(()) }\n ```\n\n3. Finally, configure the actual weight values in your runtime. In `runtime/src/config/mod.rs`, add the following code:\n\n ```rust title=\"mod.rs\"\n // Configure pallet.\n impl pallet_parachain_template::Config for Runtime {\n // ...\n type WeightInfo = pallet_parachain_template::weights::SubstrateWeight;\n }\n ```"} {"page_id": "parachains-customize-runtime-pallet-development-benchmark-pallet", "page_title": "Benchmarking FRAME Pallets", "index": 8, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 14232, "end_char": 14715, "estimated_token_count": 114, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n- View the Rust Docs for a more comprehensive, low-level view of the [FRAME V2 Benchmarking Suite](https://paritytech.github.io/polkadot-sdk/master/frame_benchmarking/v2/index.html){target=_blank}.\n- Read the [FRAME Benchmarking and Weights](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_benchmarking_weight/index.html){target=_blank} reference document, a concise guide which details how weights and benchmarking work."} -<<<<<<< HEAD -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 24, "end_char": 1130, "estimated_token_count": 216, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[Framework for Runtime Aggregation of Modular Entities (FRAME)](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html){target=\\_blank} provides a powerful set of tools for blockchain development through modular components called [pallets](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/pallet/index.html){target=\\_blank}. These Rust-based runtime modules allow you to build custom blockchain functionality with precision and flexibility. While FRAME includes a library of pre-built pallets, its true strength lies in the ability to create custom pallets tailored to your specific needs.\n\nIn this guide, you'll learn how to build a custom counter pallet from scratch that demonstrates core pallet development concepts. The pallet you'll create includes:\n\n- User-triggered increment and decrement operations\n- Root-only counter value setting\n- Event emission for state changes\n- Custom error handling\n- Storage management\n- User interaction tracking\n- Genesis configuration for initial state"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 1130, "end_char": 1497, "estimated_token_count": 96, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have:\n\n- [Polkadot SDK dependencies installed](/parachains/install-polkadot-sdk/){target=\\_blank}\n- A [Polkadot SDK Parchain Template](/parachains/launch-a-parachain/set-up-the-parachain-template/){target=\\_blank} set up locally\n- Basic familiarity with [FRAME concepts](/parachains/customize-runtime/){target=\\_blank}"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 2, "depth": 2, "title": "Core Pallet Components", "anchor": "core-pallet-components", "start_char": 1497, "end_char": 2372, "estimated_token_count": 193, "token_estimator": "heuristic-v1", "text": "## Core Pallet Components\n\nAs you build your custom pallet, you'll work with these key sections:\n\n- **Imports and dependencies**: Bring in necessary FRAME libraries and external modules.\n- **Runtime configuration trait**: Specify types and constants for pallet-runtime interaction.\n- **Runtime events**: Define signals that communicate state changes.\n- **Runtime errors**: Define error types returned from dispatchable calls.\n- **Runtime storage**: Declare on-chain storage items for your pallet's state.\n- **Genesis configuration**: Set initial blockchain state.\n- **Dispatchable functions (extrinsics)**: Create callable functions for user interactions.\n\nFor additional macros beyond those covered here, refer to the [pallet_macros](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/index.html){target=\\_blank} section of the Polkadot SDK Docs."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 3, "depth": 2, "title": "Create the Pallet Project", "anchor": "create-the-pallet-project", "start_char": 2372, "end_char": 3111, "estimated_token_count": 180, "token_estimator": "heuristic-v1", "text": "## Create the Pallet Project\n\nBegin by creating a new Rust library project for your custom pallet within the [Polkadot SDK Parachain Template](https://github.com/paritytech/polkadot-sdk-parachain-template){target=\\_blank}:\n\n1. Navigate to the root directory of your parachain template:\n\n ```bash\n cd polkadot-sdk-parachain-template\n ```\n\n2. Navigate to the `pallets` directory:\n\n ```bash\n cd pallets\n ```\n\n3. Create a new Rust library project:\n\n ```bash\n cargo new --lib pallet-custom\n ```\n\n4. Enter the new project directory:\n\n ```bash\n cd pallet-custom\n ```\n\n5. Verify the project structure. It should look like:\n\n ```\n pallet-custom/\n ├── Cargo.toml\n └── src/\n └── lib.rs\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 4, "depth": 2, "title": "Configure Dependencies", "anchor": "configure-dependencies", "start_char": 3111, "end_char": 4892, "estimated_token_count": 386, "token_estimator": "heuristic-v1", "text": "## Configure Dependencies\n\nTo integrate your custom pallet into the Polkadot SDK-based runtime, configure the `Cargo.toml` file with the required dependencies. Since your pallet exists within the parachain template workspace, you'll use workspace inheritance to maintain version consistency.\n\n1. Open `Cargo.toml` and replace its contents with:\n\n ```toml title=\"pallet-custom/Cargo.toml\"\n [package]\n name = \"pallet-custom\"\n description = \"A custom counter pallet for demonstration purposes.\"\n version = \"0.1.0\"\n license = \"Unlicense\"\n authors.workspace = true\n homepage.workspace = true\n repository.workspace = true\n edition.workspace = true\n publish = false\n\n [package.metadata.docs.rs]\n targets = [\"x86_64-unknown-linux-gnu\"]\n\n [dependencies]\n codec = { features = [\"derive\"], workspace = true }\n scale-info = { features = [\"derive\"], workspace = true }\n frame = { features = [\"experimental\", \"runtime\"], workspace = true }\n\n [features]\n default = [\"std\"]\n std = [\n \"codec/std\",\n \"scale-info/std\",\n \"frame/std\",\n ]\n ```\n\n !!!note \"Version Management\"\n The parachain template uses workspace inheritance to maintain consistent dependency versions across all packages. The actual versions are defined in the root `Cargo.toml` file, ensuring compatibility throughout the project. By using `workspace = true`, your pallet automatically inherits the correct versions.\n\n2. The parachain template already includes `pallets/*` in the workspace members, so your new pallet is automatically recognized. Verify this by checking the root `Cargo.toml`:\n\n ```toml title=\"Cargo.toml\"\n [workspace.members]\n members = [\n \"node\",\n \"pallets/*\",\n \"runtime\",\n ]\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 5, "depth": 2, "title": "Initialize the Pallet Structure", "anchor": "initialize-the-pallet-structure", "start_char": 4892, "end_char": 6071, "estimated_token_count": 269, "token_estimator": "heuristic-v1", "text": "## Initialize the Pallet Structure\n\nWith dependencies configured, set up the basic scaffold that will hold your pallet's logic:\n\n1. Open `src/lib.rs` and delete all existing content.\n\n2. Add the initial scaffold structure using the unified `frame` dependency:\n\n ```rust title=\"src/lib.rs\"\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[frame::pallet]\n pub mod pallet {\n use frame::prelude::*;\n\n #[pallet::pallet]\n pub struct Pallet(_);\n\n #[pallet::config]\n pub trait Config: frame_system::Config {\n // Configuration will be added here\n }\n\n #[pallet::storage]\n pub type CounterValue = StorageValue<_, u32, ValueQuery>;\n\n #[pallet::call]\n impl Pallet {\n // Dispatchable functions will be added here\n }\n }\n ```\n\n !!!note\n This setup starts with a minimal scaffold without events and errors. These will be added in the following sections after the `Config` trait is properly configured with the required `RuntimeEvent` type.\n\n3. Verify it compiles:\n\n ```bash\n cargo build --package pallet-custom\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 6, "depth": 2, "title": "Configure the Pallet", "anchor": "configure-the-pallet", "start_char": 6071, "end_char": 7327, "estimated_token_count": 320, "token_estimator": "heuristic-v1", "text": "## Configure the Pallet\n\nThe [`Config`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/trait.Config.html){target=\\_blank} trait exposes configurable options and links your pallet to the runtime. All types and constants the pallet depends on must be declared here. These types are defined generically and become concrete when the pallet is instantiated at runtime.\n\nReplace the [`#[pallet::config]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.config.html){target=\\_blank} section with:\n\n```rust title=\"src/lib.rs\"\n#[pallet::config]\npub trait Config: frame_system::Config {\n /// The overarching runtime event type.\n type RuntimeEvent: From> + IsType<::RuntimeEvent>;\n \n /// Maximum value the counter can reach.\n #[pallet::constant]\n type CounterMaxValue: Get;\n}\n```\n\n**Key configuration elements:**\n\n- **[`RuntimeEvent`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/trait.Config.html#associatedtype.RuntimeEvent){target=\\_blank}**: Required for the pallet to emit events that the runtime can process.\n- **`CounterMaxValue`**: A constant that sets an upper limit on counter values, configurable per runtime."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 7, "depth": 2, "title": "Define Events", "anchor": "define-events", "start_char": 7327, "end_char": 8742, "estimated_token_count": 344, "token_estimator": "heuristic-v1", "text": "## Define Events\n\nEvents inform external entities (dApps, explorers, users) about significant runtime changes. Event details are included in the node's metadata, making them accessible to external tools.\n\nThe [`#[pallet::generate_deposit]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.generate_deposit.html){target=\\_blank} macro automatically generates a `deposit_event` function that converts your pallet's events into the `RuntimeEvent` type and deposits them via [`frame_system::Pallet::deposit_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.deposit_event){target=\\_blank}.\n\nAdd the [`#[pallet::event]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.event.html){target=\\_blank} section after the `Config` trait:\n\n```rust title=\"src/lib.rs\"\n#[pallet::event]\n#[pallet::generate_deposit(pub(super) fn deposit_event)]\npub enum Event {\n /// Counter value was explicitly set. [new_value]\n CounterValueSet { \n new_value: u32 \n },\n /// Counter was incremented. [new_value, who, amount]\n CounterIncremented {\n new_value: u32,\n who: T::AccountId,\n amount: u32,\n },\n /// Counter was decremented. [new_value, who, amount]\n CounterDecremented {\n new_value: u32,\n who: T::AccountId,\n amount: u32,\n },\n}\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 8, "depth": 2, "title": "Define Errors", "anchor": "define-errors", "start_char": 8742, "end_char": 9646, "estimated_token_count": 221, "token_estimator": "heuristic-v1", "text": "## Define Errors\n\nErrors indicate when and why a call fails. Use informative names and descriptions, as error documentation is included in the node's metadata.\n\nError types must implement the [`TypeInfo`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_prelude/trait.TypeInfo.html){target=\\_blank} trait, and runtime errors can be up to 4 bytes in size.\n\nAdd the [`#[pallet::error]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.error.html){target=\\_blank} section after the events:\n\n```rust title=\"src/lib.rs\"\n#[pallet::error]\npub enum Error {\n /// The counter value has not been set yet.\n NoneValue,\n /// Arithmetic operation would cause overflow.\n Overflow,\n /// Arithmetic operation would cause underflow.\n Underflow,\n /// The counter value would exceed the maximum allowed value.\n CounterMaxValueExceeded,\n}\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 9, "depth": 2, "title": "Add Storage Items", "anchor": "add-storage-items", "start_char": 9646, "end_char": 10760, "estimated_token_count": 283, "token_estimator": "heuristic-v1", "text": "## Add Storage Items\n\nStorage items persist state on-chain. This pallet uses two storage items:\n\n- **`CounterValue`**: Stores the current counter value.\n- **`UserInteractions`**: Tracks interaction counts per user account.\n\nThe initial scaffold already includes the `CounterValue` storage item. Now add the `UserInteractions` storage map after it:\n\n```rust title=\"src/lib.rs\"\n/// Tracks the number of interactions per user.\n#[pallet::storage]\npub type UserInteractions = StorageMap<_, Blake2_128Concat, T::AccountId, u32, ValueQuery>;\n```\n\nYour storage section should now look like this:\n\n```rust title=\"src/lib.rs\"\n/// The current value of the counter.\n#[pallet::storage]\npub type CounterValue = StorageValue<_, u32, ValueQuery>;\n\n/// Tracks the number of interactions per user.\n#[pallet::storage]\npub type UserInteractions = StorageMap<_, Blake2_128Concat, T::AccountId, u32, ValueQuery>;\n```\n\nFor more storage types and patterns, explore the [Polkadot SDK storage documentation](https://paritytech.github.io/polkadot-sdk/master/frame_support/storage/types/index.html){target=\\_blank}."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 10, "depth": 2, "title": "Configure Genesis State", "anchor": "configure-genesis-state", "start_char": 10760, "end_char": 12601, "estimated_token_count": 422, "token_estimator": "heuristic-v1", "text": "## Configure Genesis State\n\nGenesis configuration allows you to set the initial state of your pallet when the blockchain first starts. This is essential for both production networks and testing environments. It is particularly useful for:\n\n- Setting initial parameter values.\n- Pre-allocating resources or accounts.\n- Establishing starting conditions for testing.\n- Configuring network-specific initial state.\n\nAdd the [`#[pallet::genesis_config]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.genesis_config.html){target=\\_blank} and [`#[pallet::genesis_build]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.genesis_build.html){target=\\_blank} sections after your storage items:\n\n```rust title=\"src/lib.rs\"\n#[pallet::genesis_config]\n#[derive(frame_support::DefaultNoBound)]\npub struct GenesisConfig {\n /// Initial value for the counter\n pub initial_counter_value: u32,\n /// Pre-populated user interactions\n pub initial_user_interactions: Vec<(T::AccountId, u32)>,\n}\n\n#[pallet::genesis_build]\nimpl BuildGenesisConfig for GenesisConfig {\n fn build(&self) {\n // Set the initial counter value\n CounterValue::::put(self.initial_counter_value);\n \n // Set initial user interactions\n for (account, count) in &self.initial_user_interactions {\n UserInteractions::::insert(account, count);\n }\n }\n}\n```\n\n**Genesis configuration components:**\n\n- **`GenesisConfig` struct**: Defines what can be configured at genesis.\n- **`#[derive(DefaultNoBound)]`**: Provides sensible defaults (empty vec and 0 for the counter).\n- **`BuildGenesisConfig` implementation**: Executes the logic to set initial storage values.\n- **`build()` method**: Called once when the blockchain initializes."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 11, "depth": 2, "title": "Implement Dispatchable Functions", "anchor": "implement-dispatchable-functions", "start_char": 12601, "end_char": 16013, "estimated_token_count": 753, "token_estimator": "heuristic-v1", "text": "## Implement Dispatchable Functions\n\nDispatchable functions (extrinsics) allow users to interact with your pallet and trigger state changes. Each function must:\n\n- Return a [`DispatchResult`](https://paritytech.github.io/polkadot-sdk/master/frame_support/dispatch/type.DispatchResult.html){target=\\_blank}.\n- Be annotated with a weight (computational cost).\n- Have an explicit call index for backward compatibility.\n\nReplace the [`#[pallet::call]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.call.html){target=\\_blank} section with:\n\n```rust title=\"src/lib.rs\"\n#[pallet::call]\nimpl Pallet {\n /// Set the counter to a specific value. Root origin only.\n #[pallet::call_index(0)]\n #[pallet::weight(0)]\n pub fn set_counter_value(origin: OriginFor, new_value: u32) -> DispatchResult {\n // Ensure the caller is root\n ensure_root(origin)?;\n \n // Validate the new value doesn't exceed the maximum\n ensure!(\n new_value <= T::CounterMaxValue::get(),\n Error::::CounterMaxValueExceeded\n );\n \n // Update storage\n CounterValue::::put(new_value);\n \n // Emit event\n Self::deposit_event(Event::CounterValueSet { new_value });\n \n Ok(())\n }\n\n /// Increment the counter by a specified amount.\n #[pallet::call_index(1)]\n #[pallet::weight(0)]\n pub fn increment(origin: OriginFor, amount: u32) -> DispatchResult {\n // Ensure the caller is signed\n let who = ensure_signed(origin)?;\n \n // Get current counter value\n let current_value = CounterValue::::get();\n \n // Check for overflow\n let new_value = current_value\n .checked_add(amount)\n .ok_or(Error::::Overflow)?;\n \n // Ensure new value doesn't exceed maximum\n ensure!(\n new_value <= T::CounterMaxValue::get(),\n Error::::CounterMaxValueExceeded\n );\n \n // Update counter storage\n CounterValue::::put(new_value);\n \n // Track user interaction\n UserInteractions::::mutate(&who, |count| {\n *count = count.saturating_add(1);\n });\n \n // Emit event\n Self::deposit_event(Event::CounterIncremented {\n new_value,\n who,\n amount,\n });\n \n Ok(())\n }\n\n /// Decrement the counter by a specified amount.\n #[pallet::call_index(2)]\n #[pallet::weight(0)]\n pub fn decrement(origin: OriginFor, amount: u32) -> DispatchResult {\n // Ensure the caller is signed\n let who = ensure_signed(origin)?;\n \n // Get current counter value\n let current_value = CounterValue::::get();\n \n // Check for underflow\n let new_value = current_value\n .checked_sub(amount)\n .ok_or(Error::::Underflow)?;\n \n // Update counter storage\n CounterValue::::put(new_value);\n \n // Track user interaction\n UserInteractions::::mutate(&who, |count| {\n *count = count.saturating_add(1);\n });\n \n // Emit event\n Self::deposit_event(Event::CounterDecremented {\n new_value,\n who,\n amount,\n });\n \n Ok(())\n }\n}\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 12, "depth": 3, "title": "Dispatchable Function Details", "anchor": "dispatchable-function-details", "start_char": 16013, "end_char": 16952, "estimated_token_count": 222, "token_estimator": "heuristic-v1", "text": "### Dispatchable Function Details\n\n???+ interface \"`set_counter_value`\"\n\n - **Access**: Root origin only (privileged operations)\n - **Purpose**: Set counter to a specific value\n - **Validations**: New value must not exceed `CounterMaxValue`\n - **State changes**: Updates `CounterValue` storage\n - **Events**: Emits `CounterValueSet`\n\n??? interface \"`increment`\"\n\n - **Access**: Any signed account\n - **Purpose**: Increase counter by specified amount\n - **Validations**: Checks for overflow and max value compliance\n - **State changes**: Updates `CounterValue` and `UserInteractions`\n - **Events**: Emits `CounterIncremented`\n\n??? interface \"`decrement`\"\n\n - **Access**: Any signed account\n - **Purpose**: Decrease counter by specified amount\n - **Validations**: Checks for underflow\n - **State changes**: Updates `CounterValue` and `UserInteractions`\n - **Events**: Emits `CounterDecremented`"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 13, "depth": 2, "title": "Verify Pallet Compilation", "anchor": "verify-pallet-compilation", "start_char": 16952, "end_char": 21135, "estimated_token_count": 927, "token_estimator": "heuristic-v1", "text": "## Verify Pallet Compilation\n\nBefore proceeding, ensure your pallet compiles without errors:\n\n```bash\ncargo build --package pallet-custom\n```\n\nIf you encounter errors, carefully review the code against this guide. Once the build completes successfully, your custom pallet is ready for integration.\n\n??? code \"Complete Pallet Implementation\"\n \n ```rust title=\"src/lib.rs\"\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[frame::pallet]\n pub mod pallet {\n use frame::prelude::*;\n\n #[pallet::pallet]\n pub struct Pallet(_);\n\n #[pallet::config]\n pub trait Config: frame_system::Config {\n type RuntimeEvent: From> + IsType<::RuntimeEvent>;\n \n #[pallet::constant]\n type CounterMaxValue: Get;\n }\n\n #[pallet::event]\n #[pallet::generate_deposit(pub(super) fn deposit_event)]\n pub enum Event {\n CounterValueSet { new_value: u32 },\n CounterIncremented { new_value: u32, who: T::AccountId, amount: u32 },\n CounterDecremented { new_value: u32, who: T::AccountId, amount: u32 },\n }\n\n #[pallet::error]\n pub enum Error {\n NoneValue,\n Overflow,\n Underflow,\n CounterMaxValueExceeded,\n }\n\n #[pallet::storage]\n pub type CounterValue = StorageValue<_, u32, ValueQuery>;\n\n #[pallet::storage]\n pub type UserInteractions = StorageMap<_, Blake2_128Concat, T::AccountId, u32, ValueQuery>;\n\n #[pallet::genesis_config]\n #[derive(frame_support::DefaultNoBound)]\n pub struct GenesisConfig {\n pub initial_counter_value: u32,\n pub initial_user_interactions: Vec<(T::AccountId, u32)>,\n }\n\n #[pallet::genesis_build]\n impl BuildGenesisConfig for GenesisConfig {\n fn build(&self) {\n CounterValue::::put(self.initial_counter_value);\n for (account, count) in &self.initial_user_interactions {\n UserInteractions::::insert(account, count);\n }\n }\n }\n\n #[pallet::call]\n impl Pallet {\n #[pallet::call_index(0)]\n #[pallet::weight(0)]\n pub fn set_counter_value(origin: OriginFor, new_value: u32) -> DispatchResult {\n ensure_root(origin)?;\n ensure!(new_value <= T::CounterMaxValue::get(), Error::::CounterMaxValueExceeded);\n CounterValue::::put(new_value);\n Self::deposit_event(Event::CounterValueSet { new_value });\n Ok(())\n }\n\n #[pallet::call_index(1)]\n #[pallet::weight(0)]\n pub fn increment(origin: OriginFor, amount: u32) -> DispatchResult {\n let who = ensure_signed(origin)?;\n let current_value = CounterValue::::get();\n let new_value = current_value.checked_add(amount).ok_or(Error::::Overflow)?;\n ensure!(new_value <= T::CounterMaxValue::get(), Error::::CounterMaxValueExceeded);\n CounterValue::::put(new_value);\n UserInteractions::::mutate(&who, |count| *count = count.saturating_add(1));\n Self::deposit_event(Event::CounterIncremented { new_value, who, amount });\n Ok(())\n }\n\n #[pallet::call_index(2)]\n #[pallet::weight(0)]\n pub fn decrement(origin: OriginFor, amount: u32) -> DispatchResult {\n let who = ensure_signed(origin)?;\n let current_value = CounterValue::::get();\n let new_value = current_value.checked_sub(amount).ok_or(Error::::Underflow)?;\n CounterValue::::put(new_value);\n UserInteractions::::mutate(&who, |count| *count = count.saturating_add(1));\n Self::deposit_event(Event::CounterDecremented { new_value, who, amount });\n Ok(())\n }\n }\n }\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 14, "depth": 2, "title": "Add the Pallet to Your Runtime", "anchor": "add-the-pallet-to-your-runtime", "start_char": 21135, "end_char": 21253, "estimated_token_count": 23, "token_estimator": "heuristic-v1", "text": "## Add the Pallet to Your Runtime\n\nNow that your custom pallet is complete, integrate it into the parachain runtime."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 15, "depth": 3, "title": "Add Runtime Dependency", "anchor": "add-runtime-dependency", "start_char": 21253, "end_char": 21833, "estimated_token_count": 153, "token_estimator": "heuristic-v1", "text": "### Add Runtime Dependency\n\n1. In the `runtime/Cargo.toml`, add your custom pallet to the `[dependencies]` section:\n\n ```toml title=\"runtime/Cargo.toml\"\n [dependencies]\n # Local dependencies\n pallet-custom = { path = \"../pallets/pallet-custom\", default-features = false }\n \n # ... other dependencies\n ```\n\n2. Enable the `std` feature by adding it to the `[features]` section:\n\n ```toml title=\"runtime/Cargo.toml\"\n [features]\n default = [\"std\"]\n std = [\n \"codec/std\",\n \"pallet-custom/std\",\n # ... other features\n ]\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 16, "depth": 3, "title": "Implement the Config Trait", "anchor": "implement-the-config-trait", "start_char": 21833, "end_char": 22402, "estimated_token_count": 143, "token_estimator": "heuristic-v1", "text": "### Implement the Config Trait\n\nAt the end of the `runtime/src/configs/mod.rs` file, add the implementation: \n\n```rust title=\"runtime/src/configs/mod.rs\"\n/// Configure the custom counter pallet\nimpl pallet_custom::Config for Runtime {\n type RuntimeEvent = RuntimeEvent;\n type CounterMaxValue = ConstU32<1000>;\n}\n```\n\nThis configuration:\n\n- Links the pallet's events to the runtime's event system\n- Sets a maximum counter value of 1000 using [`ConstU32`](https://paritytech.github.io/polkadot-sdk/master/frame_support/traits/struct.ConstU32.html){target=\\_blank}"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 17, "depth": 3, "title": "Add to Runtime Construct", "anchor": "add-to-runtime-construct", "start_char": 22402, "end_char": 23404, "estimated_token_count": 214, "token_estimator": "heuristic-v1", "text": "### Add to Runtime Construct\n\nIn the `runtime/src/lib.rs` file, locate the [`#[frame_support::runtime]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/attr.runtime.html){target=\\_blank} section and add your pallet with a unique `pallet_index`:\n\n```rust title=\"runtime/src/lib.rs\"\n#[frame_support::runtime]\nmod runtime {\n #[runtime::runtime]\n #[runtime::derive(\n RuntimeCall,\n RuntimeEvent,\n RuntimeError,\n RuntimeOrigin,\n RuntimeTask,\n RuntimeFreezeReason,\n RuntimeHoldReason,\n RuntimeSlashReason,\n RuntimeLockId,\n RuntimeViewFunction\n )]\n pub struct Runtime;\n\n #[runtime::pallet_index(0)]\n pub type System = frame_system;\n\n // ... other pallets\n\n #[runtime::pallet_index(51)]\n pub type CustomPallet = pallet_custom;\n}\n```\n\n!!!warning\n Each pallet must have a unique index. Duplicate indices will cause compilation errors. Choose an index that doesn't conflict with existing pallets."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 18, "depth": 3, "title": "Configure Genesis for Your Runtime", "anchor": "configure-genesis-for-your-runtime", "start_char": 23404, "end_char": 23885, "estimated_token_count": 99, "token_estimator": "heuristic-v1", "text": "### Configure Genesis for Your Runtime\n\nTo set initial values for your pallet when the chain starts, you'll need to configure the genesis in your chain specification. This is typically done in the `node/src/chain_spec.rs` file or when generating the chain specification.\n\nFor development and testing, you can use the default values provided by the `#[derive(DefaultNoBound)]` macro. For production networks, you'll want to set these values in your chain specification explicitly."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 19, "depth": 3, "title": "Verify Runtime Compilation", "anchor": "verify-runtime-compilation", "start_char": 23885, "end_char": 24108, "estimated_token_count": 41, "token_estimator": "heuristic-v1", "text": "### Verify Runtime Compilation\n\nCompile the runtime to ensure everything is configured correctly:\n\n```bash\ncargo build --release\n```\n\nThis command validates all pallet configurations and prepares the build for deployment."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 20, "depth": 2, "title": "Run Your Chain Locally", "anchor": "run-your-chain-locally", "start_char": 24108, "end_char": 24296, "estimated_token_count": 47, "token_estimator": "heuristic-v1", "text": "## Run Your Chain Locally\n\nLaunch your parachain locally to test the new pallet functionality using the [Polkadot Omni Node](https://crates.io/crates/polkadot-omni-node){target=\\_blank}."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 21, "depth": 3, "title": "Generate a Chain Specification", "anchor": "generate-a-chain-specification", "start_char": 24296, "end_char": 24705, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "### Generate a Chain Specification\n\nCreate a chain specification file with the updated runtime:\n\n```bash\nchain-spec-builder create -t development \\\n--relay-chain paseo \\\n--para-id 1000 \\\n--runtime ./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm \\\nnamed-preset development\n```\n\nThis command generates a `chain_spec.json` that includes your custom pallet."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 22, "depth": 3, "title": "Start the Parachain Node", "anchor": "start-the-parachain-node", "start_char": 24705, "end_char": 24888, "estimated_token_count": 44, "token_estimator": "heuristic-v1", "text": "### Start the Parachain Node\n\nLaunch the parachain:\n\n```bash\npolkadot-omni-node --chain ./chain_spec.json --dev\n```\n\nVerify the node starts successfully and begins producing blocks."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 23, "depth": 2, "title": "Interact with Your Pallet", "anchor": "interact-with-your-pallet", "start_char": 24888, "end_char": 25660, "estimated_token_count": 234, "token_estimator": "heuristic-v1", "text": "## Interact with Your Pallet\n\nUse the Polkadot.js Apps interface to test your pallet:\n\n1. Navigate to [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/extrinsics){target=\\_blank}.\n\n2. Ensure you're connected to your local node at `ws://127.0.0.1:9944`.\n\n3. Go to **Developer** > **Extrinsics**.\n\n4. Locate **customPallet** in the pallet dropdown.\n\n5. You should see the available extrinsics:\n\n - **`increment(amount)`**: Increase the counter by a specified amount.\n - **`decrement(amount)`**: Decrease the counter by a specified amount.\n - **`setCounterValue(newValue)`**: Set counter to a specific value (requires sudo/root).\n\n![](/images/parachains/customize-runtime/pallet-development/create-a-pallet/create-a-pallet-01.webp)"} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 24, "depth": 2, "title": "Key Takeaways", "anchor": "key-takeaways", "start_char": 25660, "end_char": 26487, "estimated_token_count": 170, "token_estimator": "heuristic-v1", "text": "## Key Takeaways\n\nYou've successfully created and integrated a custom pallet into a Polkadot SDK-based runtime. You learned:\n\n- **Configuration**: Defined runtime-specific types and constants via the `Config` trait.\n- **Storage**: Implemented on-chain state using `StorageValue` and `StorageMap`.\n- **Events**: Created signals to communicate state changes to external systems.\n- **Errors**: Established clear error handling with descriptive error types.\n- **Genesis**: Configured initial blockchain state for both production and testing.\n- **Dispatchables**: Built callable functions with proper validation and access control.\n- **Integration**: Successfully added the pallet to a runtime and tested it locally.\n\nThese components form the foundation for developing sophisticated blockchain logic in Polkadot SDK-based chains."} -{"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Make a Custom Pallet", "index": 25, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 26487, "end_char": 26836, "estimated_token_count": 86, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Mock Your Runtime__\n\n ---\n\n Learn to create a mock runtime environment for testing your pallet in isolation before integration.\n\n [:octicons-arrow-right-24: Continue](/parachains/customize-runtime/pallet-development/mock-runtime/)\n\n
"} -{"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 16, "end_char": 474, "estimated_token_count": 78, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nTesting is essential in Polkadot SDK development to ensure your blockchain operates as intended and effectively handles various potential scenarios. This guide walks you through setting up an environment to test pallets within the [runtime](/polkadot-protocol/glossary#runtime){target=_blank}, allowing you to evaluate how different pallets, their configurations, and system components interact to ensure reliable blockchain functionality."} -{"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 1, "depth": 2, "title": "Configuring a Mock Runtime", "anchor": "configuring-a-mock-runtime", "start_char": 474, "end_char": 505, "estimated_token_count": 6, "token_estimator": "heuristic-v1", "text": "## Configuring a Mock Runtime"} -{"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 2, "depth": 3, "title": "Testing Module", "anchor": "testing-module", "start_char": 505, "end_char": 2264, "estimated_token_count": 348, "token_estimator": "heuristic-v1", "text": "### Testing Module\n\nThe mock runtime includes all the necessary pallets and configurations needed for testing. To ensure proper testing, you must create a module that integrates all components, enabling assessment of interactions between pallets and system elements.\n\nHere's a simple example of how to create a testing module that simulates these interactions:\n\n```rust\npub mod tests {\n use crate::*;\n // ...\n}\n```\n\nThe `crate::*;` snippet imports all the components from your crate (including runtime configurations, pallet modules, and utility functions) into the `tests` module. This allows you to write tests without manually importing each piece, making the code more concise and readable. You can opt to instead create a separate `mock.rs` file to define the configuration for your mock runtime and a companion `tests.rs` file to house the specific logic for each test.\n\nOnce the testing module is configured, you can craft your mock runtime using the [`frame_support::runtime`](https://paritytech.github.io/polkadot-sdk/master/frame_support/attr.runtime.html){target=\\_blank} macro. This macro allows you to define a runtime environment that will be created for testing purposes:\n\n```rust\npub mod tests {\n use crate::*;\n\n #[frame_support::runtime]\n mod runtime {\n #[runtime::runtime]\n #[runtime::derive(\n RuntimeCall,\n RuntimeEvent,\n RuntimeError,\n RuntimeOrigin,\n RuntimeFreezeReason,\n RuntimeHoldReason,\n RuntimeSlashReason,\n RuntimeLockId,\n RuntimeTask\n )]\n pub struct Test;\n\n #[runtime::pallet_index(0)]\n pub type System = frame_system::Pallet;\n\n // Other pallets...\n }\n}\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 3, "depth": 3, "title": "Genesis Storage", "anchor": "genesis-storage", "start_char": 2264, "end_char": 5778, "estimated_token_count": 767, "token_estimator": "heuristic-v1", "text": "### Genesis Storage\n\nThe next step is configuring the genesis storage—the initial state of your runtime. Genesis storage sets the starting conditions for the runtime, defining how pallets are configured before any blocks are produced. You can only customize the initial state only of those items that implement the [`[pallet::genesis_config]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.genesis_config.html){target=\\_blank} and [`[pallet::genesis_build]`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.genesis_build.html){target=\\_blank} macros within their respective pallets.\n\nIn Polkadot SDK, you can create this storage using the [`BuildStorage`](https://paritytech.github.io/polkadot-sdk/master/sp_runtime/trait.BuildStorage.html){target=\\_blank} trait from the [`sp_runtime`](https://paritytech.github.io/polkadot-sdk/master/sp_runtime){target=\\_blank} crate. This trait is essential for building the configuration that initializes the blockchain's state. \n\nThe function `new_test_ext()` demonstrates setting up this environment. It uses `frame_system::GenesisConfig::::default()` to generate a default genesis configuration for the runtime, followed by `.build_storage()` to create the initial storage state. This storage is then converted into a format usable by the testing framework, [`sp_io::TestExternalities`](https://paritytech.github.io/polkadot-sdk/master/sp_io/type.TestExternalities.html){target=\\_blank}, allowing tests to be executed in a simulated blockchain environment.\n\nHere's the code that sets the genesis storage configuration:\n\n```rust\npub mod tests {\n use crate::*;\n use sp_runtime::BuildStorage;\n\n #[frame_support::runtime]\n mod runtime {\n #[runtime::runtime]\n #[runtime::derive(\n RuntimeCall,\n RuntimeEvent,\n RuntimeError,\n RuntimeOrigin,\n RuntimeFreezeReason,\n RuntimeHoldReason,\n RuntimeSlashReason,\n RuntimeLockId,\n RuntimeTask\n )]\n pub struct Test;\n\n #[runtime::pallet_index(0)]\n pub type System = frame_system::Pallet;\n\n // Other pallets...\n }\n\n pub fn new_test_ext() -> sp_io::TestExternalities {\n frame_system::GenesisConfig::::default()\n .build_storage()\n .unwrap()\n .into()\n }\n}\n```\n\nYou can also customize the genesis storage to set initial values for your runtime pallets. For example, you can set the initial balance for accounts like this:\n\n```rust\n// Build genesis storage according to the runtime's configuration\npub fn new_test_ext() -> sp_io::TestExternalities {\n // Define the initial balances for accounts\n let initial_balances: Vec<(AccountId32, u128)> = vec![\n (AccountId32::from([0u8; 32]), 1_000_000_000_000),\n (AccountId32::from([1u8; 32]), 2_000_000_000_000),\n ];\n\n let mut t = frame_system::GenesisConfig::::default()\n .build_storage()\n .unwrap();\n\n // Adding balances configuration to the genesis config\n pallet_balances::GenesisConfig:: {\n balances: initial_balances,\n }\n .assimilate_storage(&mut t)\n .unwrap();\n\n t.into()\n}\n```\n\nFor a more idiomatic approach, see the [Your First Pallet](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#better-test-setup){target=\\_blank} guide from the Polkadot SDK Rust documentation."} -{"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 4, "depth": 3, "title": "Pallet Configuration", "anchor": "pallet-configuration", "start_char": 5778, "end_char": 6780, "estimated_token_count": 207, "token_estimator": "heuristic-v1", "text": "### Pallet Configuration\n\nEach pallet in the mocked runtime requires an associated configuration, specifying the types and values it depends on to function. These configurations often use basic or primitive types (e.g., u32, bool) instead of more complex types like structs or traits, ensuring the setup remains straightforward and manageable.\n\n```rust\n#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]\nimpl frame_system::Config for Test {\n ...\n type Index = u64;\n type BlockNumber = u64;\n type Hash = H256;\n type Hashing = BlakeTwo256;\n type AccountId = u64;\n ...\n}\n\nimpl pallet_template::Config for Test {\n\ttype RuntimeEvent = RuntimeEvent;\n\ttype WeightInfo = ();\n ...\n}\n```\n\nThe configuration should be set for each pallet existing in the mocked runtime. The simplification of types is for simplifying the testing process. For example, `AccountId` is `u64`, meaning a valid account address can be an unsigned integer:\n\n```rust\nlet alice_account: u64 = 1;\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Runtime for Pallet Testing", "index": 5, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6780, "end_char": 7514, "estimated_token_count": 170, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nWith the mock environment in place, developers can now test and explore how pallets interact and ensure they work seamlessly together. For further details about mocking runtimes, see the following [Polkadot SDK docs guide](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#your-first-test-runtime){target=\\_blank}.\n\n
\n\n- Guide __Pallet Testing__\n\n ---\n\n Learn how to efficiently test pallets in the Polkadot SDK, ensuring your pallet operations are reliable and secure.\n\n [:octicons-arrow-right-24: Reference](/parachains/customize-runtime/pallet-development/pallet-testing/)\n\n
"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 23, "end_char": 614, "estimated_token_count": 104, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nUnit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation.\n\nIn this guide, you'll learn how to:\n\n- Structure test modules effectively\n- Test dispatchable functions\n- Verify storage changes\n- Check event emission\n- Test error conditions\n- Use genesis configurations in tests"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 614, "end_char": 1069, "estimated_token_count": 119, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have:\n\n- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide\n- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide\n- The custom counter pallet with mock runtime in `pallets/pallet-custom`\n- Basic understanding of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\\_blank}"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 2, "depth": 2, "title": "Understanding FRAME Testing Tools", "anchor": "understanding-frame-testing-tools", "start_char": 1069, "end_char": 1205, "estimated_token_count": 20, "token_estimator": "heuristic-v1", "text": "## Understanding FRAME Testing Tools\n\nFRAME provides specialized testing macros and utilities that make pallet testing more efficient:"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 3, "depth": 3, "title": "Assertion Macros", "anchor": "assertion-macros", "start_char": 1205, "end_char": 1880, "estimated_token_count": 174, "token_estimator": "heuristic-v1", "text": "### Assertion Macros\n\n- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\\_blank}** - Asserts that a dispatchable call succeeds.\n- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\\_blank}** - Asserts that a call fails without changing state (no operation).\n- **`assert_eq!`** - Standard Rust equality assertion.\n\n!!!info \"`assert_noop!` Explained\"\n Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 4, "depth": 3, "title": "System Pallet Test Helpers", "anchor": "system-pallet-test-helpers", "start_char": 1880, "end_char": 2876, "estimated_token_count": 279, "token_estimator": "heuristic-v1", "text": "### System Pallet Test Helpers\n\nThe [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\\_blank} pallet provides useful methods for testing:\n\n- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\\_blank}** - Returns all events emitted during the test.\n- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\\_blank}** - Asserts the last event matches expectations.\n- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\\_blank}** - Sets the current block number.\n\n!!!info \"Events and Block Number\"\n Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 5, "depth": 3, "title": "Origin Types", "anchor": "origin-types", "start_char": 2876, "end_char": 3667, "estimated_token_count": 230, "token_estimator": "heuristic-v1", "text": "### Origin Types\n\n- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\\_blank}** - Root/sudo origin for privileged operations.\n- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\\_blank}** - Signed origin from a specific account.\n- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\\_blank}** - No origin (typically fails for most operations).\n\nLearn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\\_blank}."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 6, "depth": 2, "title": "Create the Tests Module", "anchor": "create-the-tests-module", "start_char": 3667, "end_char": 4274, "estimated_token_count": 166, "token_estimator": "heuristic-v1", "text": "## Create the Tests Module\n\nCreate a new file for your tests within the pallet directory:\n\n1. Navigate to your pallet directory:\n\n ```bash\n cd pallets/pallet-custom/src\n ```\n\n2. Create a new file named `tests.rs`:\n\n ```bash\n touch tests.rs\n ```\n\n3. Open `src/lib.rs` and add the tests module declaration after the mock module:\n\n ```rust title=\"src/lib.rs\"\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n\n #[frame::pallet]\n pub mod pallet {\n // ... existing pallet code\n }\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 7, "depth": 2, "title": "Set Up the Test Module", "anchor": "set-up-the-test-module", "start_char": 4274, "end_char": 4883, "estimated_token_count": 160, "token_estimator": "heuristic-v1", "text": "## Set Up the Test Module\n\nOpen `src/tests.rs` and add the basic structure with necessary imports:\n\n```rust\nuse crate::{mock::*, Error, Event};\nuse frame::deps::frame_support::{assert_noop, assert_ok};\nuse frame::deps::sp_runtime::DispatchError;\n```\n\nThis setup imports:\n\n- The mock runtime and test utilities from `mock.rs`\n- Your pallet's `Error` and `Event` types\n- FRAME's assertion macros via `frame::deps`\n- `DispatchError` for testing origin checks\n\n???+ code \"Complete Pallet Code Reference\"\n Here's the complete pallet code that you'll be testing throughout this guide:\n\n ```rust\n \n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 8, "depth": 2, "title": "Write Your First Test", "anchor": "write-your-first-test", "start_char": 4883, "end_char": 4991, "estimated_token_count": 22, "token_estimator": "heuristic-v1", "text": "## Write Your First Test\n\nLet's start with a simple test to verify the increment function works correctly."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 9, "depth": 3, "title": "Test Basic Increment", "anchor": "test-basic-increment", "start_char": 4991, "end_char": 6071, "estimated_token_count": 239, "token_estimator": "heuristic-v1", "text": "### Test Basic Increment\n\nTest that the increment function increases counter value and emits events.\n\n```rust\n#[test]\nfn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n}\n```\n\nRun your first test:\n\n```bash\ncargo test --package pallet-custom increment_works\n```\n\nYou should see:\n\n```\nrunning 1 test\ntest tests::increment_works ... ok\n```\n\n🎉 Congratulations! You've written and run your first pallet test."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 10, "depth": 2, "title": "Test Error Conditions", "anchor": "test-error-conditions", "start_char": 6071, "end_char": 6216, "estimated_token_count": 28, "token_estimator": "heuristic-v1", "text": "## Test Error Conditions\n\nNow let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 11, "depth": 3, "title": "Test Overflow Protection", "anchor": "test-overflow-protection", "start_char": 6216, "end_char": 6731, "estimated_token_count": 113, "token_estimator": "heuristic-v1", "text": "### Test Overflow Protection\n\nTest that incrementing at u32::MAX fails with Overflow error.\n\n```rust\n#[test]\nfn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n}\n```\n\nTest overflow protection:\n\n```bash\ncargo test --package pallet-custom increment_fails_on_overflow\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 12, "depth": 3, "title": "Test Underflow Protection", "anchor": "test-underflow-protection", "start_char": 6731, "end_char": 7243, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "### Test Underflow Protection\n\nTest that decrementing below zero fails with Underflow error.\n\n```rust\n#[test]\nfn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n}\n```\n\nVerify underflow protection:\n\n```bash\ncargo test --package pallet-custom decrement_fails_on_underflow\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 13, "depth": 2, "title": "Test Access Control", "anchor": "test-access-control", "start_char": 7243, "end_char": 7347, "estimated_token_count": 17, "token_estimator": "heuristic-v1", "text": "## Test Access Control\n\nVerify that origin checks work correctly and unauthorized access is prevented."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 14, "depth": 3, "title": "Test Root-Only Access", "anchor": "test-root-only-access", "start_char": 7347, "end_char": 8112, "estimated_token_count": 164, "token_estimator": "heuristic-v1", "text": "### Test Root-Only Access\n\nTest that set_counter_value requires root origin and rejects signed origins.\n\n```rust\n#[test]\nfn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n\n // When: non-root user tries to set counter\n // Then: should fail with BadOrigin\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n DispatchError::BadOrigin\n );\n\n // But root should succeed\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n}\n```\n\nTest access control:\n\n```bash\ncargo test --package pallet-custom set_counter_value_requires_root\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 15, "depth": 2, "title": "Test Event Emission", "anchor": "test-event-emission", "start_char": 8112, "end_char": 8199, "estimated_token_count": 16, "token_estimator": "heuristic-v1", "text": "## Test Event Emission\n\nVerify that events are emitted correctly with the right data."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 16, "depth": 3, "title": "Test Event Data", "anchor": "test-event-data", "start_char": 8199, "end_char": 9286, "estimated_token_count": 236, "token_estimator": "heuristic-v1", "text": "### Test Event Data\n\nThe `increment_works` test (shown earlier) already demonstrates event testing by:\n1. Setting the block number to 1 to enable event emission\n2. Calling the dispatchable function\n3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data\n\nThis pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function:\n\nTest that set_counter_value updates storage and emits correct event.\n\n```rust\n#[test]\nfn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n}\n```\n\nRun the event test:\n\n```bash\ncargo test --package pallet-custom set_counter_value_works\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 17, "depth": 2, "title": "Test Genesis Configuration", "anchor": "test-genesis-configuration", "start_char": 9286, "end_char": 9369, "estimated_token_count": 12, "token_estimator": "heuristic-v1", "text": "## Test Genesis Configuration\n\nVerify that genesis configuration works correctly."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 18, "depth": 3, "title": "Test Genesis Setup", "anchor": "test-genesis-setup", "start_char": 9369, "end_char": 9988, "estimated_token_count": 160, "token_estimator": "heuristic-v1", "text": "### Test Genesis Setup\n\nTest that genesis configuration correctly initializes counter and user interactions.\n\n```rust\n#[test]\nfn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n}\n```\n\nTest genesis configuration:\n\n```bash\ncargo test --package pallet-custom genesis_config_works\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 19, "depth": 2, "title": "Run All Tests", "anchor": "run-all-tests", "start_char": 9988, "end_char": 19815, "estimated_token_count": 2039, "token_estimator": "heuristic-v1", "text": "## Run All Tests\n\nNow run all your tests together:\n\n```bash\ncargo test --package pallet-custom\n```\n\nYou should see all tests passing:\n\n```\nrunning 15 tests\ntest mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok\ntest mock::test_genesis_config_builds ... ok\ntest tests::decrement_fails_on_underflow ... ok\ntest tests::decrement_tracks_multiple_interactions ... ok\ntest tests::decrement_works ... ok\ntest tests::different_users_tracked_separately ... ok\ntest tests::genesis_config_works ... ok\ntest tests::increment_fails_on_overflow ... ok\ntest tests::increment_respects_max_value ... ok\ntest tests::increment_tracks_multiple_interactions ... ok\ntest tests::increment_works ... ok\ntest tests::mixed_increment_and_decrement_works ... ok\ntest tests::set_counter_value_requires_root ... ok\ntest tests::set_counter_value_respects_max_value ... ok\ntest tests::set_counter_value_works ... ok\n\ntest result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out\n```\n\n!!!note \"Mock Runtime Tests\"\n You'll notice 2 additional tests from the `mock` module:\n\n - `mock::__construct_runtime_integrity_test::runtime_integrity_tests` - Auto-generated test that validates runtime construction\n - `mock::test_genesis_config_builds` - Validates that genesis configuration builds correctly\n\n These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid.\n\n🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns!\n\nThese tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality.\n\n??? code \"Full Test Suite Code\"\n Here's the complete `tests.rs` file for quick reference:\n\n ```rust\n use crate::{mock::*, Error, Event};\n use frame::deps::frame_support::{assert_noop, assert_ok};\n use frame::deps::sp_runtime::DispatchError;\n\n #[test]\n fn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n }\n\n #[test]\n fn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter with non-root origin should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(1), 100),\n DispatchError::BadOrigin\n );\n });\n }\n\n #[test]\n fn set_counter_value_respects_max_value() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter above max value (1000) should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::root(), 1001),\n Error::::CounterMaxValueExceeded\n );\n\n // Setting to exactly max value should work\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 1000));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn increment_tracks_multiple_interactions() {\n new_test_ext().execute_with(|| {\n let account = 1u64;\n\n // Increment multiple times\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 20));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 30));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 60);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n }\n\n #[test]\n fn increment_respects_max_value() {\n new_test_ext_with_counter(950).execute_with(|| {\n // Incrementing past max value (1000) should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 51),\n Error::::CounterMaxValueExceeded\n );\n\n // Incrementing to exactly max value should work\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(1), 50));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn decrement_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 2u64;\n\n // Decrement by 30\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 30));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterDecremented {\n new_value: 70,\n who: account,\n amount: 30,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n }\n\n #[test]\n fn decrement_tracks_multiple_interactions() {\n new_test_ext_with_counter(100).execute_with(|| {\n let account = 3u64;\n\n // Decrement multiple times\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 20));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 2)\n assert_eq!(crate::UserInteractions::::get(account), 2);\n });\n }\n\n #[test]\n fn mixed_increment_and_decrement_works() {\n new_test_ext_with_counter(50).execute_with(|| {\n let account = 4u64;\n\n // Mix of increment and decrement\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 25));\n assert_eq!(crate::CounterValue::::get(), 75);\n\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 15));\n assert_eq!(crate::CounterValue::::get(), 60);\n\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn different_users_tracked_separately() {\n new_test_ext().execute_with(|| {\n let account1 = 1u64;\n let account2 = 2u64;\n\n // User 1 increments\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n\n // User 2 decrements\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account2), 5));\n\n // Check counter value (10 + 10 - 5 = 15)\n assert_eq!(crate::CounterValue::::get(), 15);\n\n // Check user interactions are tracked separately\n assert_eq!(crate::UserInteractions::::get(account1), 2);\n assert_eq!(crate::UserInteractions::::get(account2), 1);\n });\n }\n\n #[test]\n fn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n }\n ```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 19815, "end_char": 20165, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Add Your Custom Pallet to the Runtime__\n\n ---\n\n Your pallet is tested and ready! Learn how to integrate it into your runtime.\n\n [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)\n\n
"} -======= {"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Create a Custom Pallet", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 26, "end_char": 847, "estimated_token_count": 167, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[Framework for Runtime Aggregation of Modular Entities (FRAME)](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html){target=\\_blank} provides a powerful set of tools for blockchain development through modular components called [pallets](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/pallet/index.html){target=\\_blank}. These Rust-based runtime modules allow you to build custom blockchain functionality with precision and flexibility. While FRAME includes a library of pre-built pallets, its true strength lies in creating custom pallets tailored to your specific needs.\n\nIn this guide, you'll learn how to build a custom counter pallet from scratch that demonstrates core pallet development concepts."} {"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Create a Custom Pallet", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 847, "end_char": 1217, "estimated_token_count": 99, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have:\n\n- [Polkadot SDK dependencies installed](/parachains/install-polkadot-sdk/){target=\\_blank}.\n- A [Polkadot SDK Parchain Template](/parachains/launch-a-parachain/set-up-the-parachain-template/){target=\\_blank} set up locally.\n- Basic familiarity with [FRAME concepts](/parachains/customize-runtime/){target=\\_blank}."} {"page_id": "parachains-customize-runtime-pallet-development-create-a-pallet", "page_title": "Create a Custom Pallet", "index": 2, "depth": 2, "title": "Core Pallet Components", "anchor": "core-pallet-components", "start_char": 1217, "end_char": 2092, "estimated_token_count": 193, "token_estimator": "heuristic-v1", "text": "## Core Pallet Components\n\nAs you build your custom pallet, you'll work with these key sections:\n\n- **Imports and dependencies**: Bring in necessary FRAME libraries and external modules.\n- **Runtime configuration trait**: Specify types and constants for pallet-runtime interaction.\n- **Runtime events**: Define signals that communicate state changes.\n- **Runtime errors**: Define error types returned from dispatchable calls.\n- **Runtime storage**: Declare on-chain storage items for your pallet's state.\n- **Genesis configuration**: Set initial blockchain state.\n- **Dispatchable functions (extrinsics)**: Create callable functions for user interactions.\n\nFor additional macros beyond those covered here, refer to the [pallet_macros](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/index.html){target=\\_blank} section of the Polkadot SDK Docs."} @@ -665,14 +622,27 @@ {"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Your Runtime", "index": 10, "depth": 2, "title": "Verify Mock Compilation", "anchor": "verify-mock-compilation", "start_char": 7931, "end_char": 10853, "estimated_token_count": 564, "token_estimator": "heuristic-v1", "text": "## Verify Mock Compilation\n\nBefore proceeding to write tests, ensure your mock runtime compiles correctly:\n\n```bash\ncargo test --package pallet-custom --lib\n```\n\nThis command compiles the test code (including the mock and genesis configuration) without running tests yet. Address any compilation errors before continuing.\n\n??? code \"Complete mock runtime script\"\n\n Here's the complete `mock.rs` file for reference:\n\n ```rust title=\"src/mock.rs\"\n use crate as pallet_custom;\n use frame::{\n deps::{\n frame_support::{ derive_impl, traits::ConstU32 },\n sp_io,\n sp_runtime::{ traits::IdentityLookup, BuildStorage },\n },\n prelude::*,\n };\n\n type Block = frame_system::mocking::MockBlock;\n\n // Configure a mock runtime to test the pallet.\n frame::deps::frame_support::construct_runtime!(\n pub enum Test\n {\n System: frame_system,\n CustomPallet: pallet_custom,\n }\n );\n\n #[derive_impl(frame_system::config_preludes::TestDefaultConfig)]\n impl frame_system::Config for Test {\n type Block = Block;\n type AccountId = u64;\n type Lookup = IdentityLookup;\n }\n\n impl pallet_custom::Config for Test {\n type RuntimeEvent = RuntimeEvent;\n type CounterMaxValue = ConstU32<1000>;\n }\n\n // Build genesis storage according to the mock runtime.\n pub fn new_test_ext() -> sp_io::TestExternalities {\n let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap();\n\n (pallet_custom::GenesisConfig:: {\n initial_counter_value: 0,\n initial_user_interactions: vec![],\n })\n .assimilate_storage(&mut t)\n .unwrap();\n\n t.into()\n }\n\n // Helper function to create a test externalities with a specific initial counter value\n pub fn new_test_ext_with_counter(initial_value: u32) -> sp_io::TestExternalities {\n let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap();\n\n (pallet_custom::GenesisConfig:: {\n initial_counter_value: initial_value,\n initial_user_interactions: vec![],\n })\n .assimilate_storage(&mut t)\n .unwrap();\n\n t.into()\n }\n\n // Helper function to create a test externalities with initial user interactions\n pub fn new_test_ext_with_interactions(\n initial_value: u32,\n interactions: Vec<(u64, u32)>\n ) -> sp_io::TestExternalities {\n let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap();\n\n (pallet_custom::GenesisConfig:: {\n initial_counter_value: initial_value,\n initial_user_interactions: interactions,\n })\n .assimilate_storage(&mut t)\n .unwrap();\n\n t.into()\n }\n ```"} {"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Your Runtime", "index": 11, "depth": 2, "title": "Key Takeaways", "anchor": "key-takeaways", "start_char": 10853, "end_char": 11416, "estimated_token_count": 98, "token_estimator": "heuristic-v1", "text": "## Key Takeaways\n\nYou've successfully created a mock runtime with a genesis configuration for your custom pallet. You can now:\n\n- Test your pallet without a full runtime.\n- Set initial blockchain state for different test scenarios.\n- Create different genesis setups for various testing needs.\n- Use this minimal setup to test all pallet functionality.\n\nThe mock runtime with a genesis configuration is essential for test-driven development, enabling you to verify logic under different initial conditions before integrating it into the actual parachain runtime."} {"page_id": "parachains-customize-runtime-pallet-development-mock-runtime", "page_title": "Mock Your Runtime", "index": 12, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 11416, "end_char": 11766, "estimated_token_count": 87, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Pallet Unit Testing__\n\n ---\n\n Learn to write comprehensive unit tests for your pallet using the mock runtime you just created.\n\n [:octicons-arrow-right-24: Continue](/parachains/customize-runtime/pallet-development/pallet-testing/)\n\n
"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 18, "end_char": 672, "estimated_token_count": 123, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nUnit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. The Polkadot SDK offers a set of APIs to create a test environment to simulate runtime and mock transaction execution for extrinsics and queries.\n\nTo begin unit testing, you must first set up a mock runtime that simulates blockchain behavior, incorporating the necessary pallets. For a deeper understanding, consult the [Mock Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/){target=\\_blank} guide."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 1, "depth": 2, "title": "Writing Unit Tests", "anchor": "writing-unit-tests", "start_char": 672, "end_char": 2195, "estimated_token_count": 285, "token_estimator": "heuristic-v1", "text": "## Writing Unit Tests\n\nOnce the mock runtime is in place, the next step is to write unit tests that evaluate the functionality of your pallet. Unit tests allow you to test specific pallet features in isolation, ensuring that each function behaves correctly under various conditions. These tests typically reside in your pallet module's `test.rs` file.\n\nUnit tests in the Polkadot SDK use the Rust testing framework, and the mock runtime you've defined earlier will serve as the test environment. Below are the typical steps involved in writing unit tests for a pallet.\n\nThe tests confirm that:\n\n- **Pallets initialize correctly**: At the start of each test, the system should initialize with block number 0, and the pallets should be in their default states.\n- **Pallets modify each other's state**: The second test shows how one pallet can trigger changes in another pallet's internal state, confirming proper cross-pallet interactions.\n- **State transitions between blocks are seamless**: By simulating block transitions, the tests validate that the runtime responds correctly to changes in the block number.\n\nTesting pallet interactions within the runtime is critical for ensuring the blockchain behaves as expected under real-world conditions. Writing integration tests allows validation of how pallets function together, preventing issues that might arise when the system is fully assembled.\n\nThis approach provides a comprehensive view of the runtime's functionality, ensuring the blockchain is stable and reliable."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 2, "depth": 3, "title": "Test Initialization", "anchor": "test-initialization", "start_char": 2195, "end_char": 2507, "estimated_token_count": 68, "token_estimator": "heuristic-v1", "text": "### Test Initialization\n\nEach test starts by initializing the runtime environment, typically using the `new_test_ext()` function, which sets up the mock storage and environment.\n\n```rust\n#[test]\nfn test_pallet_functionality() {\n new_test_ext().execute_with(|| {\n // Test logic goes here\n });\n}\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 3, "depth": 3, "title": "Function Call Testing", "anchor": "function-call-testing", "start_char": 2507, "end_char": 3280, "estimated_token_count": 167, "token_estimator": "heuristic-v1", "text": "### Function Call Testing\n\nCall the pallet's extrinsics or functions to simulate user interaction or internal logic. Use the `assert_ok!` macro to check for successful execution and `assert_err!` to verify that errors are correctly handled.\n\n```rust\n#[test]\nfn it_works_for_valid_input() {\n new_test_ext().execute_with(|| {\n // Call an extrinsic or function\n assert_ok!(TemplateModule::some_function(Origin::signed(1), valid_param));\n });\n}\n\n#[test]\nfn it_fails_for_invalid_input() {\n new_test_ext().execute_with(|| {\n // Call an extrinsic with invalid input and expect an error\n assert_err!(\n TemplateModule::some_function(Origin::signed(1), invalid_param),\n Error::::InvalidInput\n );\n });\n}\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 4, "depth": 3, "title": "Storage Testing", "anchor": "storage-testing", "start_char": 3280, "end_char": 4129, "estimated_token_count": 190, "token_estimator": "heuristic-v1", "text": "### Storage Testing\n\nAfter calling a function or extrinsic in your pallet, it's essential to verify that the state changes in the pallet's storage match the expected behavior to ensure data is updated correctly based on the actions taken.\n\nThe following example shows how to test the storage behavior before and after the function call:\n\n```rust\n#[test]\nfn test_storage_update_on_extrinsic_call() {\n new_test_ext().execute_with(|| {\n // Check the initial storage state (before the call)\n assert_eq!(Something::::get(), None);\n\n // Dispatch a signed extrinsic, which modifies storage\n assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42));\n\n // Validate that the storage has been updated as expected (after the call)\n assert_eq!(Something::::get(), Some(42));\n });\n}\n\n```"} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 5, "depth": 3, "title": "Event Testing", "anchor": "event-testing", "start_char": 4129, "end_char": 6150, "estimated_token_count": 519, "token_estimator": "heuristic-v1", "text": "### Event Testing\n\nIt's also crucial to test the events that your pallet emits during execution. By default, events generated in a pallet using the [`#generate_deposit`](https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.generate_deposit.html){target=\\_blank} macro are stored under the system's event storage key (system/events) as [`EventRecord`](https://paritytech.github.io/polkadot-sdk/master/frame_system/struct.EventRecord.html){target=\\_blank} entries. These can be accessed using [`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\\_blank} or verified with specific helper methods provided by the system pallet, such as [`assert_has_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_has_event){target=\\_blank} and [`assert_last_event`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\\_blank}.\n\nHere's an example of testing events in a mock runtime:\n\n```rust\n#[test]\nfn it_emits_events_on_success() {\n new_test_ext().execute_with(|| {\n // Call an extrinsic or function\n assert_ok!(TemplateModule::some_function(Origin::signed(1), valid_param));\n\n // Verify that the expected event was emitted\n assert!(System::events().iter().any(|record| {\n record.event == Event::TemplateModule(TemplateEvent::SomeEvent)\n }));\n });\n}\n```\n\nSome key considerations are:\n\n- **Block number**: Events are not emitted on the genesis block, so you need to set the block number using [`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\\_blank} to ensure events are triggered.\n- **Converting events**: Use `.into()` when instantiating your pallet's event to convert it into a generic event type, as required by the system's event storage."} -{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Testing", "index": 6, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6150, "end_char": 6892, "estimated_token_count": 211, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n- Dive into the full implementation of the [`mock.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/mock.rs){target=\\_blank} and [`test.rs`](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/pallets/template/src/tests.rs){target=\\_blank} files in the [Solochain Template](https://github.com/paritytech/polkadot-sdk/tree/master/templates/solochain){target=_blank}.\n\n
\n\n- Guide __Benchmarking__\n\n ---\n\n Explore methods to measure the performance and execution cost of your pallet.\n\n [:octicons-arrow-right-24: Reference](/develop/parachains/testing/benchmarking)\n\n
"} ->>>>>>> staging/product-ia +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 23, "end_char": 614, "estimated_token_count": 104, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nUnit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation.\n\nIn this guide, you'll learn how to:\n\n- Structure test modules effectively\n- Test dispatchable functions\n- Verify storage changes\n- Check event emission\n- Test error conditions\n- Use genesis configurations in tests"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 614, "end_char": 1069, "estimated_token_count": 119, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore you begin, ensure you have:\n\n- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide\n- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide\n- The custom counter pallet with mock runtime in `pallets/pallet-custom`\n- Basic understanding of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\\_blank}"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 2, "depth": 2, "title": "Understanding FRAME Testing Tools", "anchor": "understanding-frame-testing-tools", "start_char": 1069, "end_char": 1205, "estimated_token_count": 20, "token_estimator": "heuristic-v1", "text": "## Understanding FRAME Testing Tools\n\nFRAME provides specialized testing macros and utilities that make pallet testing more efficient:"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 3, "depth": 3, "title": "Assertion Macros", "anchor": "assertion-macros", "start_char": 1205, "end_char": 1880, "estimated_token_count": 174, "token_estimator": "heuristic-v1", "text": "### Assertion Macros\n\n- **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\\_blank}** - Asserts that a dispatchable call succeeds.\n- **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\\_blank}** - Asserts that a call fails without changing state (no operation).\n- **`assert_eq!`** - Standard Rust equality assertion.\n\n!!!info \"`assert_noop!` Explained\"\n Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 4, "depth": 3, "title": "System Pallet Test Helpers", "anchor": "system-pallet-test-helpers", "start_char": 1880, "end_char": 2876, "estimated_token_count": 279, "token_estimator": "heuristic-v1", "text": "### System Pallet Test Helpers\n\nThe [`frame_system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\\_blank} pallet provides useful methods for testing:\n\n- **[`System::events()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.events){target=\\_blank}** - Returns all events emitted during the test.\n- **[`System::assert_last_event()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.assert_last_event){target=\\_blank}** - Asserts the last event matches expectations.\n- **[`System::set_block_number()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/struct.Pallet.html#method.set_block_number){target=\\_blank}** - Sets the current block number.\n\n!!!info \"Events and Block Number\"\n Events are not emitted on block 0 (genesis block). If you need to test events, ensure you set the block number to at least 1 using `System::set_block_number(1)`."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 5, "depth": 3, "title": "Origin Types", "anchor": "origin-types", "start_char": 2876, "end_char": 3667, "estimated_token_count": 230, "token_estimator": "heuristic-v1", "text": "### Origin Types\n\n- **[`RuntimeOrigin::root()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Root){target=\\_blank}** - Root/sudo origin for privileged operations.\n- **[`RuntimeOrigin::signed(account)`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.Signed){target=\\_blank}** - Signed origin from a specific account.\n- **[`RuntimeOrigin::none()`](https://paritytech.github.io/polkadot-sdk/master/frame_system/enum.RawOrigin.html#variant.None){target=\\_blank}** - No origin (typically fails for most operations).\n\nLearn more about origins in the [FRAME Origin reference document](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html){target=\\_blank}."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 6, "depth": 2, "title": "Create the Tests Module", "anchor": "create-the-tests-module", "start_char": 3667, "end_char": 4274, "estimated_token_count": 166, "token_estimator": "heuristic-v1", "text": "## Create the Tests Module\n\nCreate a new file for your tests within the pallet directory:\n\n1. Navigate to your pallet directory:\n\n ```bash\n cd pallets/pallet-custom/src\n ```\n\n2. Create a new file named `tests.rs`:\n\n ```bash\n touch tests.rs\n ```\n\n3. Open `src/lib.rs` and add the tests module declaration after the mock module:\n\n ```rust title=\"src/lib.rs\"\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[cfg(test)]\n mod mock;\n\n #[cfg(test)]\n mod tests;\n\n #[frame::pallet]\n pub mod pallet {\n // ... existing pallet code\n }\n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 7, "depth": 2, "title": "Set Up the Test Module", "anchor": "set-up-the-test-module", "start_char": 4274, "end_char": 8952, "estimated_token_count": 1011, "token_estimator": "heuristic-v1", "text": "## Set Up the Test Module\n\nOpen `src/tests.rs` and add the basic structure with necessary imports:\n\n```rust\nuse crate::{mock::*, Error, Event};\nuse frame::deps::frame_support::{assert_noop, assert_ok};\nuse frame::deps::sp_runtime::DispatchError;\n```\n\nThis setup imports:\n\n- The mock runtime and test utilities from `mock.rs`\n- Your pallet's `Error` and `Event` types\n- FRAME's assertion macros via `frame::deps`\n- `DispatchError` for testing origin checks\n\n???+ code \"Complete Pallet Code Reference\"\n Here's the complete pallet code that you'll be testing throughout this guide:\n\n ```rust\n #![cfg_attr(not(feature = \"std\"), no_std)]\n\n pub use pallet::*;\n\n #[frame::pallet]\n pub mod pallet {\n use frame::prelude::*;\n\n #[pallet::pallet]\n pub struct Pallet(_);\n\n #[pallet::config]\n pub trait Config: frame_system::Config {\n type RuntimeEvent: From> + IsType<::RuntimeEvent>;\n\n #[pallet::constant]\n type CounterMaxValue: Get;\n }\n\n #[pallet::event]\n #[pallet::generate_deposit(pub(super) fn deposit_event)]\n pub enum Event {\n CounterValueSet {\n new_value: u32,\n },\n CounterIncremented {\n new_value: u32,\n who: T::AccountId,\n amount: u32,\n },\n CounterDecremented {\n new_value: u32,\n who: T::AccountId,\n amount: u32,\n },\n }\n\n #[pallet::error]\n pub enum Error {\n NoneValue,\n Overflow,\n Underflow,\n CounterMaxValueExceeded,\n }\n\n #[pallet::storage]\n pub type CounterValue = StorageValue<_, u32, ValueQuery>;\n\n #[pallet::storage]\n pub type UserInteractions = StorageMap<\n _,\n Blake2_128Concat,\n T::AccountId,\n u32,\n ValueQuery\n >;\n\n #[pallet::genesis_config]\n #[derive(DefaultNoBound)]\n pub struct GenesisConfig {\n pub initial_counter_value: u32,\n pub initial_user_interactions: Vec<(T::AccountId, u32)>,\n }\n\n #[pallet::genesis_build]\n impl BuildGenesisConfig for GenesisConfig {\n fn build(&self) {\n CounterValue::::put(self.initial_counter_value);\n for (account, count) in &self.initial_user_interactions {\n UserInteractions::::insert(account, count);\n }\n }\n }\n\n #[pallet::call]\n impl Pallet {\n #[pallet::call_index(0)]\n #[pallet::weight(0)]\n pub fn set_counter_value(origin: OriginFor, new_value: u32) -> DispatchResult {\n ensure_root(origin)?;\n ensure!(new_value <= T::CounterMaxValue::get(), Error::::CounterMaxValueExceeded);\n CounterValue::::put(new_value);\n Self::deposit_event(Event::CounterValueSet { new_value });\n Ok(())\n }\n\n #[pallet::call_index(1)]\n #[pallet::weight(0)]\n pub fn increment(origin: OriginFor, amount: u32) -> DispatchResult {\n let who = ensure_signed(origin)?;\n let current_value = CounterValue::::get();\n let new_value = current_value.checked_add(amount).ok_or(Error::::Overflow)?;\n ensure!(new_value <= T::CounterMaxValue::get(), Error::::CounterMaxValueExceeded);\n CounterValue::::put(new_value);\n UserInteractions::::mutate(&who, |count| {\n *count = count.saturating_add(1);\n });\n Self::deposit_event(Event::CounterIncremented { new_value, who, amount });\n Ok(())\n }\n\n #[pallet::call_index(2)]\n #[pallet::weight(0)]\n pub fn decrement(origin: OriginFor, amount: u32) -> DispatchResult {\n let who = ensure_signed(origin)?;\n let current_value = CounterValue::::get();\n let new_value = current_value.checked_sub(amount).ok_or(Error::::Underflow)?;\n CounterValue::::put(new_value);\n UserInteractions::::mutate(&who, |count| {\n *count = count.saturating_add(1);\n });\n Self::deposit_event(Event::CounterDecremented { new_value, who, amount });\n Ok(())\n }\n }\n }\n\n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 8, "depth": 2, "title": "Write Your First Test", "anchor": "write-your-first-test", "start_char": 8952, "end_char": 9060, "estimated_token_count": 22, "token_estimator": "heuristic-v1", "text": "## Write Your First Test\n\nLet's start with a simple test to verify the increment function works correctly."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 9, "depth": 3, "title": "Test Basic Increment", "anchor": "test-basic-increment", "start_char": 9060, "end_char": 10138, "estimated_token_count": 238, "token_estimator": "heuristic-v1", "text": "### Test Basic Increment\n\nTest that the increment function increases counter value and emits events.\n\n```rust\n#[test]\nfn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n}\n```\n\nRun your first test:\n\n```bash\ncargo test --package pallet-custom increment_works\n```\n\nYou should see:\n\n```\nrunning 1 test\ntest tests::increment_works ... ok\n```\n\nCongratulations! You've written and run your first pallet test."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 10, "depth": 2, "title": "Test Error Conditions", "anchor": "test-error-conditions", "start_char": 10138, "end_char": 10283, "estimated_token_count": 28, "token_estimator": "heuristic-v1", "text": "## Test Error Conditions\n\nNow let's test that our pallet correctly handles errors. Error testing is crucial to ensure your pallet fails safely."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 11, "depth": 3, "title": "Test Overflow Protection", "anchor": "test-overflow-protection", "start_char": 10283, "end_char": 10798, "estimated_token_count": 113, "token_estimator": "heuristic-v1", "text": "### Test Overflow Protection\n\nTest that incrementing at u32::MAX fails with Overflow error.\n\n```rust\n#[test]\nfn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n}\n```\n\nTest overflow protection:\n\n```bash\ncargo test --package pallet-custom increment_fails_on_overflow\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 12, "depth": 3, "title": "Test Underflow Protection", "anchor": "test-underflow-protection", "start_char": 10798, "end_char": 11310, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "### Test Underflow Protection\n\nTest that decrementing below zero fails with Underflow error.\n\n```rust\n#[test]\nfn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n}\n```\n\nVerify underflow protection:\n\n```bash\ncargo test --package pallet-custom decrement_fails_on_underflow\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 13, "depth": 2, "title": "Test Access Control", "anchor": "test-access-control", "start_char": 11310, "end_char": 11414, "estimated_token_count": 17, "token_estimator": "heuristic-v1", "text": "## Test Access Control\n\nVerify that origin checks work correctly and unauthorized access is prevented."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 14, "depth": 3, "title": "Test Root-Only Access", "anchor": "test-root-only-access", "start_char": 11414, "end_char": 12179, "estimated_token_count": 164, "token_estimator": "heuristic-v1", "text": "### Test Root-Only Access\n\nTest that set_counter_value requires root origin and rejects signed origins.\n\n```rust\n#[test]\nfn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n let alice = 1u64;\n\n // When: non-root user tries to set counter\n // Then: should fail with BadOrigin\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(alice), 100),\n DispatchError::BadOrigin\n );\n\n // But root should succeed\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n });\n}\n```\n\nTest access control:\n\n```bash\ncargo test --package pallet-custom set_counter_value_requires_root\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 15, "depth": 2, "title": "Test Event Emission", "anchor": "test-event-emission", "start_char": 12179, "end_char": 12266, "estimated_token_count": 16, "token_estimator": "heuristic-v1", "text": "## Test Event Emission\n\nVerify that events are emitted correctly with the right data."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 16, "depth": 3, "title": "Test Event Data", "anchor": "test-event-data", "start_char": 12266, "end_char": 13353, "estimated_token_count": 236, "token_estimator": "heuristic-v1", "text": "### Test Event Data\n\nThe `increment_works` test (shown earlier) already demonstrates event testing by:\n1. Setting the block number to 1 to enable event emission\n2. Calling the dispatchable function\n3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data\n\nThis pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function:\n\nTest that set_counter_value updates storage and emits correct event.\n\n```rust\n#[test]\nfn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n}\n```\n\nRun the event test:\n\n```bash\ncargo test --package pallet-custom set_counter_value_works\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 17, "depth": 2, "title": "Test Genesis Configuration", "anchor": "test-genesis-configuration", "start_char": 13353, "end_char": 13436, "estimated_token_count": 12, "token_estimator": "heuristic-v1", "text": "## Test Genesis Configuration\n\nVerify that genesis configuration works correctly."} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 18, "depth": 3, "title": "Test Genesis Setup", "anchor": "test-genesis-setup", "start_char": 13436, "end_char": 14055, "estimated_token_count": 160, "token_estimator": "heuristic-v1", "text": "### Test Genesis Setup\n\nTest that genesis configuration correctly initializes counter and user interactions.\n\n```rust\n#[test]\nfn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n}\n```\n\nTest genesis configuration:\n\n```bash\ncargo test --package pallet-custom genesis_config_works\n```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 19, "depth": 2, "title": "Run All Tests", "anchor": "run-all-tests", "start_char": 14055, "end_char": 23880, "estimated_token_count": 2038, "token_estimator": "heuristic-v1", "text": "## Run All Tests\n\nNow run all your tests together:\n\n```bash\ncargo test --package pallet-custom\n```\n\nYou should see all tests passing:\n\n```\nrunning 15 tests\ntest mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok\ntest mock::test_genesis_config_builds ... ok\ntest tests::decrement_fails_on_underflow ... ok\ntest tests::decrement_tracks_multiple_interactions ... ok\ntest tests::decrement_works ... ok\ntest tests::different_users_tracked_separately ... ok\ntest tests::genesis_config_works ... ok\ntest tests::increment_fails_on_overflow ... ok\ntest tests::increment_respects_max_value ... ok\ntest tests::increment_tracks_multiple_interactions ... ok\ntest tests::increment_works ... ok\ntest tests::mixed_increment_and_decrement_works ... ok\ntest tests::set_counter_value_requires_root ... ok\ntest tests::set_counter_value_respects_max_value ... ok\ntest tests::set_counter_value_works ... ok\n\ntest result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out\n```\n\n!!!note \"Mock Runtime Tests\"\n You'll notice 2 additional tests from the `mock` module:\n\n - `mock::__construct_runtime_integrity_test::runtime_integrity_tests` - Auto-generated test that validates runtime construction\n - `mock::test_genesis_config_builds` - Validates that genesis configuration builds correctly\n\n These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid.\n\nCongratulations! You have a well-tested pallet covering the essential testing patterns!\n\nThese tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality.\n\n??? code \"Full Test Suite Code\"\n Here's the complete `tests.rs` file for quick reference:\n\n ```rust\n use crate::{mock::*, Error, Event};\n use frame::deps::frame_support::{assert_noop, assert_ok};\n use frame::deps::sp_runtime::DispatchError;\n\n #[test]\n fn set_counter_value_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n // Set counter to 100\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 100));\n assert_eq!(crate::CounterValue::::get(), 100);\n\n // Check event was emitted\n System::assert_last_event(Event::CounterValueSet { new_value: 100 }.into());\n });\n }\n\n #[test]\n fn set_counter_value_requires_root() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter with non-root origin should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::signed(1), 100),\n DispatchError::BadOrigin\n );\n });\n }\n\n #[test]\n fn set_counter_value_respects_max_value() {\n new_test_ext().execute_with(|| {\n // Attempt to set counter above max value (1000) should fail\n assert_noop!(\n CustomPallet::set_counter_value(RuntimeOrigin::root(), 1001),\n Error::::CounterMaxValueExceeded\n );\n\n // Setting to exactly max value should work\n assert_ok!(CustomPallet::set_counter_value(RuntimeOrigin::root(), 1000));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn increment_works() {\n new_test_ext().execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 1u64;\n\n // Increment by 50\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 50));\n assert_eq!(crate::CounterValue::::get(), 50);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterIncremented {\n new_value: 50,\n who: account,\n amount: 50,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn increment_tracks_multiple_interactions() {\n new_test_ext().execute_with(|| {\n let account = 1u64;\n\n // Increment multiple times\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 20));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 30));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 60);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn increment_fails_on_overflow() {\n new_test_ext_with_counter(u32::MAX).execute_with(|| {\n // Attempt to increment when at max u32 should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 1),\n Error::::Overflow\n );\n });\n }\n\n #[test]\n fn increment_respects_max_value() {\n new_test_ext_with_counter(950).execute_with(|| {\n // Incrementing past max value (1000) should fail\n assert_noop!(\n CustomPallet::increment(RuntimeOrigin::signed(1), 51),\n Error::::CounterMaxValueExceeded\n );\n\n // Incrementing to exactly max value should work\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(1), 50));\n assert_eq!(crate::CounterValue::::get(), 1000);\n });\n }\n\n #[test]\n fn decrement_works() {\n new_test_ext_with_counter(100).execute_with(|| {\n // Set block number to 1 so events are registered\n System::set_block_number(1);\n\n let account = 2u64;\n\n // Decrement by 30\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 30));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check event was emitted\n System::assert_last_event(\n Event::CounterDecremented {\n new_value: 70,\n who: account,\n amount: 30,\n }\n .into(),\n );\n\n // Check user interactions were tracked\n assert_eq!(crate::UserInteractions::::get(account), 1);\n });\n }\n\n #[test]\n fn decrement_fails_on_underflow() {\n new_test_ext_with_counter(10).execute_with(|| {\n // Attempt to decrement below zero should fail\n assert_noop!(\n CustomPallet::decrement(RuntimeOrigin::signed(1), 11),\n Error::::Underflow\n );\n });\n }\n\n #[test]\n fn decrement_tracks_multiple_interactions() {\n new_test_ext_with_counter(100).execute_with(|| {\n let account = 3u64;\n\n // Decrement multiple times\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 10));\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 20));\n\n // Check counter value\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 2)\n assert_eq!(crate::UserInteractions::::get(account), 2);\n });\n }\n\n #[test]\n fn mixed_increment_and_decrement_works() {\n new_test_ext_with_counter(50).execute_with(|| {\n let account = 4u64;\n\n // Mix of increment and decrement\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 25));\n assert_eq!(crate::CounterValue::::get(), 75);\n\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account), 15));\n assert_eq!(crate::CounterValue::::get(), 60);\n\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account), 10));\n assert_eq!(crate::CounterValue::::get(), 70);\n\n // Check user interactions were tracked (should be 3)\n assert_eq!(crate::UserInteractions::::get(account), 3);\n });\n }\n\n #[test]\n fn different_users_tracked_separately() {\n new_test_ext().execute_with(|| {\n let account1 = 1u64;\n let account2 = 2u64;\n\n // User 1 increments\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n assert_ok!(CustomPallet::increment(RuntimeOrigin::signed(account1), 10));\n\n // User 2 decrements\n assert_ok!(CustomPallet::decrement(RuntimeOrigin::signed(account2), 5));\n\n // Check counter value (10 + 10 - 5 = 15)\n assert_eq!(crate::CounterValue::::get(), 15);\n\n // Check user interactions are tracked separately\n assert_eq!(crate::UserInteractions::::get(account1), 2);\n assert_eq!(crate::UserInteractions::::get(account2), 1);\n });\n }\n\n #[test]\n fn genesis_config_works() {\n new_test_ext_with_interactions(42, vec![(1, 5), (2, 10)]).execute_with(|| {\n // Check initial counter value\n assert_eq!(crate::CounterValue::::get(), 42);\n\n // Check initial user interactions\n assert_eq!(crate::UserInteractions::::get(1), 5);\n assert_eq!(crate::UserInteractions::::get(2), 10);\n });\n }\n ```"} +{"page_id": "parachains-customize-runtime-pallet-development-pallet-testing", "page_title": "Pallet Unit Testing", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 23880, "end_char": 24230, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Add Your Custom Pallet to the Runtime__\n\n ---\n\n Your pallet is tested and ready! Learn how to integrate it into your runtime.\n\n [:octicons-arrow-right-24: Integrate](/parachains/customize-runtime/pallet-development/add-to-runtime/)\n\n
"} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 26, "end_char": 754, "estimated_token_count": 146, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nA blockchain runtime is more than just a fixed set of rules—it's a dynamic foundation that you can shape to match your specific needs. With Polkadot SDK's [FRAME (Framework for Runtime Aggregation of Modularized Entities)](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\\_blank}, customizing your runtime is straightforward and modular. Instead of building everything from scratch, you combine pre-built pallets with your own custom logic to create a runtime suited to your blockchain's purpose.\n\nThis overview explains how runtime customization works, introduces the building blocks you'll use, and guides you through the key patterns for extending your runtime."} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 1, "depth": 2, "title": "Understanding Your Runtime", "anchor": "understanding-your-runtime", "start_char": 754, "end_char": 1532, "estimated_token_count": 158, "token_estimator": "heuristic-v1", "text": "## Understanding Your Runtime\n\nThe runtime is the core logic of your blockchain—it processes transactions, manages state, and enforces the rules that govern your network. When a transaction arrives at your blockchain, the [`frame_executive`](https://paritytech.github.io/polkadot-sdk/master/frame_executive/index.html){target=\\_blank} pallet receives it and routes it to the appropriate pallet for execution.\n\nThink of your runtime as a collection of specialized modules, each handling a different aspect of your blockchain. Need token balances? Use the Balances pallet. Want governance? Add the Governance pallet. Need something custom? Create your own pallet. By mixing and matching these modules, you build a runtime that's efficient, secure, and tailored to your use case."} {"page_id": "parachains-customize-runtime", "page_title": "Overview of FRAME", "index": 2, "depth": 2, "title": "Runtime Architecture", "anchor": "runtime-architecture", "start_char": 1532, "end_char": 2084, "estimated_token_count": 121, "token_estimator": "heuristic-v1", "text": "## Runtime Architecture\n\nThe following diagram shows how FRAME components work together to form your runtime:\n\n![](/images/parachains/customize-runtime/index/frame-overview-01.webp)\n\nThe main components are:\n\n- **`frame_executive`**: Routes all incoming transactions to the correct pallet for execution.\n- **Pallets**: Domain-specific modules that implement your blockchain's features and business logic.\n- **`frame_system`**: Provides core runtime primitives and storage.\n- **`frame_support`**: Utilities and macros that simplify pallet development."} @@ -691,18 +661,26 @@ {"page_id": "parachains-get-started", "page_title": "Get Started with Parachain Development", "index": 6, "depth": 2, "title": "Interoperability", "anchor": "interoperability", "start_char": 6290, "end_char": 7079, "estimated_token_count": 251, "token_estimator": "heuristic-v1", "text": "## Interoperability\n\nConfigure your parachain for cross-chain communication using XCM (Cross-Consensus Messaging).\n\n| Tutorial | Description |\n| :--------------------------------------------------------------------------------------------------------: | :----------------------------------------------------: |\n| [Open HRMP Channels Between Parachains](/parachains/interoperability/channels-between-parachains/) | Establish communication channels with other parachains |\n| [Open HRMP Channels with System Parachains](/parachains/interoperability/channels-with-system-parachains/) | Connect with Asset Hub and other system parachains |"} {"page_id": "parachains-get-started", "page_title": "Get Started with Parachain Development", "index": 7, "depth": 2, "title": "Integrations", "anchor": "integrations", "start_char": 7079, "end_char": 7708, "estimated_token_count": 189, "token_estimator": "heuristic-v1", "text": "## Integrations\n\nIntegrate your parachain with essential ecosystem tools and services.\n\n| Tutorial | Description |\n| :--------------------------------------------: | :----------------------------------------------------: |\n| [Wallets](/parachains/integrations/wallets/) | Integrate wallet support for user interactions |\n| [Indexers](/parachains/integrations/indexers/) | Set up indexing solutions for querying blockchain data |\n| [Oracles](/parachains/integrations/oracles/) | Connect your parachain to off-chain data sources |"} {"page_id": "parachains-get-started", "page_title": "Get Started with Parachain Development", "index": 8, "depth": 2, "title": "Additional Resources", "anchor": "additional-resources", "start_char": 7708, "end_char": 7941, "estimated_token_count": 60, "token_estimator": "heuristic-v1", "text": "## Additional Resources\n\n- [Polkadot SDK Documentation](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/index.html)\n- [Polkadot Wiki - Parachains](https://wiki.polkadot.network/docs/learn-parachains/)"} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 0, "depth": 2, "title": "Part 1: Install Dependencies", "anchor": "part-1-install-dependencies", "start_char": 497, "end_char": 530, "estimated_token_count": 7, "token_estimator": "heuristic-v1", "text": "## Part 1: Install Dependencies"} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 1, "depth": 3, "title": "macOS", "anchor": "macos", "start_char": 530, "end_char": 3540, "estimated_token_count": 667, "token_estimator": "heuristic-v1", "text": "### macOS\n\nYou can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors.\n\n#### Before You Begin\n\nBefore you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements:\n\n- Operating system version is 10.7 Lion or later.\n- Processor speed of at least 2 GHz. Note that 3 GHz is recommended.\n- Memory of at least 8 GB RAM. Note that 16 GB is recommended.\n- Storage of at least 10 GB of available space.\n- Broadband Internet connection.\n\n#### Install Homebrew\n\nIn most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing.\n\nTo install Homebrew:\n\n1. Open the Terminal application.\n2. Download and install Homebrew by running the following command:\n\n ```bash\n /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"\n ```\n\n3. Verify Homebrew has been successfully installed by running the following command:\n\n ```bash\n brew --version\n ```\n\n The command displays output similar to the following:\n\n
\n brew --version\n Homebrew 4.3.15\n
\n\n#### Support for Apple Silicon\n\nProtobuf must be installed before the build process can begin. To install it, run the following command:\n\n```bash\nbrew install protobuf\n```\n\n#### Install Required Packages and Rust\n\nBecause the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`.\n\nTo install `openssl` and the Rust toolchain on macOS:\n\n1. Open the Terminal application.\n2. Ensure you have an updated version of Homebrew by running the following command:\n\n ```bash\n brew update\n ```\n\n3. Install the `openssl` package by running the following command:\n\n ```bash\n brew install openssl\n ```\n\n4. Download the `rustup` installation program and use it to install Rust by running the following command:\n\n ```bash\n curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n ```\n\n5. Follow the prompts displayed to proceed with a default installation.\n6. Update your current shell to include Cargo by running the following command:\n\n ```bash\n source ~/.cargo/env\n ```\n\n7. Configure the Rust toolchain to default to the latest stable version by running the following commands:\n\n ```bash\n rustup default stable\n rustup update\n rustup target add wasm32-unknown-unknown\n rustup component add rust-src\n ```\n\n8. Install `cmake` using the following command:\n\n ```bash\n brew install cmake\n ```\n\n9. Proceed to [Part 2: Build the Polkadot SDK](#part-2-build-the-polkadot-sdk)."} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 2, "depth": 3, "title": "Linux", "anchor": "linux", "start_char": 3540, "end_char": 7011, "estimated_token_count": 703, "token_estimator": "heuristic-v1", "text": "### Linux\n\nRust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or C-compatible compiler, such as `clang` and an appropriate integrated development environment (IDE).\n\n#### Before You Begin\n\nCheck the documentation for your operating system for information about the installed packages and how to download and install any additional packages you might need. For example, if you use Ubuntu, you can use the Ubuntu Advanced Packaging Tool (`apt`) to install the `build-essential` package:\n\n```bash\nsudo apt install build-essential\n```\n\nAt a minimum, you need the following packages before you install Rust:\n\n```text\nclang curl git make\n```\n\nBecause the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `libssl-dev` or `openssl-devel`.\n\n#### Install Required Packages and Rust\n\nTo install the Rust toolchain on Linux:\n\n1. Open a terminal shell.\n2. Check the packages you have installed on the local computer by running an appropriate package management command for your Linux distribution.\n3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution:\n\n === \"Ubuntu\"\n\n ```bash\n sudo apt install --assume-yes git clang curl libssl-dev protobuf-compiler\n ```\n\n === \"Debian\"\n\n ```sh\n sudo apt install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler\n ```\n\n === \"Arch\"\n\n ```sh\n pacman -Syu --needed --noconfirm curl git clang make protobuf\n ```\n\n === \"Fedora\"\n\n ```sh\n sudo dnf update\n sudo dnf install clang curl git openssl-devel make protobuf-compiler\n ```\n\n === \"OpenSUSE\"\n\n ```sh\n sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf\n ```\n\n Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable for many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS.\n\n4. Download the `rustup` installation program and use it to install Rust by running the following command:\n\n ```bash\n curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n ```\n\n5. Follow the prompts displayed to proceed with a default installation.\n6. Update your current shell to include Cargo by running the following command:\n\n ```bash\n source $HOME/.cargo/env\n ```\n\n7. Verify your installation by running the following command:\n\n ```bash\n rustc --version\n ```\n\n8. Configure the Rust toolchain to default to the latest stable version by running the following commands:\n\n ```bash\n rustup default stable\n rustup update\n rustup target add wasm32-unknown-unknown\n rustup component add rust-src\n ```\n\n9. Proceed to [Part 2: Build the Polkadot SDK](#part-2-build-the-polkadot-sdk)."} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 3, "depth": 3, "title": "Windows (WSL)", "anchor": "windows-wsl", "start_char": 7011, "end_char": 11950, "estimated_token_count": 1056, "token_estimator": "heuristic-v1", "text": "### Windows (WSL)\n\nIn general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains.\n\nHowever, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment.\n\n#### Before You Begin\n\nBefore installing on Microsoft Windows, verify the following basic requirements:\n\n- You have a computer running a supported Microsoft Windows operating system:\n - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL.\n - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system.\n- You have good internet connection and access to a shell terminal on your local computer.\n\n#### Set Up Windows Subsystem for Linux\n\nWSL enables you to emulate a Linux environment on a computer that uses the Windows operating system. The primary advantage of this approach for Substrate development is that you can use all of the code and command-line examples as described in the Substrate documentation. For example, you can run common commands—such as `ls` and `ps`—unmodified. By using WSL, you can avoid configuring a virtual machine image or a dual-boot operating system.\n\nTo prepare a development environment using WSL:\n\n1. Check your Windows version and build number to see if WSL is enabled by default.\n\n If you have Microsoft Windows 10, version 2004 (Build 19041 and higher), or Microsoft Windows 11, WSL is available by default and you can continue to the next step.\n\n If you have an older version of Microsoft Windows installed, see the [WSL manual installation steps for older versions](https://learn.microsoft.com/en-us/windows/wsl/install-manual){target=\\_blank}. If you are installing on an older version of Microsoft Windows, you can download and install WLS 2 if your computer has Windows 10, version 1903 or higher.\n\n2. Select **Windows PowerShell** or **Command Prompt** from the **Start** menu, right-click, then **Run as administrator**.\n\n3. In the PowerShell or Command Prompt terminal, run the following command:\n\n ```bash\n wsl --install\n ```\n\n This command enables the required WSL 2 components that are part of the Windows operating system, downloads the latest Linux kernel, and installs the Ubuntu Linux distribution by default.\n\n If you want to review the other Linux distributions available, run the following command:\n\n ```bash\n wsl --list --online\n ```\n\n4. After the distribution is downloaded, close the terminal.\n\n5. Click the **Start** menu, select **Shut down or sign out**, then click **Restart** to restart the computer.\n\n Restarting the computer is required to start the installation of the Linux distribution. It can take a few minutes for the installation to complete after you restart.\n\n For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\\_blank} docs.\n\n#### Install Required Packages and Rust\n\nTo install the Rust toolchain on WSL:\n\n1. Click the **Start** menu, then select **Ubuntu**.\n2. Type a UNIX user name to create user account.\n3. Type a password for your UNIX user, then retype the password to confirm it.\n4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command:\n\n ```bash\n sudo apt update\n ```\n\n5. Add the required packages for the Ubuntu distribution by running the following command:\n\n ```bash\n sudo apt install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler\n ```\n\n6. Download the `rustup` installation program and use it to install Rust for the Ubuntu distribution by running the following command:\n\n ```bash\n curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n ```\n\n7. Follow the prompts displayed to proceed with a default installation.\n\n8. Update your current shell to include Cargo by running the following command:\n\n ```bash\n source ~/.cargo/env\n ```\n\n9. Verify your installation by running the following command:\n\n ```bash\n rustc --version\n ```\n\n10. Configure the Rust toolchain to use the latest stable version as the default toolchain by running the following commands:\n\n ```bash\n rustup default stable\n rustup update\n rustup target add wasm32-unknown-unknown\n rustup component add rust-src\n ```\n\n11. Proceed to [Part 2: Build the Polkadot SDK](#part-2-build-the-polkadot-sdk)."} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 4, "depth": 2, "title": "Part 2: Build the Polkadot SDK", "anchor": "part-2-build-the-polkadot-sdk", "start_char": 11950, "end_char": 12101, "estimated_token_count": 29, "token_estimator": "heuristic-v1", "text": "## Part 2: Build the Polkadot SDK\n\nAfter installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup."} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 5, "depth": 3, "title": "Clone the Polkadot SDK", "anchor": "clone-the-polkadot-sdk", "start_char": 12101, "end_char": 12332, "estimated_token_count": 58, "token_estimator": "heuristic-v1", "text": "### Clone the Polkadot SDK\n\n1. Clone the Polkadot SDK repository:\n\n ```bash\n git clone https://github.com/paritytech/polkadot-sdk.git\n ```\n\n2. Navigate into the project directory:\n\n ```bash\n cd polkadot-sdk\n ```"} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 6, "depth": 3, "title": "Compile the Polkadot SDK", "anchor": "compile-the-polkadot-sdk", "start_char": 12332, "end_char": 12787, "estimated_token_count": 89, "token_estimator": "heuristic-v1", "text": "### Compile the Polkadot SDK\n\nCompile the entire Polkadot SDK repository to ensure your environment is properly configured:\n\n```bash\ncargo build --release --locked\n```\n\n!!!warning\n This initial compilation will take significant time (30-60 minutes or more) depending on your machine specifications. The `--release` flag optimizes for performance. This step compiles all components of the Polkadot SDK to verify your toolchain is correctly configured."} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 7, "depth": 3, "title": "Verify the Build", "anchor": "verify-the-build", "start_char": 12787, "end_char": 13561, "estimated_token_count": 163, "token_estimator": "heuristic-v1", "text": "### Verify the Build\n\nOnce the build completes successfully, verify the installation by checking the compiled binaries:\n\n```bash\nls target/release\n```\n\nYou should see several binaries including:\n\n- `polkadot` - The Polkadot relay chain node\n- `polkadot-parachain` - The parachain collator node\n- `polkadot-omni-node` - The omni node for running parachains\n- `substrate-node` - The kitchensink node with many pre-configured pallets\n\nVerify the Polkadot binary works by checking its version:\n\n```bash\n./target/release/polkadot --version\n```\n\nThis should display version information similar to:\n\n```bash\npolkadot 1.16.0-1234abcd567\n```\n\nIf you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development!"} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 8, "depth": 2, "title": "Optional: Run the Kitchensink Node", "anchor": "optional-run-the-kitchensink-node", "start_char": 13561, "end_char": 14089, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "## Optional: Run the Kitchensink Node\n\nThe Polkadot SDK includes a feature-rich node called \"kitchensink\" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together.\n\n!!!note\n If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node."} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 9, "depth": 3, "title": "Run the Kitchensink Node in Development Mode", "anchor": "run-the-kitchensink-node-in-development-mode", "start_char": 14089, "end_char": 14674, "estimated_token_count": 125, "token_estimator": "heuristic-v1", "text": "### Run the Kitchensink Node in Development Mode\n\nFrom the `polkadot-sdk` root directory, start the kitchensink node in development mode:\n\n```bash\n./target/release/substrate-node --dev\n```\n\nThe `--dev` flag enables development mode, which:\n\n- Runs a single-node development chain\n- Produces and finalizes blocks automatically\n- Uses pre-configured development accounts (Alice, Bob, etc.)\n- Deletes all data when stopped, ensuring a clean state on restart\n\nYou should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`."} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 10, "depth": 3, "title": "Interact with the Kitchensink Node", "anchor": "interact-with-the-kitchensink-node", "start_char": 14674, "end_char": 15319, "estimated_token_count": 157, "token_estimator": "heuristic-v1", "text": "### Interact with the Kitchensink Node\n\nThe kitchensink node is accessible at `ws://localhost:9944`. To explore its features using the Polkadot.js Apps interface:\n\n1. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} in your web browser\n2. Click the network icon in the top left corner\n3. Scroll to **Development** and select **Local Node**\n4. Click **Switch** to connect to your local node\n\nYou can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications.\n\nTo stop the node, press `Control-C` in the terminal."} -{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 11, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 15319, "end_char": 15587, "estimated_token_count": 57, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n- **[Get Started with Parachain Development](/parachains/get-started/){target=\\_blank}**: Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 0, "depth": 2, "title": "Install Dependencies: macOS", "anchor": "install-dependencies-macos", "start_char": 495, "end_char": 656, "estimated_token_count": 28, "token_estimator": "heuristic-v1", "text": "## Install Dependencies: macOS\n\nYou can install Rust and set up a Substrate development environment on Apple macOS computers with Intel or Apple M1 processors."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 1, "depth": 3, "title": "Before You Begin {: #before-you-begin-mac-os }", "anchor": "before-you-begin-before-you-begin-mac-os", "start_char": 656, "end_char": 1113, "estimated_token_count": 102, "token_estimator": "heuristic-v1", "text": "### Before You Begin {: #before-you-begin-mac-os }\n\nBefore you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements:\n\n- Operating system version is 10.7 Lion or later.\n- Processor speed of at least 2 GHz. Note that 3 GHz is recommended.\n- Memory of at least 8 GB RAM. Note that 16 GB is recommended.\n- Storage of at least 10 GB of available space.\n- Broadband Internet connection."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 2, "depth": 3, "title": "Install Homebrew", "anchor": "install-homebrew", "start_char": 1113, "end_char": 1964, "estimated_token_count": 206, "token_estimator": "heuristic-v1", "text": "### Install Homebrew\n\nIn most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing.\n\nTo install Homebrew:\n\n1. Open the Terminal application.\n2. Download and install Homebrew by running the following command:\n\n ```bash\n /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"\n ```\n\n3. Verify Homebrew has been successfully installed by running the following command:\n\n ```bash\n brew --version\n ```\n\n The command displays output similar to the following:\n\n
\n brew --version\n Homebrew 4.3.15\n
"} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 3, "depth": 3, "title": "Support for Apple Silicon", "anchor": "support-for-apple-silicon", "start_char": 1964, "end_char": 2136, "estimated_token_count": 37, "token_estimator": "heuristic-v1", "text": "### Support for Apple Silicon\n\nProtobuf must be installed before the build process can begin. To install it, run the following command:\n\n```bash\nbrew install protobuf\n```"} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 4, "depth": 3, "title": "Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os }", "anchor": "install-required-packages-and-rust-install-required-packages-and-rust-mac-os", "start_char": 2136, "end_char": 3585, "estimated_token_count": 315, "token_estimator": "heuristic-v1", "text": "### Install Required Packages and Rust {: #install-required-packages-and-rust-mac-os }\n\nBecause the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `openssl`.\n\nTo install `openssl` and the Rust toolchain on macOS:\n\n1. Open the Terminal application.\n2. Ensure you have an updated version of Homebrew by running the following command:\n\n ```bash\n brew update\n ```\n\n3. Install the `openssl` package by running the following command:\n\n ```bash\n brew install openssl\n ```\n\n4. Download the `rustup` installation program and use it to install Rust by running the following command:\n\n ```bash\n curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n ```\n\n5. Follow the prompts displayed to proceed with a default installation.\n6. Update your current shell to include Cargo by running the following command:\n\n ```bash\n source ~/.cargo/env\n ```\n\n7. Configure the Rust toolchain to default to the latest stable version by running the following commands:\n\n ```bash\n rustup default stable\n rustup update\n rustup target add wasm32-unknown-unknown\n rustup component add rust-src\n ```\n\n8. Install `cmake` using the following command:\n\n ```bash\n brew install cmake\n ```\n\n9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk)."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 5, "depth": 2, "title": "Install Dependencies: Linux", "anchor": "install-dependencies-linux", "start_char": 3585, "end_char": 3983, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "## Install Dependencies: Linux\n\nRust supports most Linux distributions. Depending on the specific distribution and version of the operating system you use, you might need to add some software dependencies to your environment. In general, your development environment should include a linker or a C-compatible compiler, such as `clang`, and an appropriate integrated development environment (IDE)."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 6, "depth": 3, "title": "Before You Begin {: #before-you-begin-linux }", "anchor": "before-you-begin-before-you-begin-linux", "start_char": 3983, "end_char": 4735, "estimated_token_count": 159, "token_estimator": "heuristic-v1", "text": "### Before You Begin {: #before-you-begin-linux }\n\nCheck the documentation for your operating system for information about the installed packages and how to download and install any additional packages you might need. For example, if you use Ubuntu, you can use the Ubuntu Advanced Packaging Tool (`apt`) to install the `build-essential` package:\n\n```bash\nsudo apt install build-essential\n```\n\nAt a minimum, you need the following packages before you install Rust:\n\n```text\nclang curl git make\n```\n\nBecause the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as `libssl-dev` or `openssl-devel`."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 7, "depth": 3, "title": "Install Required Packages and Rust {: #install-required-packages-and-rust-linux }", "anchor": "install-required-packages-and-rust-install-required-packages-and-rust-linux", "start_char": 4735, "end_char": 7130, "estimated_token_count": 492, "token_estimator": "heuristic-v1", "text": "### Install Required Packages and Rust {: #install-required-packages-and-rust-linux }\n\nTo install the Rust toolchain on Linux:\n\n1. Open a terminal shell.\n2. Check the packages installed on the local computer by running the appropriate package management command for your Linux distribution.\n3. Add any package dependencies you are missing to your local development environment by running the appropriate package management command for your Linux distribution:\n\n === \"Ubuntu\"\n\n ```bash\n sudo apt install --assume-yes git clang curl libssl-dev protobuf-compiler\n ```\n\n === \"Debian\"\n\n ```sh\n sudo apt install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler\n ```\n\n === \"Arch\"\n\n ```sh\n pacman -Syu --needed --noconfirm curl git clang make protobuf\n ```\n\n === \"Fedora\"\n\n ```sh\n sudo dnf update\n sudo dnf install clang curl git openssl-devel make protobuf-compiler\n ```\n\n === \"OpenSUSE\"\n\n ```sh\n sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf\n ```\n\n Remember that different distributions might use different package managers and bundle packages in different ways. For example, depending on your installation selections, Ubuntu Desktop and Ubuntu Server might have different packages and different requirements. However, the packages listed in the command-line examples are applicable to many common Linux distributions, including Debian, Linux Mint, MX Linux, and Elementary OS.\n\n4. Download the `rustup` installation program and use it to install Rust by running the following command:\n\n ```bash\n curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n ```\n\n5. Follow the prompts displayed to proceed with a default installation.\n6. Update your current shell to include Cargo by running the following command:\n\n ```bash\n source $HOME/.cargo/env\n ```\n\n7. Verify your installation by running the following command:\n\n ```bash\n rustc --version\n ```\n\n8. Configure the Rust toolchain to default to the latest stable version by running the following commands:\n\n ```bash\n rustup default stable\n rustup update\n rustup target add wasm32-unknown-unknown\n rustup component add rust-src\n ```\n\n9. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk)."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 8, "depth": 2, "title": "Install Dependencies: Windows (WSL)", "anchor": "install-dependencies-windows-wsl", "start_char": 7130, "end_char": 7723, "estimated_token_count": 106, "token_estimator": "heuristic-v1", "text": "## Install Dependencies: Windows (WSL)\n\nIn general, UNIX-based operating systems—like macOS or Linux—provide a better development environment for building Substrate-based blockchains.\n\nHowever, suppose your local computer uses Microsoft Windows instead of a UNIX-based operating system. In that case, you can configure it with additional software to make it a suitable development environment for building Substrate-based blockchains. To prepare a development environment on a Microsoft Windows computer, you can use Windows Subsystem for Linux (WSL) to emulate a UNIX operating environment."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 9, "depth": 3, "title": "Before You Begin {: #before-you-begin-windows-wls }", "anchor": "before-you-begin-before-you-begin-windows-wls", "start_char": 7723, "end_char": 8306, "estimated_token_count": 122, "token_estimator": "heuristic-v1", "text": "### Before You Begin {: #before-you-begin-windows-wls }\n\nBefore installing on Microsoft Windows, verify the following basic requirements:\n\n- You have a computer running a supported Microsoft Windows operating system:\n - **For Windows desktop**: You must be running Microsoft Windows 10, version 2004 or later, or Microsoft Windows 11 to install WSL.\n - **For Windows server**: You must be running Microsoft Windows Server 2019, or later, to install WSL on a server operating system.\n- You have a good internet connection and access to a shell terminal on your local computer."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 10, "depth": 3, "title": "Set Up Windows Subsystem for Linux", "anchor": "set-up-windows-subsystem-for-linux", "start_char": 8306, "end_char": 10587, "estimated_token_count": 496, "token_estimator": "heuristic-v1", "text": "### Set Up Windows Subsystem for Linux\n\nWSL enables you to emulate a Linux environment on a computer that uses the Windows operating system. The primary advantage of this approach for Substrate development is that you can use all of the code and command-line examples as described in the Substrate documentation. For example, you can run common commands—such as `ls` and `ps`—unmodified. By using WSL, you can avoid configuring a virtual machine image or a dual-boot operating system.\n\nTo prepare a development environment using WSL:\n\n1. Check your Windows version and build number to see if WSL is enabled by default.\n\n If you have Microsoft Windows 10, version 2004 (Build 19041 and higher), or Microsoft Windows 11, WSL is available by default and you can continue to the next step.\n\n If you have an older version of Microsoft Windows installed, see the [WSL manual installation steps for older versions](https://learn.microsoft.com/en-us/windows/wsl/install-manual){target=\\_blank}. If you are installing on an older version of Microsoft Windows, you can download and install WLS 2 if your computer has Windows 10, version 1903 or higher.\n\n2. Select **Windows PowerShell** or **Command Prompt** from the **Start** menu, right-click, then **Run as administrator**.\n\n3. In the PowerShell or Command Prompt terminal, run the following command:\n\n ```bash\n wsl --install\n ```\n\n This command enables the required WSL 2 components that are part of the Windows operating system, downloads the latest Linux kernel, and installs the Ubuntu Linux distribution by default.\n\n If you want to review the other Linux distributions available, run the following command:\n\n ```bash\n wsl --list --online\n ```\n\n4. After the distribution is downloaded, close the terminal.\n\n5. Click the **Start** menu, select **Shut down or sign out**, then click **Restart** to restart the computer.\n\n Restarting the computer is required to start the installation of the Linux distribution. It can take a few minutes for the installation to complete after you restart.\n\n For more information about setting up WSL as a development environment, see the [Set up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment){target=\\_blank} docs."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 11, "depth": 3, "title": "Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls }", "anchor": "install-required-packages-and-rust-install-required-packages-and-rust-windows-wls", "start_char": 10587, "end_char": 12164, "estimated_token_count": 356, "token_estimator": "heuristic-v1", "text": "### Install Required Packages and Rust {: #install-required-packages-and-rust-windows-wls }\n\nTo install the Rust toolchain on WSL:\n\n1. Click the **Start** menu, then select **Ubuntu**.\n2. Type a UNIX user name to create a user account.\n3. Type a password for your UNIX user, then retype the password to confirm it.\n4. Download the latest updates for the Ubuntu distribution using the Ubuntu Advanced Packaging Tool (`apt`) by running the following command:\n\n ```bash\n sudo apt update\n ```\n\n5. Add the required packages for the Ubuntu distribution by running the following command:\n\n ```bash\n sudo apt install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler\n ```\n\n6. Download the `rustup` installation program and use it to install Rust for the Ubuntu distribution by running the following command:\n\n ```bash\n curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n ```\n\n7. Follow the prompts displayed to proceed with a default installation.\n\n8. Update your current shell to include Cargo by running the following command:\n\n ```bash\n source ~/.cargo/env\n ```\n\n9. Verify your installation by running the following command:\n\n ```bash\n rustc --version\n ```\n\n10. Configure the Rust toolchain to use the latest stable version as the default toolchain by running the following commands:\n\n ```bash\n rustup default stable\n rustup update\n rustup target add wasm32-unknown-unknown\n rustup component add rust-src\n ```\n\n11. Proceed to [Build the Polkadot SDK](#build-the-polkadot-sdk)."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 12, "depth": 2, "title": "Build the Polkadot SDK", "anchor": "build-the-polkadot-sdk", "start_char": 12164, "end_char": 12307, "estimated_token_count": 26, "token_estimator": "heuristic-v1", "text": "## Build the Polkadot SDK\n\nAfter installing all dependencies, you can now clone and compile the Polkadot SDK repository to verify your setup."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 13, "depth": 3, "title": "Clone the Polkadot SDK", "anchor": "clone-the-polkadot-sdk", "start_char": 12307, "end_char": 12538, "estimated_token_count": 58, "token_estimator": "heuristic-v1", "text": "### Clone the Polkadot SDK\n\n1. Clone the Polkadot SDK repository:\n\n ```bash\n git clone https://github.com/paritytech/polkadot-sdk.git\n ```\n\n2. Navigate into the project directory:\n\n ```bash\n cd polkadot-sdk\n ```"} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 14, "depth": 3, "title": "Compile the Polkadot SDK", "anchor": "compile-the-polkadot-sdk", "start_char": 12538, "end_char": 12912, "estimated_token_count": 70, "token_estimator": "heuristic-v1", "text": "### Compile the Polkadot SDK\n\nCompile the entire Polkadot SDK repository to ensure your environment is properly configured:\n\n```bash\ncargo build --release --locked\n```\n\n!!!note\n This initial compilation will take significant time, depending on your machine specifications. It compiles all components of the Polkadot SDK to verify your toolchain is correctly configured."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 15, "depth": 3, "title": "Verify the Build", "anchor": "verify-the-build", "start_char": 12912, "end_char": 13686, "estimated_token_count": 168, "token_estimator": "heuristic-v1", "text": "### Verify the Build\n\nOnce the build completes successfully, verify the installation by checking the compiled binaries:\n\n```bash\nls target/release\n```\n\nYou should see several binaries, including:\n\n- `polkadot`: The Polkadot relay chain node.\n- `polkadot-parachain`: The parachain collator node.\n- `polkadot-omni-node`:The omni node for running parachains.\n- `substrate-node`: The kitchensink node with many pre-configured pallets.\n\nVerify the Polkadot binary works by checking its version:\n\n```bash\n./target/release/polkadot --version\n```\n\nThis should display version information similar to:\n\n```bash\npolkadot 1.16.0-1234abcd567\n```\n\nIf you see the version output without errors, your development environment is correctly configured and ready for Polkadot SDK development!"} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 16, "depth": 2, "title": "Optional: Run the Kitchensink Node", "anchor": "optional-run-the-kitchensink-node", "start_char": 13686, "end_char": 14214, "estimated_token_count": 105, "token_estimator": "heuristic-v1", "text": "## Optional: Run the Kitchensink Node\n\nThe Polkadot SDK includes a feature-rich node called \"kitchensink\" located at `substrate/bin/node`. This node comes pre-configured with many pallets and features from the Polkadot SDK, making it an excellent reference for exploring capabilities and understanding how different components work together.\n\n!!!note\n If you've already compiled the Polkadot SDK in the previous step, the `substrate-node` binary is already built and ready to use. You can skip directly to running the node."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 17, "depth": 3, "title": "Run the Kitchensink Node in Development Mode", "anchor": "run-the-kitchensink-node-in-development-mode", "start_char": 14214, "end_char": 14804, "estimated_token_count": 129, "token_estimator": "heuristic-v1", "text": "### Run the Kitchensink Node in Development Mode\n\nFrom the `polkadot-sdk` root directory, start the kitchensink node in development mode:\n\n```bash\n./target/release/substrate-node --dev\n```\n\nThe `--dev` flag enables development mode, which:\n\n- Runs a single-node development chain.\n- Produces and finalizes blocks automatically.\n- Uses pre-configured development accounts (Alice, Bob, etc.).\n- Deletes all data when stopped, ensuring a clean state on restart.\n\n\nYou should see log output indicating the node is running and producing blocks, with increasing block numbers after `finalized`."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 18, "depth": 3, "title": "Interact with the Kitchensink Node", "anchor": "interact-with-the-kitchensink-node", "start_char": 14804, "end_char": 15697, "estimated_token_count": 225, "token_estimator": "heuristic-v1", "text": "### Interact with the Kitchensink Node\n\nThe kitchensink node is accessible at `ws://localhost:9944`. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} in your browser to explore its features and connect to the local node.\n\n1. Click the network icon in the top left corner.\n2. Scroll to **Development** and select **Local Node**.\n3. Click **Switch** to connect to your local node.\n\n![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-1.webp)\n\nOnce connected, the interface updates its color scheme to indicate a successful connection to the local node.\n\n![](/images/parachains/install-polkadot-sdk/install-polkadot-sdk-2.webp)\n\nYou can now explore the various pallets and features included in the kitchensink node, making it a valuable reference as you develop your own blockchain applications.\n\nTo stop the node, press `Control-C` in the terminal."} +{"page_id": "parachains-install-polkadot-sdk", "page_title": "Install Polkadot SDK", "index": 19, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 15697, "end_char": 16051, "estimated_token_count": 74, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- __Get Started with Parachain Development__\n\n ---\n\n Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging.\n\n [:octicons-arrow-right-24: Get Started](/parachains/get-started/)\n \n
"} {"page_id": "parachains-integrations-indexers", "page_title": "Indexers", "index": 0, "depth": 2, "title": "The Challenge of Blockchain Data Access", "anchor": "the-challenge-of-blockchain-data-access", "start_char": 12, "end_char": 649, "estimated_token_count": 103, "token_estimator": "heuristic-v1", "text": "## The Challenge of Blockchain Data Access\n\nBlockchain data is inherently sequential and distributed, with information stored chronologically across numerous blocks. While retrieving data from a single block through JSON-RPC API calls is straightforward, more complex queries that span multiple blocks present significant challenges:\n\n- Data is scattered and unorganized across the blockchain.\n- Retrieving large datasets can take days or weeks to sync.\n- Complex operations (like aggregations, averages, or cross-chain queries) require additional processing.\n- Direct blockchain queries can impact dApp performance and responsiveness."} {"page_id": "parachains-integrations-indexers", "page_title": "Indexers", "index": 1, "depth": 2, "title": "What is a Blockchain Indexer?", "anchor": "what-is-a-blockchain-indexer", "start_char": 649, "end_char": 1211, "estimated_token_count": 108, "token_estimator": "heuristic-v1", "text": "## What is a Blockchain Indexer?\n\nA blockchain indexer is a specialized infrastructure tool that processes, organizes, and stores blockchain data in an optimized format for efficient querying. Think of it as a search engine for blockchain data that:\n\n- Continuously monitors the blockchain for new blocks and transactions.\n- Processes and categorizes this data according to predefined schemas.\n- Stores the processed data in an easily queryable database.\n- Provides efficient APIs (typically [GraphQL](https://graphql.org/){target=\\_blank}) for data retrieval."} {"page_id": "parachains-integrations-indexers", "page_title": "Indexers", "index": 2, "depth": 2, "title": "Indexer Implementations", "anchor": "indexer-implementations", "start_char": 1211, "end_char": 2230, "estimated_token_count": 217, "token_estimator": "heuristic-v1", "text": "## Indexer Implementations\n\n
\n\n- __Subsquid__\n\n ---\n\n Subsquid is a data network that allows rapid and cost-efficient retrieval of blockchain data from 100+ chains using Subsquid's decentralized data lake and open-source SDK. In simple terms, Subsquid can be considered an ETL (extract, transform, and load) tool with a GraphQL server included. It enables comprehensive filtering, pagination, and even full-text search capabilities. Subsquid has native and full support for EVM and Substrate data, even within the same project.\n\n [:octicons-arrow-right-24: Reference](https://www.sqd.ai/){target=\\_blank}\n\n- __Subquery__\n\n ---\n\n SubQuery is a fast, flexible, and reliable open-source data decentralised infrastructure network that provides both RPC and indexed data to consumers worldwide.\n It provides custom APIs for your web3 project across multiple supported chains.\n\n [:octicons-arrow-right-24: Reference](https://subquery.network/){target=\\_blank}\n\n
"} @@ -756,16 +734,16 @@ {"page_id": "parachains-launch-a-parachain-obtain-coretime", "page_title": "Obtain Coretime", "index": 10, "depth": 3, "title": "Assign Your Parachain to the Core", "anchor": "assign-your-parachain-to-the-core", "start_char": 7562, "end_char": 8604, "estimated_token_count": 245, "token_estimator": "heuristic-v1", "text": "### Assign Your Parachain to the Core\n\nWith your core purchased, you now need to assign your parachain to it for block production:\n\n1. From the **My Regions** page, click on your core to select it.\n\n2. Click the **Assign** option from the left-hand menu.\n\n3. A modal will appear, allowing you to add a new task.\n\n4. Click **Add Task** and enter the following information:\n\n - **Parachain ID**: Your reserved parachain identifier\n - **Project Name**: The name of your parachain project\n\n5. Click **Add Task** to proceed.\n\n6. Select your parachain task from the list.\n\n7. Set the core's **Finality** setting:\n\n - **Provisional**: Allows interlacing and partitioning of the core, but the region cannot be renewed as-is.\n - **Final**: Prevents modification of the core but allows renewal. Choose this if you plan to renew the core.\n\n8. Sign and submit the transaction.\n\nOnce confirmed, your parachain will be assigned to the core and should begin producing blocks (provided your collator is running and synced with the relay chain)."} {"page_id": "parachains-launch-a-parachain-obtain-coretime", "page_title": "Obtain Coretime", "index": 11, "depth": 2, "title": "Next Steps", "anchor": "next-steps", "start_char": 8604, "end_char": 9049, "estimated_token_count": 91, "token_estimator": "heuristic-v1", "text": "## Next Steps\n\nYour parachain is now set up for block production. Consider the following:\n\n- **Monitor your collator**: Keep your collator node running and monitor its performance.\n- **Plan coretime renewal**: If using bulk coretime, plan to renew your core before the current lease expires.\n- **Explore runtime upgrades**: Once comfortable with your setup, explore how to upgrade your parachain's runtime without interrupting block production."} {"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 46, "end_char": 1141, "estimated_token_count": 228, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThe [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\\_blank} includes several [templates](/parachains/customize-runtime/#starting-templates){target=\\_blank} designed to help you quickly start building your own blockchain. Each template offers a different level of configuration, from minimal setups to feature-rich environments, allowing you to choose the foundation that best fits your project's needs.\n\nAmong these, the [Parachain Template](https://github.com/paritytech/polkadot-sdk-parachain-template){target=\\_blank} provides a preconfigured runtime with commonly used pallets, making it an ideal starting point for most parachain development projects.\n\nThis guide walks you through the full process of working with this template. You will:\n\n- Set up the Polkadot SDK Parachain Template.\n- Understand the project structure and key components.\n- Verify your template is ready for development.\n- Run the parachain template locally in development mode.\n\nBy the end of this guide, you'll have a working template ready to customize and deploy as a parachain."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 1141, "end_char": 2131, "estimated_token_count": 240, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore getting started, ensure you have done the following:\n\n- Completed the [Install Polkadot SDK Dependencies](/reference/tools/polkadot-sdk/install/){target=\\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\\_blank} and the required packages to set up your development environment\n\nFor this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version.\n\nRun the following commands to set up the correct Rust version:\n\n=== \"macOS\"\n\n ```bash\n rustup install 1.86\n rustup default 1.86\n rustup target add wasm32-unknown-unknown --toolchain 1.86-aarch64-apple-darwin\n rustup component add rust-src --toolchain 1.86-aarch64-apple-darwin\n ```\n\n=== \"Ubuntu\"\n\n ```bash\n rustup toolchain install 1.86.0\n rustup default 1.86.0\n rustup target add wasm32-unknown-unknown --toolchain 1.86.0\n rustup component add rust-src --toolchain 1.86.0\n ```"} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 2, "depth": 2, "title": "Polkadot SDK Utility Tools", "anchor": "polkadot-sdk-utility-tools", "start_char": 2131, "end_char": 3316, "estimated_token_count": 293, "token_estimator": "heuristic-v1", "text": "## Polkadot SDK Utility Tools\n\nThis tutorial requires two essential tools:\n\n- [**Chain spec builder**](https://crates.io/crates/staging-chain-spec-builder/10.0.0){target=\\_blank}: A Polkadot SDK utility for generating chain specifications. Refer to the [Generate Chain Specs](/develop/parachains/deployment/generate-chain-specs/){target=\\_blank} documentation for detailed usage.\n \n Install it by executing the following command:\n \n ```bash\n cargo install --locked staging-chain-spec-builder@10.0.0\n ```\n\n This command installs the `chain-spec-builder` binary.\n\n- [**Polkadot Omni Node**](https://crates.io/crates/polkadot-omni-node/0.5.0){target=\\_blank}: A white-labeled binary, released as a part of Polkadot SDK that can act as the collator of a parachain in production, with all the related auxiliary functionalities that a normal collator node has: RPC server, archiving state, etc. Moreover, it can also run the Wasm blob of the parachain locally for testing and development.\n\n To install it, run the following command:\n\n ```bash\n cargo install --locked polkadot-omni-node@0.5.0\n ```\n\n This command installs the `polkadot-omni-node` binary."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 3, "depth": 2, "title": "Clone the Template", "anchor": "clone-the-template", "start_char": 3316, "end_char": 3889, "estimated_token_count": 142, "token_estimator": "heuristic-v1", "text": "## Clone the Template\n\nThe [Polkadot SDK Parachain Template](https://github.com/paritytech/polkadot-sdk-parachain-template){target=\\_blank} provides a ready-to-use development environment for building with the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\\_blank}. Follow these steps to set up the template:\n\n1. Clone the template repository:\n\n ```bash\n git clone https://github.com/paritytech/polkadot-sdk-parachain-template.git parachain-template\n ```\n\n2. Navigate into the project directory:\n\n ```bash\n cd parachain-template\n ```"} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 4, "depth": 2, "title": "Explore the Project Structure", "anchor": "explore-the-project-structure", "start_char": 3889, "end_char": 5114, "estimated_token_count": 244, "token_estimator": "heuristic-v1", "text": "## Explore the Project Structure\n\nBefore building the template, take a moment to familiarize yourself with its structure. Understanding this organization will help you navigate the codebase as you develop your parachain.\n\nThe template follows a standard Polkadot SDK project layout:\n\n```text\nparachain-template/\n├── node/ # Node implementation and client\n├── pallets/ # Custom pallets for your parachain\n├── runtime/ # Runtime configuration and logic\n├── Cargo.toml # Workspace configuration\n└── README.md # Documentation\n```\n\nKey directories explained:\n\n- **runtime/**: Contains your parachain's state transition function and pallet configuration. This is where you'll define what your blockchain can do.\n- **node/**: Houses the client implementation that runs your blockchain, handles networking, and manages the database.\n- **pallets/**: Where you'll create custom business logic modules (pallets) for your specific use case.\n- **Cargo.toml**: The workspace configuration that ties all components together.\n\n!!!note\n The runtime is compiled to WebAssembly (Wasm), enabling forkless upgrades. The node binary remains constant while the runtime can be updated on-chain."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 5, "depth": 2, "title": "Compile the Runtime", "anchor": "compile-the-runtime", "start_char": 5114, "end_char": 6078, "estimated_token_count": 189, "token_estimator": "heuristic-v1", "text": "## Compile the Runtime\n\nNow that you understand the template structure, let's compile the runtime to ensure everything is working correctly.\n\n1. Compile the runtime:\n\n ```bash\n cargo build --release --locked\n ```\n\n !!!tip\n Initial compilation may take several minutes, depending on your machine specifications. Use the `--release` flag for improved runtime performance compared to the default `--debug` build. If you need to troubleshoot issues, the `--debug` build provides better diagnostics.\n \n For production deployments, consider using a dedicated `--profile production` flag - this can provide an additional 15-30% performance improvement over the standard `--release` profile.\n\n2. Upon successful compilation, you should see output indicating the build was successful. The compiled runtime will be located at:\n \n `./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm`"} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 6, "depth": 2, "title": "Verify the Build", "anchor": "verify-the-build", "start_char": 6078, "end_char": 6411, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "## Verify the Build\n\nAfter compilation completes, verify that the runtime was created successfully by checking for the Wasm blob:\n\n```bash\nls -la ./target/release/wbuild/parachain-template-runtime/\n```\n\nYou should see the `parachain_template_runtime.compact.compressed.wasm` file in the output, confirming the build was successful."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 7, "depth": 2, "title": "Run the Node Locally", "anchor": "run-the-node-locally", "start_char": 6411, "end_char": 8125, "estimated_token_count": 343, "token_estimator": "heuristic-v1", "text": "## Run the Node Locally\n\nAfter successfully compiling your runtime, you can spin up a local chain and produce blocks. This process will start your local parachain using the Polkadot Omni Node and allow you to interact with it. You'll first need to generate a chain specification that defines your network's identity, initial connections, and genesis state, providing the foundational configuration for how your nodes connect and what initial state they agree upon.\n\nFollow these steps to launch your node in development mode:\n\n1. Generate the chain specification file of your parachain:\n\n ```bash\n chain-spec-builder create -t development \\\n --relay-chain paseo \\\n --para-id 1000 \\\n --runtime ./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm \\\n named-preset development\n ```\n\n2. Start the Omni Node with the generated chain spec. You'll start it in development mode (without a relay chain config), producing and finalizing blocks:\n\n ```bash\n polkadot-omni-node --chain ./chain_spec.json --dev\n ```\n\n The `--dev` option does the following:\n\n - Deletes all active data (keys, blockchain database, networking information) when stopped.\n - Ensures a clean working state each time you restart the node.\n\n3. Verify that your node is running by reviewing the terminal output. You should see log messages indicating block production and finalization.\n\n4. Confirm that your blockchain is producing new blocks by checking if the number after `finalized` is increasing in the output.\n\nThe details of the log output will be explored in a later tutorial. For now, knowing that your node is running and producing blocks is sufficient."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 8, "depth": 2, "title": "Interact with the Node", "anchor": "interact-with-the-node", "start_char": 8125, "end_char": 9694, "estimated_token_count": 414, "token_estimator": "heuristic-v1", "text": "## Interact with the Node\n\nWhen running the template node, it's accessible by default at `ws://localhost:9944`. To interact with your node using the [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} interface, follow these steps:\n\n1. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} in your web browser and click the network icon (which should be the Polkadot logo) in the top left corner:\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-01.webp)\n\n2. Connect to your local node:\n\n 1. Scroll to the bottom and select **Development**.\n 2. Choose **Custom**.\n 3. Enter `ws**: //localhost:9944` in the **custom endpoint** input field.\n 4. Click the **Switch** button.\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-02.webp)\n\n3. Once connected, you should see **parachain-template-runtime** in the top left corner, with the interface displaying information about your local blockchain.\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-03.webp)\n\nYou are now connected to your local node and can interact with it through the Polkadot.js Apps interface. This tool enables you to explore blocks, execute transactions, and interact with your blockchain's features. For in-depth guidance on using the interface effectively, refer to the [Polkadot.js Guides](https://wiki.polkadot.com/general/polkadotjs/){target=\\_blank} available on the Polkadot Wiki."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 9, "depth": 2, "title": "Stop the Node", "anchor": "stop-the-node", "start_char": 9694, "end_char": 10200, "estimated_token_count": 115, "token_estimator": "heuristic-v1", "text": "## Stop the Node\n\nWhen you're done exploring your local node, you can stop it to remove any state changes you've made. Since you started the node with the `--dev` option, stopping the node will purge all persistent block data, allowing you to start fresh the next time.\n\nTo stop the local node:\n\n1. Return to the terminal window where the node output is displayed.\n2. Press `Control-C` to stop the running process.\n3. Verify that your terminal returns to the prompt in the `parachain-template` directory."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 10, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 10200, "end_char": 10608, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Tutorial __Deploy to Polkadot__\n\n ---\n\n Learn how to deploy your parachain template to a relay chain testnet. Configure your chain specification, register as a parachain, and start producing blocks.\n\n [:octicons-arrow-right-24: Get Started](/parachains/launch-a-parachain/deploy-to-polkadot.md)\n\n
"} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 1141, "end_char": 2114, "estimated_token_count": 238, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore getting started, ensure you have done the following:\n\n- Completed the [Install Polkadot SDK](/parachains/install-polkadot-sdk/){target=\\_blank} guide and successfully installed [Rust](https://www.rust-lang.org/){target=\\_blank} and the required packages to set up your development environment.\n\nFor this tutorial series, you need to use Rust `1.86`. Newer versions of the compiler may not work with this parachain template version.\n\nRun the following commands to set up the correct Rust version:\n\n=== \"macOS\"\n\n ```bash\n rustup install 1.86\n rustup default 1.86\n rustup target add wasm32-unknown-unknown --toolchain 1.86-aarch64-apple-darwin\n rustup component add rust-src --toolchain 1.86-aarch64-apple-darwin\n ```\n\n=== \"Ubuntu\"\n\n ```bash\n rustup toolchain install 1.86.0\n rustup default 1.86.0\n rustup target add wasm32-unknown-unknown --toolchain 1.86.0\n rustup component add rust-src --toolchain 1.86.0\n ```"} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 2, "depth": 2, "title": "Polkadot SDK Utility Tools", "anchor": "polkadot-sdk-utility-tools", "start_char": 2114, "end_char": 3299, "estimated_token_count": 293, "token_estimator": "heuristic-v1", "text": "## Polkadot SDK Utility Tools\n\nThis tutorial requires two essential tools:\n\n- [**Chain spec builder**](https://crates.io/crates/staging-chain-spec-builder/10.0.0){target=\\_blank}: A Polkadot SDK utility for generating chain specifications. Refer to the [Generate Chain Specs](/develop/parachains/deployment/generate-chain-specs/){target=\\_blank} documentation for detailed usage.\n \n Install it by executing the following command:\n \n ```bash\n cargo install --locked staging-chain-spec-builder@10.0.0\n ```\n\n This command installs the `chain-spec-builder` binary.\n\n- [**Polkadot Omni Node**](https://crates.io/crates/polkadot-omni-node/0.5.0){target=\\_blank}: A white-labeled binary, released as a part of Polkadot SDK that can act as the collator of a parachain in production, with all the related auxiliary functionalities that a normal collator node has: RPC server, archiving state, etc. Moreover, it can also run the Wasm blob of the parachain locally for testing and development.\n\n To install it, run the following command:\n\n ```bash\n cargo install --locked polkadot-omni-node@0.5.0\n ```\n\n This command installs the `polkadot-omni-node` binary."} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 3, "depth": 2, "title": "Clone the Template", "anchor": "clone-the-template", "start_char": 3299, "end_char": 3872, "estimated_token_count": 142, "token_estimator": "heuristic-v1", "text": "## Clone the Template\n\nThe [Polkadot SDK Parachain Template](https://github.com/paritytech/polkadot-sdk-parachain-template){target=\\_blank} provides a ready-to-use development environment for building with the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\\_blank}. Follow these steps to set up the template:\n\n1. Clone the template repository:\n\n ```bash\n git clone https://github.com/paritytech/polkadot-sdk-parachain-template.git parachain-template\n ```\n\n2. Navigate into the project directory:\n\n ```bash\n cd parachain-template\n ```"} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 4, "depth": 2, "title": "Explore the Project Structure", "anchor": "explore-the-project-structure", "start_char": 3872, "end_char": 5097, "estimated_token_count": 244, "token_estimator": "heuristic-v1", "text": "## Explore the Project Structure\n\nBefore building the template, take a moment to familiarize yourself with its structure. Understanding this organization will help you navigate the codebase as you develop your parachain.\n\nThe template follows a standard Polkadot SDK project layout:\n\n```text\nparachain-template/\n├── node/ # Node implementation and client\n├── pallets/ # Custom pallets for your parachain\n├── runtime/ # Runtime configuration and logic\n├── Cargo.toml # Workspace configuration\n└── README.md # Documentation\n```\n\nKey directories explained:\n\n- **runtime/**: Contains your parachain's state transition function and pallet configuration. This is where you'll define what your blockchain can do.\n- **node/**: Houses the client implementation that runs your blockchain, handles networking, and manages the database.\n- **pallets/**: Where you'll create custom business logic modules (pallets) for your specific use case.\n- **Cargo.toml**: The workspace configuration that ties all components together.\n\n!!!note\n The runtime is compiled to WebAssembly (Wasm), enabling forkless upgrades. The node binary remains constant while the runtime can be updated on-chain."} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 5, "depth": 2, "title": "Compile the Runtime", "anchor": "compile-the-runtime", "start_char": 5097, "end_char": 6061, "estimated_token_count": 189, "token_estimator": "heuristic-v1", "text": "## Compile the Runtime\n\nNow that you understand the template structure, let's compile the runtime to ensure everything is working correctly.\n\n1. Compile the runtime:\n\n ```bash\n cargo build --release --locked\n ```\n\n !!!tip\n Initial compilation may take several minutes, depending on your machine specifications. Use the `--release` flag for improved runtime performance compared to the default `--debug` build. If you need to troubleshoot issues, the `--debug` build provides better diagnostics.\n \n For production deployments, consider using a dedicated `--profile production` flag - this can provide an additional 15-30% performance improvement over the standard `--release` profile.\n\n2. Upon successful compilation, you should see output indicating the build was successful. The compiled runtime will be located at:\n \n `./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm`"} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 6, "depth": 2, "title": "Verify the Build", "anchor": "verify-the-build", "start_char": 6061, "end_char": 6394, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "## Verify the Build\n\nAfter compilation completes, verify that the runtime was created successfully by checking for the Wasm blob:\n\n```bash\nls -la ./target/release/wbuild/parachain-template-runtime/\n```\n\nYou should see the `parachain_template_runtime.compact.compressed.wasm` file in the output, confirming the build was successful."} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 7, "depth": 2, "title": "Run the Node Locally", "anchor": "run-the-node-locally", "start_char": 6394, "end_char": 8108, "estimated_token_count": 343, "token_estimator": "heuristic-v1", "text": "## Run the Node Locally\n\nAfter successfully compiling your runtime, you can spin up a local chain and produce blocks. This process will start your local parachain using the Polkadot Omni Node and allow you to interact with it. You'll first need to generate a chain specification that defines your network's identity, initial connections, and genesis state, providing the foundational configuration for how your nodes connect and what initial state they agree upon.\n\nFollow these steps to launch your node in development mode:\n\n1. Generate the chain specification file of your parachain:\n\n ```bash\n chain-spec-builder create -t development \\\n --relay-chain paseo \\\n --para-id 1000 \\\n --runtime ./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm \\\n named-preset development\n ```\n\n2. Start the Omni Node with the generated chain spec. You'll start it in development mode (without a relay chain config), producing and finalizing blocks:\n\n ```bash\n polkadot-omni-node --chain ./chain_spec.json --dev\n ```\n\n The `--dev` option does the following:\n\n - Deletes all active data (keys, blockchain database, networking information) when stopped.\n - Ensures a clean working state each time you restart the node.\n\n3. Verify that your node is running by reviewing the terminal output. You should see log messages indicating block production and finalization.\n\n4. Confirm that your blockchain is producing new blocks by checking if the number after `finalized` is increasing in the output.\n\nThe details of the log output will be explored in a later tutorial. For now, knowing that your node is running and producing blocks is sufficient."} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 8, "depth": 2, "title": "Interact with the Node", "anchor": "interact-with-the-node", "start_char": 8108, "end_char": 9677, "estimated_token_count": 414, "token_estimator": "heuristic-v1", "text": "## Interact with the Node\n\nWhen running the template node, it's accessible by default at `ws://localhost:9944`. To interact with your node using the [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} interface, follow these steps:\n\n1. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} in your web browser and click the network icon (which should be the Polkadot logo) in the top left corner:\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-01.webp)\n\n2. Connect to your local node:\n\n 1. Scroll to the bottom and select **Development**.\n 2. Choose **Custom**.\n 3. Enter `ws**: //localhost:9944` in the **custom endpoint** input field.\n 4. Click the **Switch** button.\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-02.webp)\n\n3. Once connected, you should see **parachain-template-runtime** in the top left corner, with the interface displaying information about your local blockchain.\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-03.webp)\n\nYou are now connected to your local node and can interact with it through the Polkadot.js Apps interface. This tool enables you to explore blocks, execute transactions, and interact with your blockchain's features. For in-depth guidance on using the interface effectively, refer to the [Polkadot.js Guides](https://wiki.polkadot.com/general/polkadotjs/){target=\\_blank} available on the Polkadot Wiki."} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 9, "depth": 2, "title": "Stop the Node", "anchor": "stop-the-node", "start_char": 9677, "end_char": 10183, "estimated_token_count": 115, "token_estimator": "heuristic-v1", "text": "## Stop the Node\n\nWhen you're done exploring your local node, you can stop it to remove any state changes you've made. Since you started the node with the `--dev` option, stopping the node will purge all persistent block data, allowing you to start fresh the next time.\n\nTo stop the local node:\n\n1. Return to the terminal window where the node output is displayed.\n2. Press `Control-C` to stop the running process.\n3. Verify that your terminal returns to the prompt in the `parachain-template` directory."} +{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 10, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 10183, "end_char": 10591, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Tutorial __Deploy to Polkadot__\n\n ---\n\n Learn how to deploy your parachain template to a relay chain testnet. Configure your chain specification, register as a parachain, and start producing blocks.\n\n [:octicons-arrow-right-24: Get Started](/parachains/launch-a-parachain/deploy-to-polkadot.md)\n\n
"} {"page_id": "parachains-runtime-maintenance-runtime-upgrades", "page_title": "Runtime Upgrades", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 20, "end_char": 926, "estimated_token_count": 147, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nOne of the defining features of Polkadot SDK-based blockchains is the ability to perform forkless runtime upgrades. Unlike traditional blockchains, which require hard forks and node coordination for upgrades, Polkadot networks enable seamless updates without network disruption.\n\nForkless upgrades are achieved through WebAssembly (Wasm) runtimes stored on-chain, which can be securely swapped and upgraded as part of the blockchain's state. By leveraging decentralized consensus, runtime updates can happen trustlessly, ensuring continuous improvement and evolution without halting operations.\n\nThis guide explains how Polkadot's runtime versioning, Wasm deployment, and storage migrations enable these upgrades, ensuring the blockchain evolves smoothly and securely. You'll also learn how different upgrade processes apply to solo chains and parachains, depending on the network setup."} {"page_id": "parachains-runtime-maintenance-runtime-upgrades", "page_title": "Runtime Upgrades", "index": 1, "depth": 2, "title": "How Runtime Upgrades Work", "anchor": "how-runtime-upgrades-work", "start_char": 926, "end_char": 1650, "estimated_token_count": 165, "token_estimator": "heuristic-v1", "text": "## How Runtime Upgrades Work\n\nIn FRAME, the [`system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\\_blank} pallet uses the [`set_code`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/enum.Call.html#variant.set_code){target=\\_blank} extrinsic to update the Wasm code for the runtime. This method allows solo chains to upgrade without disruption. \n\nFor parachains, upgrades are more complex. Parachains must first call `authorize_upgrade`, followed by `apply_authorized_upgrade`, to ensure the relay chain approves and applies the changes. Additionally, changes to current functionality that impact storage often require a [storage migration](#storage-migrations)."} {"page_id": "parachains-runtime-maintenance-runtime-upgrades", "page_title": "Runtime Upgrades", "index": 2, "depth": 3, "title": "Runtime Versioning", "anchor": "runtime-versioning", "start_char": 1650, "end_char": 4915, "estimated_token_count": 664, "token_estimator": "heuristic-v1", "text": "### Runtime Versioning\n\nThe executor is the component that selects the runtime execution environment to communicate with. Although you can override the default execution strategies for custom scenarios, in most cases, the executor selects the appropriate binary to use by evaluating and comparing key parameters from the native and Wasm runtime binaries.\n\nThe runtime includes a [runtime version struct](https://paritytech.github.io/polkadot-sdk/master/sp_version/struct.RuntimeVersion.html){target=\\_blank} to provide the needed parameter information to the executor process. A sample runtime version struct might look as follows:\n\n```rust\npub const VERSION: RuntimeVersion = RuntimeVersion {\n spec_name: create_runtime_str!(\"node-template\"),\n impl_name: create_runtime_str!(\"node-template\"),\n authoring_version: 1,\n spec_version: 1,\n impl_version: 1,\n apis: RUNTIME_API_VERSIONS,\n transaction_version: 1,\n};\n```\n\nThe struct provides the following parameter information to the executor:\n\n- **`spec_name`**: The identifier for the different runtimes.\n- **`impl_name`**: The name of the implementation of the spec. Serves only to differentiate code of different implementation teams.\n- **`authoring_version`**: The version of the authorship interface. An authoring node won't attempt to author blocks unless this is equal to its native runtime.\n- **`spec_version`**: The version of the runtime specification. A full node won't attempt to use its native runtime in substitute for the on-chain Wasm runtime unless the `spec_name`, `spec_version`, and `authoring_version` are all the same between the Wasm and native binaries. Updates to the `spec_version` can be automated as a CI process. This parameter is typically incremented when there's an update to the `transaction_version`.\n- **`impl_version`**: The version of the implementation of the specification. Nodes can ignore this. It is only used to indicate that the code is different. As long as the `authoring_version` and the `spec_version` are the same, the code might have changed, but the native and Wasm binaries do the same thing. In general, only non-logic-breaking optimizations would result in a change of the `impl_version`.\n- **`transaction_version`**: The version of the interface for handling transactions. This parameter can be useful to synchronize firmware updates for hardware wallets or other signing devices to verify that runtime transactions are valid and safe to sign. This number must be incremented if there is a change in the index of the pallets in the `construct_runtime!` macro or if there are any changes to dispatchable functions, such as the number of parameters or parameter types. If `transaction_version` is updated, then the `spec_version` must also be updated.\n- **`apis`**: A list of supported [runtime APIs](https://paritytech.github.io/polkadot-sdk/master/sp_api/macro.impl_runtime_apis.html){target=\\_blank} along with their versions.\n\nThe executor follows the same consensus-driven logic for both the native runtime and the Wasm runtime before deciding which to execute. Because runtime versioning is a manual process, there is a risk that the executor could make incorrect decisions if the runtime version is misrepresented or incorrectly defined."} @@ -1115,15 +1093,14 @@ {"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 10, "depth": 3, "title": "Handling Foreign Assets", "anchor": "handling-foreign-assets", "start_char": 10290, "end_char": 11225, "estimated_token_count": 166, "token_estimator": "heuristic-v1", "text": "### Handling Foreign Assets\n\nThe Foreign Assets pallet, an instance of the Assets pallet, manages these assets. Since foreign assets are integrated into the same interface as native assets, developers can use the same functionalities, such as transferring and querying balances. However, there are important distinctions when dealing with foreign assets.\n\n- **Asset identifier**: Unlike native assets, foreign assets are identified using an XCM Multilocation rather than a simple numeric `AssetId`. This multilocation identifier represents the cross-chain location of the asset and provides a standardized way to reference it across different parachains and relay chains.\n\n- **Transfers**: Once registered in the Asset Hub, foreign assets can be transferred between accounts, just like native assets. Users can also send these assets back to their originating blockchain if supported by the relevant cross-chain messaging mechanisms."} {"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 11, "depth": 2, "title": "Integration", "anchor": "integration", "start_char": 11225, "end_char": 11668, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "## Integration\n\nAsset Hub supports a variety of integration tools that make it easy for developers to manage assets and interact with the blockchain in their applications. The tools and libraries provided by Parity Technologies enable streamlined operations, such as querying asset information, building transactions, and monitoring cross-chain asset transfers.\n\nDevelopers can integrate Asset Hub into their projects using these core tools:"} {"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 12, "depth": 3, "title": "API Sidecar", "anchor": "api-sidecar", "start_char": 11668, "end_char": 12511, "estimated_token_count": 211, "token_estimator": "heuristic-v1", "text": "### API Sidecar\n\n[API Sidecar](https://github.com/paritytech/substrate-api-sidecar){target=\\_blank} is a RESTful service that can be deployed alongside Polkadot and Kusama nodes. It provides endpoints to retrieve real-time blockchain data, including asset information. When used with Asset Hub, Sidecar allows querying:\n\n- **Asset look-ups**: Retrieve specific assets using `AssetId`.\n- **Asset balances**: View the balance of a particular asset on Asset Hub.\n\nPublic instances of API Sidecar connected to Asset Hub are available, such as:\n\n- [Polkadot Asset Hub Sidecar](https://polkadot-asset-hub-public-sidecar.parity-chains.parity.io/){target=\\_blank}\n- [Kusama Asset Hub Sidecar](https://kusama-asset-hub-public-sidecar.parity-chains.parity.io/){target=\\_blank}\n\nThese public instances are primarily for ad-hoc testing and quick checks."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 13, "depth": 3, "title": "TxWrapper", "anchor": "txwrapper", "start_char": 12511, "end_char": 13112, "estimated_token_count": 113, "token_estimator": "heuristic-v1", "text": "### TxWrapper\n\n[`TxWrapper`](https://github.com/paritytech/txwrapper-core){target=\\_blank} is a library that simplifies constructing and signing transactions for Polkadot SDK-based chains, including Polkadot and Kusama. This tool includes support for working with Asset Hub, enabling developers to:\n\n- Construct offline transactions.\n- Leverage asset-specific functions such as minting, burning, and transferring assets.\n\n`TxWrapper` provides the flexibility needed to integrate asset operations into custom applications while maintaining the security and efficiency of Polkadot's transaction model."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 14, "depth": 3, "title": "ParaSpell", "anchor": "paraspell", "start_char": 13112, "end_char": 14967, "estimated_token_count": 409, "token_estimator": "heuristic-v1", "text": "### ParaSpell\n\n[ParaSpell](https://paraspell.xyz/){target=\\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are:\n\n- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions.\n- **[XCM API](https://paraspell.xyz/#xcm-api){target=\\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance.\n- **[XCM router](https://paraspell.xyz/#xcm-router){target=\\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar).\n- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging.\n- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow.\n\nParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 15, "depth": 3, "title": "Parachain Node", "anchor": "parachain-node", "start_char": 14967, "end_char": 15620, "estimated_token_count": 131, "token_estimator": "heuristic-v1", "text": "### Parachain Node\n\nTo fully leverage the Asset Hub's functionality, developers will need to run a system parachain node. Setting up an Asset Hub node allows users to interact with the parachain in real time, syncing data and participating in the broader Polkadot ecosystem. Guidelines for setting up an [Asset Hub node](https://github.com/paritytech/polkadot-sdk/tree/polkadot-stable2506-2/cumulus#asset-hub-){target=\\_blank} are available in the Parity documentation.\n\nUsing these integration tools, developers can manage assets seamlessly and integrate Asset Hub functionality into their applications, leveraging Polkadot's powerful infrastructure."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 16, "depth": 2, "title": "XCM Transfer Monitoring", "anchor": "xcm-transfer-monitoring", "start_char": 15620, "end_char": 15963, "estimated_token_count": 56, "token_estimator": "heuristic-v1", "text": "## XCM Transfer Monitoring\n\nSince Asset Hub facilitates cross-chain asset transfers across the Polkadot ecosystem, XCM transfer monitoring becomes an essential practice for developers and infrastructure providers. This section outlines how to monitor the cross-chain movement of assets between parachains, the relay chain, and other systems."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 17, "depth": 3, "title": "Monitor XCM Deposits", "anchor": "monitor-xcm-deposits", "start_char": 15963, "end_char": 16755, "estimated_token_count": 160, "token_estimator": "heuristic-v1", "text": "### Monitor XCM Deposits\n\nAs assets move between chains, tracking the cross-chain transfers in real time is crucial. Whether assets are transferred via a teleport from system parachains or through a reserve-backed transfer from any other parachain, each transfer emits a relevant event (such as the `balances.minted` event).\n\nTo ensure accurate monitoring of these events:\n\n- **Track XCM deposits**: Query every new block created in the relay chain or Asset Hub, loop through the events array, and filter for any `balances.minted` events which confirm the asset was successfully transferred to the account.\n- **Track event origins**: Each `balances.minted` event points to a specific address. By monitoring this, service providers can verify that assets have arrived in the correct account."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 18, "depth": 3, "title": "Track XCM Information Back to the Source", "anchor": "track-xcm-information-back-to-the-source", "start_char": 16755, "end_char": 17422, "estimated_token_count": 146, "token_estimator": "heuristic-v1", "text": "### Track XCM Information Back to the Source\n\nWhile the `balances.minted` event confirms the arrival of assets, there may be instances where you need to trace the origin of the cross-chain message that triggered the event. In such cases, you can:\n\n1. Query the relevant chain at the block where the `balances.minted` event was emitted.\n2. Look for a `messageQueue(Processed)` event within that block's initialization. This event contains a parameter (`Id`) that identifies the cross-chain message received by the relay chain or Asset Hub. You can use this `Id` to trace the message back to its origin chain, offering full visibility of the asset transfer's journey."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 19, "depth": 3, "title": "Practical Monitoring Examples", "anchor": "practical-monitoring-examples", "start_char": 17422, "end_char": 18233, "estimated_token_count": 163, "token_estimator": "heuristic-v1", "text": "### Practical Monitoring Examples\n\nThe preceding sections outline the process of monitoring XCM deposits to specific accounts and then tracing back the origin of these deposits. The process of tracking an XCM transfer and the specific events to monitor may vary based on the direction of the XCM message. Here are some examples to showcase the slight differences:\n\n- **Transfer from parachain to relay chain**: Track `parachainsystem(UpwardMessageSent)` on the parachain and `messagequeue(Processed)` on the relay chain.\n- **Transfer from relay chain to parachain**: Track `xcmPallet(sent)` on the relay chain and `dmpqueue(ExecutedDownward)` on the parachain.\n- **Transfer between parachains**: Track `xcmpqueue(XcmpMessageSent)` on the system parachain and `xcmpqueue(Success)` on the destination parachain."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 20, "depth": 3, "title": "Monitor for Failed XCM Transfers", "anchor": "monitor-for-failed-xcm-transfers", "start_char": 18233, "end_char": 19041, "estimated_token_count": 176, "token_estimator": "heuristic-v1", "text": "### Monitor for Failed XCM Transfers\n\nSometimes, XCM transfers may fail due to liquidity or other errors. Failed transfers emit specific error events, which are key to resolving issues in asset transfers. Monitoring for these failure events helps catch issues before they affect asset balances.\n\n- **Relay chain to system parachain**: Look for the `dmpqueue(ExecutedDownward)` event on the parachain with an `Incomplete` outcome and an error type such as `UntrustedReserveLocation`.\n- **Parachain to parachain**: Monitor for `xcmpqueue(Fail)` on the destination parachain with error types like `TooExpensive`.\n\nFor detailed error management in XCM, see Gavin Wood's blog post on [XCM Execution and Error Management](https://polkadot.com/blog/xcm-part-three-execution-and-error-management/){target=\\_blank}."} -{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 21, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 19041, "end_char": 20065, "estimated_token_count": 244, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Tutorial __Register a Local Asset__\n\n ---\n\n Comprehensive guide to registering a local asset on the Asset Hub system parachain, including step-by-step instructions.\n\n [:octicons-arrow-right-24: Reference](/chain-interactions/token-operations/register-local-asset/)\n\n- Tutorial __Register a Foreign Asset__\n\n ---\n\n An in-depth guide to registering a foreign asset on the Asset Hub parachain, providing clear, step-by-step instructions.\n\n [:octicons-arrow-right-24: Reference](/chain-interactions/token-operations/register-foreign-asset/)\n\n- Tutorial __Convert Assets__\n\n ---\n\n A guide detailing the step-by-step process of converting assets on Asset Hub, helping users efficiently navigate asset management on the platform.\n\n [:octicons-arrow-right-24: Reference](/chain-interactions/token-operations/convert-assets/)\n\n
"} +{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 13, "depth": 3, "title": "TxWrapper", "anchor": "txwrapper", "start_char": 12511, "end_char": 13113, "estimated_token_count": 113, "token_estimator": "heuristic-v1", "text": "### TxWrapper\n\n[`TxWrapper`](https://github.com/paritytech/txwrapper-core){target=\\_blank} is a library that simplifies constructing and signing transactions for Polkadot SDK-based chains, including Polkadot and Kusama. This tool includes support for working with Asset Hub, enabling developers to:\n\n- Construct offline transactions.\n- Leverage asset-specific functions such as minting, burning, and transferring assets.\n\n`TxWrapper` provides the flexibility needed to integrate asset operations into custom applications while maintaining the security and efficiency of Polkadot's transaction model."} +{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 14, "depth": 3, "title": "Parachain Node", "anchor": "parachain-node", "start_char": 13113, "end_char": 13766, "estimated_token_count": 131, "token_estimator": "heuristic-v1", "text": "### Parachain Node\n\nTo fully leverage the Asset Hub's functionality, developers will need to run a system parachain node. Setting up an Asset Hub node allows users to interact with the parachain in real time, syncing data and participating in the broader Polkadot ecosystem. Guidelines for setting up an [Asset Hub node](https://github.com/paritytech/polkadot-sdk/tree/polkadot-stable2506-2/cumulus#asset-hub-){target=\\_blank} are available in the Parity documentation.\n\nUsing these integration tools, developers can manage assets seamlessly and integrate Asset Hub functionality into their applications, leveraging Polkadot's powerful infrastructure."} +{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 15, "depth": 2, "title": "XCM Transfer Monitoring", "anchor": "xcm-transfer-monitoring", "start_char": 13766, "end_char": 14109, "estimated_token_count": 56, "token_estimator": "heuristic-v1", "text": "## XCM Transfer Monitoring\n\nSince Asset Hub facilitates cross-chain asset transfers across the Polkadot ecosystem, XCM transfer monitoring becomes an essential practice for developers and infrastructure providers. This section outlines how to monitor the cross-chain movement of assets between parachains, the relay chain, and other systems."} +{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 16, "depth": 3, "title": "Monitor XCM Deposits", "anchor": "monitor-xcm-deposits", "start_char": 14109, "end_char": 14901, "estimated_token_count": 160, "token_estimator": "heuristic-v1", "text": "### Monitor XCM Deposits\n\nAs assets move between chains, tracking the cross-chain transfers in real time is crucial. Whether assets are transferred via a teleport from system parachains or through a reserve-backed transfer from any other parachain, each transfer emits a relevant event (such as the `balances.minted` event).\n\nTo ensure accurate monitoring of these events:\n\n- **Track XCM deposits**: Query every new block created in the relay chain or Asset Hub, loop through the events array, and filter for any `balances.minted` events which confirm the asset was successfully transferred to the account.\n- **Track event origins**: Each `balances.minted` event points to a specific address. By monitoring this, service providers can verify that assets have arrived in the correct account."} +{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 17, "depth": 3, "title": "Track XCM Information Back to the Source", "anchor": "track-xcm-information-back-to-the-source", "start_char": 14901, "end_char": 15568, "estimated_token_count": 146, "token_estimator": "heuristic-v1", "text": "### Track XCM Information Back to the Source\n\nWhile the `balances.minted` event confirms the arrival of assets, there may be instances where you need to trace the origin of the cross-chain message that triggered the event. In such cases, you can:\n\n1. Query the relevant chain at the block where the `balances.minted` event was emitted.\n2. Look for a `messageQueue(Processed)` event within that block's initialization. This event contains a parameter (`Id`) that identifies the cross-chain message received by the relay chain or Asset Hub. You can use this `Id` to trace the message back to its origin chain, offering full visibility of the asset transfer's journey."} +{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 18, "depth": 3, "title": "Practical Monitoring Examples", "anchor": "practical-monitoring-examples", "start_char": 15568, "end_char": 16379, "estimated_token_count": 163, "token_estimator": "heuristic-v1", "text": "### Practical Monitoring Examples\n\nThe preceding sections outline the process of monitoring XCM deposits to specific accounts and then tracing back the origin of these deposits. The process of tracking an XCM transfer and the specific events to monitor may vary based on the direction of the XCM message. Here are some examples to showcase the slight differences:\n\n- **Transfer from parachain to relay chain**: Track `parachainsystem(UpwardMessageSent)` on the parachain and `messagequeue(Processed)` on the relay chain.\n- **Transfer from relay chain to parachain**: Track `xcmPallet(sent)` on the relay chain and `dmpqueue(ExecutedDownward)` on the parachain.\n- **Transfer between parachains**: Track `xcmpqueue(XcmpMessageSent)` on the system parachain and `xcmpqueue(Success)` on the destination parachain."} +{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 19, "depth": 3, "title": "Monitor for Failed XCM Transfers", "anchor": "monitor-for-failed-xcm-transfers", "start_char": 16379, "end_char": 17187, "estimated_token_count": 176, "token_estimator": "heuristic-v1", "text": "### Monitor for Failed XCM Transfers\n\nSometimes, XCM transfers may fail due to liquidity or other errors. Failed transfers emit specific error events, which are key to resolving issues in asset transfers. Monitoring for these failure events helps catch issues before they affect asset balances.\n\n- **Relay chain to system parachain**: Look for the `dmpqueue(ExecutedDownward)` event on the parachain with an `Incomplete` outcome and an error type such as `UntrustedReserveLocation`.\n- **Parachain to parachain**: Monitor for `xcmpqueue(Fail)` on the destination parachain with error types like `TooExpensive`.\n\nFor detailed error management in XCM, see Gavin Wood's blog post on [XCM Execution and Error Management](https://polkadot.com/blog/xcm-part-three-execution-and-error-management/){target=\\_blank}."} +{"page_id": "reference-polkadot-hub-assets-and-smart-contracts", "page_title": "Asset Hub", "index": 20, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 17187, "end_char": 18211, "estimated_token_count": 244, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Tutorial __Register a Local Asset__\n\n ---\n\n Comprehensive guide to registering a local asset on the Asset Hub system parachain, including step-by-step instructions.\n\n [:octicons-arrow-right-24: Reference](/chain-interactions/token-operations/register-local-asset/)\n\n- Tutorial __Register a Foreign Asset__\n\n ---\n\n An in-depth guide to registering a foreign asset on the Asset Hub parachain, providing clear, step-by-step instructions.\n\n [:octicons-arrow-right-24: Reference](/chain-interactions/token-operations/register-foreign-asset/)\n\n- Tutorial __Convert Assets__\n\n ---\n\n A guide detailing the step-by-step process of converting assets on Asset Hub, helping users efficiently navigate asset management on the platform.\n\n [:octicons-arrow-right-24: Reference](/chain-interactions/token-operations/convert-assets/)\n\n
"} {"page_id": "reference-polkadot-hub-bridging", "page_title": "Bridge Hub", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 14, "end_char": 1065, "estimated_token_count": 184, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThe Bridge Hub system parachain plays a crucial role in facilitating trustless interactions between Polkadot, Kusama, Ethereum, and other blockchain ecosystems. By implementing on-chain light clients and supporting protocols like BEEFY and GRANDPA, Bridge Hub ensures seamless message transmission and state verification across chains. It also provides essential [pallets](/reference/glossary/#pallet){target=\\_blank} for sending and receiving messages, making it a cornerstone of Polkadot’s interoperability framework. With built-in support for XCM (Cross-Consensus Messaging), Bridge Hub enables secure, efficient communication between diverse blockchain networks.\n\nThis guide covers the architecture, components, and deployment of the Bridge Hub system. You'll explore its trustless bridging mechanisms, key pallets for various blockchains, and specific implementations like Snowbridge and the Polkadot <> Kusama bridge. By the end, you'll understand how Bridge Hub enhances connectivity within the Polkadot ecosystem and beyond."} {"page_id": "reference-polkadot-hub-bridging", "page_title": "Bridge Hub", "index": 1, "depth": 2, "title": "Trustless Bridging", "anchor": "trustless-bridging", "start_char": 1065, "end_char": 2671, "estimated_token_count": 313, "token_estimator": "heuristic-v1", "text": "## Trustless Bridging\n\nBridge Hub provides a mode of trustless bridging through its implementation of on-chain light clients and trustless relayers. Trustless bridges are essentially two one-way bridges, where each chain has a method of verifying the state of the other in a trustless manner through consensus proofs. In this context, \"trustless\" refers to the lack of need to trust a human when interacting with various system components. Trustless systems are based instead on trusting mathematics, cryptography, and code. The target chain and source chain both provide ways of verifying one another's state and actions (such as a transfer) based on the consensus and finality of both chains rather than an external mechanism controlled by a third party.\n\n[BEEFY (Bridge Efficiency Enabling Finality Yielder)](/reference/polkadot-hub/consensus-and-security/pos-consensus/#bridging-beefy){target=\\_blank} is instrumental in this solution. It provides a more efficient way to verify the consensus on the relay chain. It allows the participants in a network to verify finality proofs, meaning a remote chain like Ethereum can verify the state of Polkadot at a given block height. \n\nFor example, the Ethereum and Polkadot bridging solution that [Snowbridge](https://docs.snowbridge.network/){target=\\_blank} implements involves two light clients: one which verifies the state of Polkadot and the other which verifies the state of Ethereum. The light client for Polkadot is implemented in the runtime as a pallet, whereas the light client for Ethereum is implemented as a smart contract on the beacon chain."} {"page_id": "reference-polkadot-hub-bridging", "page_title": "Bridge Hub", "index": 2, "depth": 2, "title": "Bridging Components", "anchor": "bridging-components", "start_char": 2671, "end_char": 3623, "estimated_token_count": 242, "token_estimator": "heuristic-v1", "text": "## Bridging Components\n\nIn any given Bridge Hub implementation (Kusama, Polkadot, or other relay chains), there are a few primary pallets that are utilized:\n\n- **[Pallet Bridge GRANDPA](https://paritytech.github.io/polkadot-sdk/master/pallet_bridge_grandpa/index.html){target=\\_blank}**: An on-chain GRANDPA light client for Substrate based chains.\n- **[Pallet Bridge Parachains](https://paritytech.github.io/polkadot-sdk/master/pallet_bridge_parachains/index.html){target=\\_blank}**: A finality module for parachains.\n- **[Pallet Bridge Messages](https://paritytech.github.io/polkadot-sdk/master/pallet_bridge_messages/index.html){target=\\_blank}**: A pallet which allows sending, receiving, and tracking of inbound and outbound messages.\n- **[Pallet XCM Bridge](https://paritytech.github.io/polkadot-sdk/master/pallet_xcm_bridge_hub/index.html){target=\\_blank}**: A pallet which, with the Bridge Messages pallet, adds XCM support to bridge pallets."} @@ -1209,8 +1186,10 @@ {"page_id": "reference-tools-papi", "page_title": "Polkadot-API", "index": 3, "depth": 3, "title": "Reading Chain Data", "anchor": "reading-chain-data", "start_char": 6190, "end_char": 7140, "estimated_token_count": 216, "token_estimator": "heuristic-v1", "text": "### Reading Chain Data\n\nThe `TypedApi` provides a streamlined way to read blockchain data through three main interfaces, each designed for specific data access patterns:\n\n- **Constants**: Access fixed values or configurations on the blockchain using the `constants` interface.\n\n ```typescript\n const version = await typedApi.constants.System.Version();\n ```\n\n- **Storage queries**: Retrieve stored values by querying the blockchain’s storage via the `query` interface.\n\n ```typescript\n const asset = await api.query.ForeignAssets.Asset.getValue(\n token.location,\n { at: 'best' },\n );\n ```\n\n- **Runtime APIs**: Interact directly with runtime APIs using the `apis` interface.\n\n ```typescript\n const metadata = await typedApi.apis.Metadata.metadata();\n ```\n\nTo learn more about the different actions you can perform with the `TypedApi`, refer to the [TypedApi reference](https://papi.how/typed){target=\\_blank}."} {"page_id": "reference-tools-papi", "page_title": "Polkadot-API", "index": 4, "depth": 3, "title": "Sending Transactions", "anchor": "sending-transactions", "start_char": 7140, "end_char": 8815, "estimated_token_count": 355, "token_estimator": "heuristic-v1", "text": "### Sending Transactions\n\nIn PAPI, the `TypedApi` provides the `tx` and `txFromCallData` methods to send transactions. \n\n- The `tx` method allows you to directly send a transaction with the specified parameters by using the `typedApi.tx.Pallet.Call` pattern:\n\n ```typescript\n const tx: Transaction = typedApi.tx.Pallet.Call({arg1, arg2, arg3});\n ``` \n\n For instance, to execute the `balances.transferKeepAlive` call, you can use the following snippet:\n\n ```typescript\n import { MultiAddress } from '@polkadot-api/descriptors';\n\n const tx: Transaction = typedApi.tx.Balances.transfer_keep_alive({\n dest: MultiAddress.Id('INSERT_DESTINATION_ADDRESS'),\n value: BigInt(INSERT_VALUE),\n });\n\n ```\n\n Ensure you replace `INSERT_DESTINATION_ADDRESS` and `INSERT_VALUE` with the actual destination address and value, respectively.\n\n- The `txFromCallData` method allows you to send a transaction using the call data. This option accepts binary call data and constructs the transaction from it. It validates the input upon creation and will throw an error if invalid data is provided. The pattern is as follows:\n\n ```typescript\n const callData = Binary.fromHex('0x...');\n const tx: Transaction = typedApi.txFromCallData(callData);\n ``` \n\n For instance, to execute a transaction using the call data, you can use the following snippet:\n\n ```typescript\n const callData = Binary.fromHex('0x00002470617065726d6f6f6e');\n const tx: Transaction = typedApi.txFromCallData(callData);\n ```\n\nFor more information about sending transactions, refer to the [Transactions](https://papi.how/typed/tx#transactions){target=\\_blank} page."} {"page_id": "reference-tools-papi", "page_title": "Polkadot-API", "index": 5, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 8815, "end_char": 8957, "estimated_token_count": 43, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nFor an in-depth guide on how to use PAPI, refer to the official [PAPI](https://papi.how/){target=\\_blank} documentation."} -{"page_id": "reference-tools-paraspell", "page_title": "ParaSpell XCM SDK", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 21, "end_char": 2099, "estimated_token_count": 498, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[ParaSpell](https://paraspell.github.io/docs/){target=\\_blank} is a comprehensive suite of open-source tools designed to simplify cross-chain interactions within the Polkadot ecosystem. At its core, ParaSpell is dedicated to enhancing the functionality of the [XCM (Cross-Consensus Messaging)](/parachains/interoperability/get-started/){target=\\_blank} protocol by providing developers with a unified and streamlined experience for building interoperable decentralized applications (dApps).\n\nThe primary goal of ParaSpell is to abstract away the complexities of the XCM protocol. While XCM is a powerful feature of the Polkadot network, its implementation can vary significantly between different parachains. ParaSpell addresses this challenge by providing a standardized set of tools that enable developers to easily integrate cross-chain functionality into their applications, saving valuable time and effort. ParaSpell is a \"common good\" software, meaning it is free, open-source, and dedicated to the growth of the Polkadot ecosystem.\n\nThe ParaSpell suite includes:\n\n- **[XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.html){target=\\_blank}**: A powerful library for integrating XCM interoperability into dApps.\n- **[XCM API](https://paraspell.github.io/docs/api/g-started.html){target=\\_blank}**: A lightweight alternative to the SDK for package-less integration.\n- **[XCM Router](https://paraspell.github.io/docs/router/getting-strtd.html){target=\\_blank}**: A tool for enabling cross-chain swaps of different assets in a single transaction.\n- **[XCM Analyser](https://paraspell.github.io/docs/analyser/getng-strtd.html){target=\\_blank}**: A utility for decoding and translating complex XCM data into a human-readable format.\n- **[XCM Visualizator](https://paraspell.github.io/docs/visualizer/getting-start.html){target=\\_blank}**: A tool for visualizing XCM activity across the Polkadot ecosystem.\n- **[XCM Playground](https://paraspell.github.io/docs/tools/playground.html){target=\\_blank}**: A tool for testing different XCM scenarios."} -{"page_id": "reference-tools-paraspell", "page_title": "ParaSpell XCM SDK", "index": 1, "depth": 3, "title": "ParaSpell XCM SDK", "anchor": "paraspell-xcm-sdk", "start_char": 2099, "end_char": 3005, "estimated_token_count": 171, "token_estimator": "heuristic-v1", "text": "### ParaSpell XCM SDK\n\nThe [ParaSpell XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.html){target=\\_blank} is a core component of the ParaSpell toolset and a foundational library for developers looking to leverage XCM in their applications. It is the first and only XCM SDK in the ecosystem to support both PolkadotJS and Polkadot API, providing developers with flexibility and choice.\n\nThe SDK simplifies the process of creating and sending XCM messages by providing a user-friendly builder pattern. This allows developers to construct complex XCM calls with just a few lines of code, reducing the likelihood of errors and ensuring that messages are constructed correctly.\n\nBy using the ParaSpell XCM SDK, developers can significantly accelerate their development workflow and build powerful, interoperable dApps that take full advantage of the Polkadot network's cross-chain capabilities."} +{"page_id": "reference-tools-paraspell", "page_title": "ParaSpell XCM SDK", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 21, "end_char": 2383, "estimated_token_count": 522, "token_estimator": "heuristic-v1", "text": "## Introduction\n\n[ParaSpell](https://paraspell.github.io/docs/){target=\\_blank} is a comprehensive suite of open-source tools designed to simplify cross-chain interactions within the Polkadot ecosystem. At its core, ParaSpell is dedicated to enhancing the functionality of the [XCM (Cross-Consensus Messaging)](/parachains/interoperability/get-started/){target=\\_blank} protocol by providing developers with a unified and streamlined experience for building interoperable decentralized applications (dApps).\n\nThe primary goal of ParaSpell is to abstract away the complexities of the XCM protocol. While XCM is a powerful feature of the Polkadot network, its implementation can vary significantly between different parachains. ParaSpell addresses this challenge by providing a standardized set of tools that enable developers to easily integrate cross-chain functionality into their applications, saving valuable time and effort. ParaSpell is a \"common good\" software, meaning it is free, open-source, and dedicated to the growth of the Polkadot ecosystem.\n\nThe ParaSpell suite includes:\n\n- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions.\n- **[XCM API](https://paraspell.xyz/#xcm-api){target=\\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance.\n- **[XCM Router](https://paraspell.xyz/#xcm-router){target=\\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar).\n- **[XCM Analyser](https://paraspell.xyz/#xcm-analyser){target=\\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging.\n- **[XCM Visualizator](https://paraspell.xyz/#xcm-visualizator){target=\\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow.\n- **[XCM Playground](https://paraspell.xyz/#try-it){target=\\_blank}**: An interactive playground for testing different XCM scenarios."} +{"page_id": "reference-tools-paraspell", "page_title": "ParaSpell XCM SDK", "index": 1, "depth": 3, "title": "ParaSpell XCM SDK", "anchor": "paraspell-xcm-sdk", "start_char": 2383, "end_char": 3290, "estimated_token_count": 171, "token_estimator": "heuristic-v1", "text": "### ParaSpell XCM SDK\n\nThe [ParaSpell XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.html){target=\\_blank} is a core component of the ParaSpell toolset and a foundational library for developers looking to leverage XCM in their applications. It is the first and only XCM SDK in the ecosystem to support both PolkadotJS and Polkadot API, providing developers with flexibility and choice.\n\nThe SDK simplifies the process of creating and sending XCM messages by providing a user-friendly builder pattern. This allows developers to construct complex XCM calls with just a few lines of code, reducing the likelihood of errors and ensuring that messages are constructed correctly.\n\nBy using the ParaSpell XCM SDK, developers can significantly accelerate their development workflow and build powerful, interoperable dApps that take full advantage of the Polkadot network's cross-chain capabilities."} +{"page_id": "reference-tools-paraspell", "page_title": "ParaSpell XCM SDK", "index": 2, "depth": 2, "title": "Install ParaSpell", "anchor": "install-paraspell", "start_char": 3290, "end_char": 3634, "estimated_token_count": 103, "token_estimator": "heuristic-v1", "text": "## Install ParaSpell\n\nIf you want to use ParaSpell in your project you can add it as a dependency with the following command:\n\n=== \"npm\"\n\n ```bash\n npm install --save @paraspell/sdk@11.12.6\n ```\n\n=== \"pnpm\"\n\n ```bash\n pnpm add @paraspell/sdk@11.12.6\n ```\n\n=== \"yarn\"\n\n ```bash\n yarn add @paraspell/sdk@11.12.6\n ```"} +{"page_id": "reference-tools-paraspell", "page_title": "ParaSpell XCM SDK", "index": 3, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 3634, "end_char": 4043, "estimated_token_count": 92, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nExplore more about ParaSpell through these resources:\n\n
\n\n- Tutorial __Transfer Assets Between Parachains__\n\n ---\n\n Learn how to transfer assets across chains with ParaSpell.\n\n [:octicons-arrow-right-24: Get Started](/chain-interactions/send-transactions/interoperability/transfer-assets-parachains/)\n\n
"} {"page_id": "reference-tools-polkadart", "page_title": "Polkadart", "index": 0, "depth": 2, "title": "Installation", "anchor": "installation", "start_char": 454, "end_char": 1089, "estimated_token_count": 147, "token_estimator": "heuristic-v1", "text": "## Installation\n\nAdd Polkadart to your `pubspec.yaml`:\n\n=== \"All packages\"\n\n ```bash\n dart pub add polkadart polkadart_cli polkadart_keyring polkadart_scale_codec secp256k1_ecdsa sr25519 ss58 substrate_bip39 substrate_metadata\n ```\n\n=== \"Core only\"\n\n ```bash\n dart pub add polkadart polkadart_cli polkadart_keyring\n ```\n\nFor type-safe API generation, add the following to your `pubspec.yaml`:\n\n{% raw %}\n```yaml title=\"pubspec.yaml\"\npolkadart:\n output_dir: lib/generated\n chains:\n polkadot: wss://rpc.polkadot.io\n kusama: wss://kusama-rpc.polkadot.io\n custom: wss://your-node.example.com\n```\n{% endraw %}"} {"page_id": "reference-tools-polkadart", "page_title": "Polkadart", "index": 1, "depth": 2, "title": "Get Started", "anchor": "get-started", "start_char": 1089, "end_char": 1105, "estimated_token_count": 4, "token_estimator": "heuristic-v1", "text": "## Get Started"} {"page_id": "reference-tools-polkadart", "page_title": "Polkadart", "index": 2, "depth": 3, "title": "Type Generation", "anchor": "type-generation", "start_char": 1105, "end_char": 1354, "estimated_token_count": 45, "token_estimator": "heuristic-v1", "text": "### Type Generation\n\nPolkadart provides a CLI tool to generate type definitions from any Polkadot-SDK compatible blockchain network. This allows you to build type-safe Dart applications without dealing with the low-level details of the blockchain."} @@ -1256,10 +1235,10 @@ {"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 13, "end_char": 787, "estimated_token_count": 134, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nAs described in the [Interoperability](/develop/interoperability){target=\\_blank} section, XCM (Cross-Consensus Messaging) is a protocol used in the Polkadot and Kusama ecosystems to enable communication and interaction between chains. It facilitates cross-chain communication, allowing assets, data, and messages to flow seamlessly across the ecosystem.\n\nAs XCM is central to enabling communication between blockchains, developers need robust tools to help interact with, build, and test XCM messages. Several XCM tools simplify working with the protocol by providing libraries, frameworks, and utilities that enhance the development process, ensuring that applications built within the Polkadot ecosystem can efficiently use cross-chain functionalities."} {"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 1, "depth": 2, "title": "Popular XCM Tools", "anchor": "popular-xcm-tools", "start_char": 787, "end_char": 809, "estimated_token_count": 5, "token_estimator": "heuristic-v1", "text": "## Popular XCM Tools"} {"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 2, "depth": 3, "title": "Moonsong Labs XCM Tools", "anchor": "moonsong-labs-xcm-tools", "start_char": 809, "end_char": 2190, "estimated_token_count": 333, "token_estimator": "heuristic-v1", "text": "### Moonsong Labs XCM Tools\n\n[Moonsong Labs XCM Tools](https://github.com/Moonsong-Labs/xcm-tools){target=\\_blank} provides a collection of scripts for managing and testing XCM operations between Polkadot SDK-based runtimes. These tools allow performing tasks like asset registration, channel setup, and XCM initialization. Key features include:\n\n- **Asset registration**: Registers assets, setting units per second (up-front fees), and configuring error (revert) codes.\n- **XCM initializer**: Initializes XCM, sets default XCM versions, and configures revert codes for XCM-related precompiles.\n- **HRMP manipulator**: Manages HRMP channel actions, including opening, accepting, or closing channels.\n- **XCM-Transactor-Info-Setter**: Configures transactor information, including extra weight and fee settings.\n- **Decode XCM**: Decodes XCM messages on the relay chain or parachains to help interpret cross-chain communication.\n\nTo get started, clone the repository and install the required dependencies:\n\n```bash\ngit clone https://github.com/Moonsong-Labs/xcm-tools && \ncd xcm-tools &&\nyarn install\n```\n\nFor a full overview of each script, visit the [scripts](https://github.com/Moonsong-Labs/xcm-tools/tree/main/scripts){target=\\_blank} directory or refer to the [official documentation](https://github.com/Moonsong-Labs/xcm-tools/blob/main/README.md){target=\\_blank} on GitHub."} -{"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 3, "depth": 3, "title": "ParaSpell", "anchor": "paraspell", "start_char": 2190, "end_char": 4045, "estimated_token_count": 409, "token_estimator": "heuristic-v1", "text": "### ParaSpell\n\n[ParaSpell](https://paraspell.xyz/){target=\\_blank} is a collection of open-source XCM tools designed to streamline cross-chain asset transfers and interactions within the Polkadot and Kusama ecosystems. It equips developers with an intuitive interface to manage and optimize XCM-based functionalities. Some key points included by ParaSpell are:\n\n- **[XCM SDK](https://paraspell.xyz/#xcm-sdk){target=\\_blank}**: Provides a unified layer to incorporate XCM into decentralized applications, simplifying complex cross-chain interactions.\n- **[XCM API](https://paraspell.xyz/#xcm-api){target=\\_blank}**: Offers an efficient, package-free approach to integrating XCM functionality while offloading heavy computing tasks, minimizing costs and improving application performance.\n- **[XCM router](https://paraspell.xyz/#xcm-router){target=\\_blank}**: Enables cross-chain asset swaps in a single command, allowing developers to send one asset type (such as DOT on Polkadot) and receive a different asset on another chain (like ASTR on Astar).\n- **[XCM analyser](https://paraspell.xyz/#xcm-analyser){target=\\_blank}**: Decodes and translates complex XCM multilocation data into readable information, supporting easier troubleshooting and debugging.\n- **[XCM visualizator](https://paraspell.xyz/#xcm-visualizator){target=\\_blank}**: A tool designed to give developers a clear, interactive view of XCM activity across the Polkadot ecosystem, providing insights into cross-chain communication flow.\n\nParaSpell's tools make it simple for developers to build, test, and deploy cross-chain solutions without needing extensive knowledge of the XCM protocol. With features like message composition, decoding, and practical utility functions for parachain interactions, ParaSpell is especially useful for debugging and optimizing cross-chain communications."} -{"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 4, "depth": 3, "title": "Astar XCM Tools", "anchor": "astar-xcm-tools", "start_char": 4045, "end_char": 5585, "estimated_token_count": 369, "token_estimator": "heuristic-v1", "text": "### Astar XCM Tools\n\nThe [Astar parachain](https://github.com/AstarNetwork/Astar/tree/master){target=\\_blank} offers a crate with a set of utilities for interacting with the XCM protocol. The [xcm-tools](https://github.com/AstarNetwork/Astar/tree/master/bin/xcm-tools){target=\\_blank} crate provides a straightforward method for users to locate a sovereign account or calculate an XC20 asset ID. Some commands included by the xcm-tools crate allow users to perform the following tasks:\n\n- **Sovereign accounts**: Obtain the sovereign account address for any parachain, either on the Relay Chain or for sibling parachains, using a simple command.\n- **XC20 EVM addresses**: Generate XC20-compatible Ethereum addresses for assets by entering the asset ID, making it easy to integrate assets across Ethereum-compatible environments.\n- **Remote accounts**: Retrieve remote account addresses needed for multi-location compatibility, using flexible options to specify account types and parachain IDs.\n\nTo start using these tools, clone the [Astar repository](https://github.com/AstarNetwork/Astar){target=\\_blank} and compile the xcm-tools package:\n\n```bash\ngit clone https://github.com/AstarNetwork/Astar &&\ncd Astar &&\ncargo build --release -p xcm-tools\n```\n\nAfter compiling, verify the setup with the following command:\n\n```bash\n./target/release/xcm-tools --help\n```\nFor more details on using Astar xcm-tools, consult the [official documentation](https://docs.astar.network/docs/learn/interoperability/xcm/integration/tools/){target=\\_blank}."} -{"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 5, "depth": 3, "title": "Chopsticks", "anchor": "chopsticks", "start_char": 5585, "end_char": 5895, "estimated_token_count": 65, "token_estimator": "heuristic-v1", "text": "### Chopsticks\n\nThe Chopsticks library provides XCM functionality for testing XCM messages across networks, enabling you to fork multiple parachains along with a relay chain. For further details, see the [Chopsticks documentation](/tutorials/polkadot-sdk/testing/fork-live-chains/){target=\\_blank} about XCM."} -{"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 6, "depth": 3, "title": "Moonbeam XCM SDK", "anchor": "moonbeam-xcm-sdk", "start_char": 5895, "end_char": 7524, "estimated_token_count": 385, "token_estimator": "heuristic-v1", "text": "### Moonbeam XCM SDK\n\nThe [Moonbeam XCM SDK](https://github.com/moonbeam-foundation/xcm-sdk){target=\\_blank} enables developers to easily transfer assets between chains, either between parachains or between a parachain and the relay chain, within the Polkadot/Kusama ecosystem. With the SDK, you don't need to worry about determining the [Multilocation](https://github.com/polkadot-fellows/xcm-format?tab=readme-ov-file#7-universal-consensus-location-identifiers){target=\\_blank} of the origin or destination assets or which extrinsics are used on which networks.\n\nThe SDK consists of two main packages:\n\n- **[XCM SDK](https://github.com/moonbeam-foundation/xcm-sdk/tree/main/packages/sdk){target=\\_blank}**: Core SDK for executing XCM transfers between chains in the Polkadot/Kusama ecosystem.\n- **[MRL SDK](https://github.com/moonbeam-foundation/xcm-sdk/tree/main/packages/mrl){target=\\_blank}**: Extension of the XCM SDK for transferring liquidity into and across the Polkadot ecosystem from other ecosystems like Ethereum.\n\nKey features include:\n\n- **Simplified asset transfers**: Abstracts away complex multilocation determinations and extrinsic selection.\n- **Cross-ecosystem support**: Enables transfers between Polkadot/Kusama chains and external ecosystems.\n- **Developer-friendly API**: Provides intuitive interfaces for cross-chain functionality.\n- **Comprehensive documentation**: Includes usage guides and API references for both packages.\n\nFor detailed usage examples and API documentation, visit the [official Moonbeam XCM SDK documentation](https://moonbeam-foundation.github.io/xcm-sdk/latest/){target=\\_blank}."} +{"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 3, "depth": 3, "title": "ParaSpell", "anchor": "paraspell", "start_char": 2190, "end_char": 2667, "estimated_token_count": 86, "token_estimator": "heuristic-v1", "text": "### ParaSpell\n\n[ParaSpell](/reference/tools/paraspell/){target=\\_blank} is a collection of open-source XCM tools that streamline cross-chain asset transfers and interactions across the Polkadot and Kusama ecosystems. It provides developers with an intuitive interface to build, test, and deploy interoperable dApps, featuring message composition, decoding, and practical utilities for parachain interactions that simplify debugging and cross-chain communication optimization."} +{"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 4, "depth": 3, "title": "Astar XCM Tools", "anchor": "astar-xcm-tools", "start_char": 2667, "end_char": 4207, "estimated_token_count": 369, "token_estimator": "heuristic-v1", "text": "### Astar XCM Tools\n\nThe [Astar parachain](https://github.com/AstarNetwork/Astar/tree/master){target=\\_blank} offers a crate with a set of utilities for interacting with the XCM protocol. The [xcm-tools](https://github.com/AstarNetwork/Astar/tree/master/bin/xcm-tools){target=\\_blank} crate provides a straightforward method for users to locate a sovereign account or calculate an XC20 asset ID. Some commands included by the xcm-tools crate allow users to perform the following tasks:\n\n- **Sovereign accounts**: Obtain the sovereign account address for any parachain, either on the Relay Chain or for sibling parachains, using a simple command.\n- **XC20 EVM addresses**: Generate XC20-compatible Ethereum addresses for assets by entering the asset ID, making it easy to integrate assets across Ethereum-compatible environments.\n- **Remote accounts**: Retrieve remote account addresses needed for multi-location compatibility, using flexible options to specify account types and parachain IDs.\n\nTo start using these tools, clone the [Astar repository](https://github.com/AstarNetwork/Astar){target=\\_blank} and compile the xcm-tools package:\n\n```bash\ngit clone https://github.com/AstarNetwork/Astar &&\ncd Astar &&\ncargo build --release -p xcm-tools\n```\n\nAfter compiling, verify the setup with the following command:\n\n```bash\n./target/release/xcm-tools --help\n```\nFor more details on using Astar xcm-tools, consult the [official documentation](https://docs.astar.network/docs/learn/interoperability/xcm/integration/tools/){target=\\_blank}."} +{"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 5, "depth": 3, "title": "Chopsticks", "anchor": "chopsticks", "start_char": 4207, "end_char": 4517, "estimated_token_count": 65, "token_estimator": "heuristic-v1", "text": "### Chopsticks\n\nThe Chopsticks library provides XCM functionality for testing XCM messages across networks, enabling you to fork multiple parachains along with a relay chain. For further details, see the [Chopsticks documentation](/tutorials/polkadot-sdk/testing/fork-live-chains/){target=\\_blank} about XCM."} +{"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 6, "depth": 3, "title": "Moonbeam XCM SDK", "anchor": "moonbeam-xcm-sdk", "start_char": 4517, "end_char": 6146, "estimated_token_count": 385, "token_estimator": "heuristic-v1", "text": "### Moonbeam XCM SDK\n\nThe [Moonbeam XCM SDK](https://github.com/moonbeam-foundation/xcm-sdk){target=\\_blank} enables developers to easily transfer assets between chains, either between parachains or between a parachain and the relay chain, within the Polkadot/Kusama ecosystem. With the SDK, you don't need to worry about determining the [Multilocation](https://github.com/polkadot-fellows/xcm-format?tab=readme-ov-file#7-universal-consensus-location-identifiers){target=\\_blank} of the origin or destination assets or which extrinsics are used on which networks.\n\nThe SDK consists of two main packages:\n\n- **[XCM SDK](https://github.com/moonbeam-foundation/xcm-sdk/tree/main/packages/sdk){target=\\_blank}**: Core SDK for executing XCM transfers between chains in the Polkadot/Kusama ecosystem.\n- **[MRL SDK](https://github.com/moonbeam-foundation/xcm-sdk/tree/main/packages/mrl){target=\\_blank}**: Extension of the XCM SDK for transferring liquidity into and across the Polkadot ecosystem from other ecosystems like Ethereum.\n\nKey features include:\n\n- **Simplified asset transfers**: Abstracts away complex multilocation determinations and extrinsic selection.\n- **Cross-ecosystem support**: Enables transfers between Polkadot/Kusama chains and external ecosystems.\n- **Developer-friendly API**: Provides intuitive interfaces for cross-chain functionality.\n- **Comprehensive documentation**: Includes usage guides and API references for both packages.\n\nFor detailed usage examples and API documentation, visit the [official Moonbeam XCM SDK documentation](https://moonbeam-foundation.github.io/xcm-sdk/latest/){target=\\_blank}."} {"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 0, "depth": 2, "title": "Networks Details", "anchor": "networks-details", "start_char": 951, "end_char": 1604, "estimated_token_count": 137, "token_estimator": "heuristic-v1", "text": "## Networks Details\n\nDevelopers can leverage smart contracts across diverse networks, from TestNets to MainNet. This section outlines the network specifications and connection details for each environment.\n\n=== \"Polkadot Hub TestNet\"\n\n Network name\n\n ```text\n Polkadot Hub TestNet\n ```\n\n ---\n\n Currency symbol\n \n ```text\n PAS\n ```\n\n ---\n \n Chain ID\n \n ```text\n 420420422\n ```\n\n ---\n \n RPC URL\n \n ```text\n https://testnet-passet-hub-eth-rpc.polkadot.io\n ```\n\n ---\n \n Block explorer URL\n \n ```text\n https://blockscout-passet-hub.parity-testnet.parity.io/\n ```"} {"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 1, "depth": 2, "title": "Test Tokens", "anchor": "test-tokens", "start_char": 1604, "end_char": 2618, "estimated_token_count": 233, "token_estimator": "heuristic-v1", "text": "## Test Tokens\n\nYou will need testnet tokens to perform transactions and engage with smart contracts on any chain. Here's how to obtain Paseo (PAS) tokens for testing purposes:\n\n1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\\_blank}. If the desired network is not already selected, choose it from the Network drop-down.\n\n2. Copy your address linked to the TestNet and paste it into the designated field.\n\n ![](/images/smart-contracts/connect/connect-to-polkadot-01.webp)\n\n3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly.\n\n ![](/images/smart-contracts/connect/connect-to-polkadot-02.webp)\n\nNow that you have obtained PAS tokens in your wallet, you’re ready to deploy and interact with smart contracts on Polkadot Hub TestNet! These tokens will allow you to pay for gas fees when executing transactions, deploying contracts, and testing your dApp functionality in a secure testnet environment."} {"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 2, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 2618, "end_char": 3459, "estimated_token_count": 188, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nFor your next steps, explore the various smart contract guides demonstrating how to use and integrate different tools and development environments into your workflow.\n\n
\n\n- Guide __Deploy your first contract with Remix__\n\n ---\n\n Explore the smart contract development and deployment process on Polkadot Hub using the Remix IDE.\n\n [:octicons-arrow-right-24: Build with Remix IDE](/smart-contracts/dev-environments/remix/get-started/)\n\n- Guide __Interact with the blockchain with viem__\n\n ---\n\n Use viem for interacting with Ethereum-compatible chains, to deploy and interact with smart contracts on Polkadot Hub.\n\n [:octicons-arrow-right-24: Build with viem](/smart-contracts/libraries/viem/)\n\n
"} @@ -1270,21 +1249,21 @@ {"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 4, "depth": 3, "title": "Create the Storage Contract", "anchor": "create-the-storage-contract", "start_char": 3094, "end_char": 3633, "estimated_token_count": 112, "token_estimator": "heuristic-v1", "text": "### Create the Storage Contract\n\nIn the `contracts` directory, create a new file called `Storage.sol` and add the following code:\n\n```solidity title=\"Storage.sol\"\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract Storage {\n uint256 private storedNumber;\n\n event NumberStored(uint256 newNumber);\n\n function setNumber(uint256 _number) public {\n storedNumber = _number;\n emit NumberStored(_number);\n }\n}\n```\n\nThis simple contract stores a single number and provides functions to read and update it."} {"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 5, "depth": 3, "title": "Configure Hardhat for Polkadot Hub", "anchor": "configure-hardhat-for-polkadot-hub", "start_char": 3633, "end_char": 5430, "estimated_token_count": 415, "token_estimator": "heuristic-v1", "text": "### Configure Hardhat for Polkadot Hub\n\nUpdate your `hardhat.config.ts` file to include the Polkadot Hub TestNet configuration:\n\n```typescript title=\"hardhat.config.ts\" hl_lines=\"39-44\"\nimport type { HardhatUserConfig } from \"hardhat/config\";\n\nimport hardhatToolboxViemPlugin from \"@nomicfoundation/hardhat-toolbox-viem\";\nimport { configVariable } from \"hardhat/config\";\n\nconst config: HardhatUserConfig = {\n plugins: [hardhatToolboxViemPlugin],\n solidity: {\n profiles: {\n default: {\n version: \"0.8.28\",\n },\n production: {\n version: \"0.8.28\",\n settings: {\n optimizer: {\n enabled: true,\n runs: 200,\n },\n },\n },\n },\n },\n networks: {\n hardhatMainnet: {\n type: \"edr-simulated\",\n chainType: \"l1\",\n },\n hardhatOp: {\n type: \"edr-simulated\",\n chainType: \"op\",\n },\n sepolia: {\n type: \"http\",\n chainType: \"l1\",\n url: configVariable(\"SEPOLIA_RPC_URL\"),\n accounts: [configVariable(\"SEPOLIA_PRIVATE_KEY\")],\n },\n polkadotTestNet: {\n type: \"http\",\n chainType: \"l1\",\n url: 'http://127.0.0.1:8545',\n accounts: [process.env.PRIVATE_KEY || ''],\n },\n },\n};\n\nexport default config;\n```\n\nCreate a `.env` file in the root of your Hardhat project:\n\n```text title=\".env\"\nPRIVATE_KEY=INSERT_PRIVATE_KEY_HERE\n```\n\nReplace `INSERT_PRIVATE_KEY_HERE` with your actual private key. You can get this by exporting the private key from your wallet (e.g., MetaMask).\n\n!!! warning\n Never commit your private key to version control. Use environment variables or a `.env` file (and add it to `.gitignore`) to manage sensitive information. Keep your private key safe, and never share it with anyone. If it is compromised, your funds can be stolen."} {"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 6, "depth": 3, "title": "Compile the Contract", "anchor": "compile-the-contract", "start_char": 5430, "end_char": 5579, "estimated_token_count": 29, "token_estimator": "heuristic-v1", "text": "### Compile the Contract\n\nCompile your Storage contract:\n\n```bash\nnpx hardhat compile\n```\n\nYou should see output indicating successful compilation."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 7, "depth": 3, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 5579, "end_char": 7212, "estimated_token_count": 416, "token_estimator": "heuristic-v1", "text": "### Deploy the Contract\n\nCreate a deployment script in the `ignition/modules` directory called `Storage.ts`:\n\n```typescript title=\"Storage.ts\"\nimport { buildModule } from \"@nomicfoundation/hardhat-ignition/modules\";\n\nexport default buildModule(\"StorageModule\", (m) => {\n const storage = m.contract(\"Storage\");\n\n return { storage };\n});\n```\n\nDeploy the contract to Polkadot Hub TestNet:\n\n```bash\nnpx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotHub\n```\n\nYou should see output similar to:\n\n
\n npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet\n WARNING: You are using Node.js 23.11.0 which is not supported by Hardhat.\n Please upgrade to 22.10.0 or a later LTS version (even major version number)\n ✔ Confirm deploy to network polkadotTestNet (420420420)? … yes\n Hardhat Ignition 🚀\n Deploying [ StorageModule ]\n Batch #1\n Executed StorageModule#Storage\n [ StorageModule ] successfully deployed 🚀\n Deployed Addresses\n StorageModule#Storage - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3\n
\n\n!!! note\n Save the deployed contract address - you'll need it when building your dApp. In the following sections, we'll reference a pre-deployed contract at `0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3`, but you can use your own deployed contract address instead."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 8, "depth": 3, "title": "Export the Contract ABI", "anchor": "export-the-contract-abi", "start_char": 7212, "end_char": 7599, "estimated_token_count": 89, "token_estimator": "heuristic-v1", "text": "### Export the Contract ABI\n\nAfter deployment, you'll need the contract's Application Binary Interface (ABI) for your dApp. You can find it in the `artifacts/contracts/Storage.sol/Storage.json` file generated by Hardhat. You'll use this in the next section when setting up your dApp.\n\nNow that you have your contract deployed, you're ready to build the dApp that will interact with it!"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 9, "depth": 2, "title": "Set Up the dApp Project", "anchor": "set-up-the-dapp-project", "start_char": 7599, "end_char": 7796, "estimated_token_count": 59, "token_estimator": "heuristic-v1", "text": "## Set Up the dApp Project\n\nNavigate to the root of the project, and create a new Next.js project called `dapp`:\n\n```bash\nnpx create-next-app dapp --ts --eslint --tailwind --app --yes\ncd dapp\n```"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 10, "depth": 2, "title": "Install Dependencies", "anchor": "install-dependencies", "start_char": 7796, "end_char": 7955, "estimated_token_count": 50, "token_estimator": "heuristic-v1", "text": "## Install Dependencies\n\nInstall viem and related packages:\n\n```bash\nnpm install viem@2.38.5\nnpm install --save-dev typescript@5.9.3 @types/node@22.19.24\n```"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 11, "depth": 2, "title": "Connect to Polkadot Hub", "anchor": "connect-to-polkadot-hub", "start_char": 7955, "end_char": 10052, "estimated_token_count": 509, "token_estimator": "heuristic-v1", "text": "## Connect to Polkadot Hub\n\nTo interact with Polkadot Hub, you need to set up a [Public Client](https://viem.sh/docs/clients/public#public-client){target=\\_blank} that connects to the blockchain. In this example, you will interact with the Polkadot Hub TestNet, to experiment safely. Start by creating a new file called `utils/viem.ts` and add the following code:\n\n```typescript title=\"viem.ts\"\nimport { createPublicClient, http, createWalletClient, custom } from 'viem'\nimport 'viem/window';\n\nconst transport = http('http://127.0.0.1:8545') // TODO: change to the paseo asset hub RPC URL when it's available\n\n// Configure the Polkadot Testnet Hub chain\nexport const polkadotTestnet = {\n id: 420420420,\n name: 'Polkadot Testnet',\n network: 'polkadot-testnet',\n nativeCurrency: {\n decimals: 18,\n name: 'PAS',\n symbol: 'PAS',\n },\n rpcUrls: {\n default: {\n http: ['http://127.0.0.1:8545'], // TODO: change to the paseo asset hub RPC URL\n },\n },\n} as const\n\n// Create a public client for reading data\nexport const publicClient = createPublicClient({\n chain: polkadotTestnet,\n transport\n})\n\n// Create a wallet client for signing transactions\nexport const getWalletClient = async () => {\n if (typeof window !== 'undefined' && window.ethereum) {\n const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' });\n return createWalletClient({\n chain: polkadotTestnet,\n transport: custom(window.ethereum),\n account,\n });\n }\n throw new Error('No Ethereum browser provider detected');\n};\n```\n\nThis file initializes a viem client, providing helper functions for obtaining a Public Client and a [Wallet Client](https://viem.sh/docs/clients/wallet#wallet-client){target=\\_blank}. The Public Client enables reading blockchain data, while the Wallet Client allows users to sign and send transactions. Also, note that by importing `viem/window` the global `window.ethereum` will be typed as an `EIP1193Provider`, check the [`window` Polyfill](https://viem.sh/docs/typescript#window-polyfill){target=\\_blank} reference for more information."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 12, "depth": 2, "title": "Set Up the Smart Contract Interface", "anchor": "set-up-the-smart-contract-interface", "start_char": 10052, "end_char": 11943, "estimated_token_count": 415, "token_estimator": "heuristic-v1", "text": "## Set Up the Smart Contract Interface\n\nFor this dApp, you'll use a simple [Storage contract](/tutorials/smart-contracts/launch-your-first-project/create-contracts){target=\\_blank} that's already deployed in the Polkadot Hub TestNet: `0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3`. To interact with it, you need to define the contract interface.\n\nCreate a folder called `abis` at the root of your project, then create a file named `Storage.json` and paste the corresponding ABI of the Storage contract. You can copy and paste the following:\n\n```bash\ncp ./storage-contract/artifacts/contracts/Storage.sol/Storage.json ./dapp/abis/Storage.json\n```\n\nNext, create a file called `utils/contract.ts`:\n\n```typescript title=\"contract.ts\"\nimport { getContract } from 'viem';\nimport { publicClient, getWalletClient } from './viem';\nimport StorageABI from '../abis/Storage.json';\n\nexport const CONTRACT_ADDRESS = '0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3'; // TODO: change when the paseo asset hub RPC URL is available, and the contract is redeployed\nexport const CONTRACT_ABI = StorageABI.abi;\n\n// Create a function to get a contract instance for reading\nexport const getContractInstance = () => {\n return getContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n client: publicClient,\n });\n};\n\n// Create a function to get a contract instance with a signer for writing\nexport const getSignedContract = async () => {\n const walletClient = await getWalletClient();\n return getContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n client: walletClient,\n });\n};\n```\n\nThis file defines the contract address, ABI, and functions to create a viem [contract instance](https://viem.sh/docs/contract/getContract#contract-instances){target=\\_blank} for reading and writing operations. viem's contract utilities enable more efficient, type-safe interaction with smart contracts."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 13, "depth": 2, "title": "Create the Wallet Connection Component", "anchor": "create-the-wallet-connection-component", "start_char": 11943, "end_char": 17968, "estimated_token_count": 1343, "token_estimator": "heuristic-v1", "text": "## Create the Wallet Connection Component\n\nNow, let's create a component to handle wallet connections. Create a new file called `components/WalletConnect.tsx`:\n\n```typescript title=\"WalletConnect.tsx\"\n\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { polkadotTestnet } from \"../utils/viem\";\n\ninterface WalletConnectProps {\n onConnect: (account: string) => void;\n}\n\nconst WalletConnect: React.FC = ({ onConnect }) => {\n const [account, setAccount] = useState(null);\n const [chainId, setChainId] = useState(null);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n // Check if user already has an authorized wallet connection\n const checkConnection = async () => {\n if (typeof window !== 'undefined' && window.ethereum) {\n try {\n // eth_accounts doesn't trigger the wallet popup\n const accounts = await window.ethereum.request({\n method: 'eth_accounts',\n }) as string[];\n \n if (accounts.length > 0) {\n setAccount(accounts[0]);\n const chainIdHex = await window.ethereum.request({\n method: 'eth_chainId',\n }) as string;\n setChainId(parseInt(chainIdHex, 16));\n onConnect(accounts[0]);\n }\n } catch (err) {\n console.error('Error checking connection:', err);\n setError('Failed to check wallet connection');\n }\n }\n };\n\n checkConnection();\n\n if (typeof window !== 'undefined' && window.ethereum) {\n // Setup wallet event listeners\n window.ethereum.on('accountsChanged', (accounts: string[]) => {\n setAccount(accounts[0] || null);\n if (accounts[0]) onConnect(accounts[0]);\n });\n\n window.ethereum.on('chainChanged', (chainIdHex: string) => {\n setChainId(parseInt(chainIdHex, 16));\n });\n }\n\n return () => {\n // Cleanup event listeners\n if (typeof window !== 'undefined' && window.ethereum) {\n window.ethereum.removeListener('accountsChanged', () => {});\n window.ethereum.removeListener('chainChanged', () => {});\n }\n };\n }, [onConnect]);\n\n const connectWallet = async () => {\n if (typeof window === 'undefined' || !window.ethereum) {\n setError(\n 'MetaMask not detected! Please install MetaMask to use this dApp.'\n );\n return;\n }\n\n try {\n // eth_requestAccounts triggers the wallet popup\n const accounts = await window.ethereum.request({\n method: 'eth_requestAccounts',\n }) as string[];\n \n setAccount(accounts[0]);\n\n const chainIdHex = await window.ethereum.request({\n method: 'eth_chainId',\n }) as string;\n \n const currentChainId = parseInt(chainIdHex, 16);\n setChainId(currentChainId);\n\n // Prompt user to switch networks if needed\n if (currentChainId !== polkadotTestnet.id) {\n await switchNetwork();\n }\n\n onConnect(accounts[0]);\n } catch (err) {\n console.error('Error connecting to wallet:', err);\n setError('Failed to connect wallet');\n }\n };\n\n const switchNetwork = async () => {\n console.log('Switch network')\n try {\n await window.ethereum.request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: `0x${polkadotTestnet.id.toString(16)}` }],\n });\n } catch (switchError: any) {\n // Error 4902 means the chain hasn't been added to MetaMask\n if (switchError.code === 4902) {\n try {\n await window.ethereum.request({\n method: 'wallet_addEthereumChain',\n params: [\n {\n chainId: `0x${polkadotTestnet.id.toString(16)}`,\n chainName: polkadotTestnet.name,\n rpcUrls: [polkadotTestnet.rpcUrls.default.http[0]],\n nativeCurrency: {\n name: polkadotTestnet.nativeCurrency.name,\n symbol: polkadotTestnet.nativeCurrency.symbol,\n decimals: polkadotTestnet.nativeCurrency.decimals,\n },\n },\n ],\n });\n } catch (addError) {\n setError('Failed to add network to wallet');\n }\n } else {\n setError('Failed to switch network');\n }\n }\n };\n\n // UI-only disconnection - MetaMask doesn't support programmatic disconnection\n const disconnectWallet = () => {\n setAccount(null);\n };\n\n return (\n
\n {error &&

{error}

}\n\n {!account ? (\n \n Connect Wallet\n \n ) : (\n
\n \n {`${account.substring(0, 6)}...${account.substring(38)}`}\n \n \n Disconnect\n \n {chainId !== polkadotTestnet.id && (\n \n Switch to Polkadot Testnet\n \n )}\n
\n )}\n
\n );\n};\n\nexport default WalletConnect;\n```\n\nThis component handles connecting to the wallet, switching networks if necessary, and keeping track of the connected account. It provides a button for users to connect their wallet and displays the connected account address once connected."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 14, "depth": 2, "title": "Create the Read Contract Component", "anchor": "create-the-read-contract-component", "start_char": 17968, "end_char": 20502, "estimated_token_count": 617, "token_estimator": "heuristic-v1", "text": "## Create the Read Contract Component\n\nNow, let's create a component to read data from the contract. Create a file called `components/ReadContract.tsx`:\n\n```typescript title=\"ReadContract.tsx\"\n'use client';\n\nimport React, { useState, useEffect } from 'react';\nimport { publicClient } from '../utils/viem';\nimport { CONTRACT_ADDRESS, CONTRACT_ABI } from '../utils/contract';\n\nconst ReadContract: React.FC = () => {\n const [storedNumber, setStoredNumber] = useState(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n // Function to read data from the blockchain\n const fetchData = async () => {\n try {\n setLoading(true);\n // Call the smart contract's storedNumber function\n const number = await publicClient.readContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n functionName: 'storedNumber',\n args: [],\n }) as bigint;\n\n setStoredNumber(number.toString());\n setError(null);\n } catch (err) {\n console.error('Error fetching stored number:', err);\n setError('Failed to fetch data from the contract');\n } finally {\n setLoading(false);\n }\n };\n\n fetchData();\n\n // Poll for updates every 10 seconds to keep UI in sync with blockchain\n const interval = setInterval(fetchData, 10000);\n\n // Clean up interval on component unmount\n return () => clearInterval(interval);\n }, []);\n\n return (\n
\n

Contract Data

\n {loading ? (\n
\n
\n
\n ) : error ? (\n

{error}

\n ) : (\n
\n

\n Stored Number: {storedNumber}\n

\n
\n )}\n
\n );\n};\n\nexport default ReadContract;\n```\n\nThis component reads the `storedNumber` value from the contract and displays it to the user. It also sets up a polling interval to refresh the data periodically, ensuring that the UI stays in sync with the blockchain state."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 15, "depth": 2, "title": "Create the Write Contract Component", "anchor": "create-the-write-contract-component", "start_char": 20502, "end_char": 28611, "estimated_token_count": 1825, "token_estimator": "heuristic-v1", "text": "## Create the Write Contract Component\n\nFinally, let's create a component that allows users to update the stored number. Create a file called `components/WriteContract.tsx`:\n\n```typescript title=\"WriteContract.tsx\"\n\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { publicClient, getWalletClient } from '../utils/viem';\nimport { CONTRACT_ADDRESS, CONTRACT_ABI } from '../utils/contract';\n\ninterface WriteContractProps {\n account: string | null;\n}\n\nconst WriteContract: React.FC = ({ account }) => {\n const [newNumber, setNewNumber] = useState(\"\");\n const [status, setStatus] = useState<{\n type: string | null;\n message: string;\n }>({\n type: null,\n message: \"\",\n });\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isCorrectNetwork, setIsCorrectNetwork] = useState(true);\n\n // Check if the account is on the correct network\n useEffect(() => {\n const checkNetwork = async () => {\n if (!account) return;\n\n try {\n // Get the chainId from the public client\n const chainId = await publicClient.getChainId();\n\n // Get the user's current chainId from their wallet\n const walletClient = await getWalletClient();\n if (!walletClient) return;\n\n const walletChainId = await walletClient.getChainId();\n\n // Check if they match\n setIsCorrectNetwork(chainId === walletChainId);\n } catch (err) {\n console.error(\"Error checking network:\", err);\n setIsCorrectNetwork(false);\n }\n };\n\n checkNetwork();\n }, [account]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n\n // Validation checks\n if (!account) {\n setStatus({ type: \"error\", message: \"Please connect your wallet first\" });\n return;\n }\n\n if (!isCorrectNetwork) {\n setStatus({\n type: \"error\",\n message: \"Please switch to the correct network in your wallet\",\n });\n return;\n }\n\n if (!newNumber || isNaN(Number(newNumber))) {\n setStatus({ type: \"error\", message: \"Please enter a valid number\" });\n return;\n }\n\n try {\n setIsSubmitting(true);\n setStatus({ type: \"info\", message: \"Initiating transaction...\" });\n\n // Get wallet client for transaction signing\n const walletClient = await getWalletClient();\n\n if (!walletClient) {\n setStatus({ type: \"error\", message: \"Wallet client not available\" });\n return;\n }\n\n // Check if account matches\n if (\n walletClient.account?.address.toLowerCase() !== account.toLowerCase()\n ) {\n setStatus({\n type: \"error\",\n message:\n \"Connected wallet account doesn't match the selected account\",\n });\n return;\n }\n\n // Prepare transaction and wait for user confirmation in wallet\n setStatus({\n type: \"info\",\n message: \"Please confirm the transaction in your wallet...\",\n });\n\n // Simulate the contract call first\n console.log('newNumber', newNumber);\n const { request } = await publicClient.simulateContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n functionName: \"setNumber\",\n args: [BigInt(newNumber)],\n account: walletClient.account,\n });\n\n // Send the transaction with wallet client\n const hash = await walletClient.writeContract(request);\n\n // Wait for transaction to be mined\n setStatus({\n type: \"info\",\n message: \"Transaction submitted. Waiting for confirmation...\",\n });\n\n const receipt = await publicClient.waitForTransactionReceipt({\n hash,\n });\n\n setStatus({\n type: \"success\",\n message: `Transaction confirmed! Transaction hash: ${receipt.transactionHash}`,\n });\n\n setNewNumber(\"\");\n } catch (err: any) {\n console.error(\"Error updating number:\", err);\n\n // Handle specific errors\n if (err.code === 4001) {\n // User rejected transaction\n setStatus({ type: \"error\", message: \"Transaction rejected by user.\" });\n } else if (err.message?.includes(\"Account not found\")) {\n // Account not found on the network\n setStatus({\n type: \"error\",\n message:\n \"Account not found on current network. Please check your wallet is connected to the correct network.\",\n });\n } else if (err.message?.includes(\"JSON is not a valid request object\")) {\n // JSON error - specific to your current issue\n setStatus({\n type: \"error\",\n message:\n \"Invalid request format. Please try again or contact support.\",\n });\n } else {\n // Other errors\n setStatus({\n type: \"error\",\n message: `Error: ${err.message || \"Failed to send transaction\"}`,\n });\n }\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n
\n

Update Stored Number

\n\n {!isCorrectNetwork && account && (\n
\n ⚠️ You are not connected to the correct network. Please switch\n networks in your wallet.\n
\n )}\n\n {status.message && (\n \n {status.message}\n
\n )}\n\n
\n setNewNumber(e.target.value)}\n disabled={isSubmitting || !account}\n className=\"w-full p-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-pink-400\"\n />\n \n {isSubmitting ? \"Updating...\" : \"Update\"}\n \n \n\n {!account && (\n

\n Connect your wallet to update the stored number.\n

\n )}\n
\n );\n};\n\nexport default WriteContract;\n```\n\nThis component allows users to input a new number and send a transaction to update the value stored in the contract. It provides appropriate feedback during each step of the transaction process and handles error scenarios.\n\nUpdate the `app/page.tsx` file to integrate all components:\n\n```typescript title=\"page.tsx\"\n\"use client\";\n\nimport { useState } from \"react\";\nimport WalletConnect from \"./components/WalletConnect\";\nimport ReadContract from \"./components/ReadContract\";\nimport WriteContract from \"./components/WriteContract\";\n\nexport default function Home() {\n const [account, setAccount] = useState(null);\n\n const handleConnect = (connectedAccount: string) => {\n setAccount(connectedAccount);\n };\n\n return (\n
\n

\n Polkadot Hub - Zero To Hero DApp\n

\n \n \n \n
\n );\n}\n```\n\nRun the dApp:\n\n```bash\nnpm run dev\n```\n\nNavigate to `http://localhost:3000` in your browser, and you should see your dApp with the wallet connection button, the stored number displayed, and the form to update the number. You should see something like this:"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 16, "depth": 2, "title": "How It Works", "anchor": "how-it-works", "start_char": 28611, "end_char": 28704, "estimated_token_count": 18, "token_estimator": "heuristic-v1", "text": "## How It Works\n\nThis dApp uses components to interact with the blockchain in several ways."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 17, "depth": 3, "title": "Wallet Connection", "anchor": "wallet-connection", "start_char": 28704, "end_char": 29010, "estimated_token_count": 60, "token_estimator": "heuristic-v1", "text": "### Wallet Connection \n\nThe `WalletConnect` component uses the browser's Ethereum provider (MetaMask) to connect to the user's wallet and handles network switching to ensure the user is connected to the Polkadot Hub TestNet. Once connected, it provides the user's account address to the parent component."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 18, "depth": 3, "title": "Data Reads", "anchor": "data-reads", "start_char": 29010, "end_char": 29311, "estimated_token_count": 57, "token_estimator": "heuristic-v1", "text": "### Data Reads\n\nThe `ReadContract` component uses viem's `readContract` function to call the `storedNumber` view function and periodically poll for updates to keep the UI in sync with the blockchain state. The component also displays a loading indicator while fetching data and handles error states."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 19, "depth": 3, "title": "Data Writes", "anchor": "data-writes", "start_char": 29311, "end_char": 29713, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "### Data Writes\n\nThe `WriteContract` component uses viem's `writeContract` function to send a transaction to the `setNumber` function and ensures the wallet is connected before allowing a transaction. The component shows detailed feedback during transaction submission and confirmation. After a successful transaction, the value displayed in the `ReadContract` component will update on the next poll."} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 20, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 29713, "end_char": 30610, "estimated_token_count": 178, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nCongratulations! You've successfully built a fully functional dApp that interacts with a smart contract on Polkadot Hub using viem and Next.js. Your application can now:\n\n- Create a smart contract with Hardhat and deploy it to Polkadot Hub TestNet.\n- Connect to a user's wallet and handle network switching.\n- Read data from a smart contract and keep it updated.\n- Write data to the blockchain through transactions.\n\nThese fundamental skills provide the foundation for building more complex dApps on Polkadot Hub. With this knowledge, you can extend your application to interact with more sophisticated smart contracts and create advanced user interfaces.\n\nTo get started right away with a working example, you can clone the repository and navigate to the implementation:\n\n```bash\ngit clone https://github.com/polkadot-developers/revm-hardhat-examples.git\ncd zero-to-hero-dapp\n```"} -{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 21, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 30610, "end_char": 31203, "estimated_token_count": 147, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Port Ethereum Projects to Polkadot Hub__\n\n ---\n\n Learn how to port an Ethereum project to Polkadot Hub using Hardhat and Viem.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/eth-dapps/)\n\n- Guide __Dive Deeper into Polkadot Precompiles__\n\n ---\n\n Learn how to use the Polkadot precompiles to interact with the blockchain.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/polkadot-precompiles/)\n
"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 7, "depth": 3, "title": "Deploy the Contract", "anchor": "deploy-the-contract", "start_char": 5579, "end_char": 7216, "estimated_token_count": 416, "token_estimator": "heuristic-v1", "text": "### Deploy the Contract\n\nCreate a deployment script in the `ignition/modules` directory called `Storage.ts`:\n\n```typescript title=\"Storage.ts\"\nimport { buildModule } from \"@nomicfoundation/hardhat-ignition/modules\";\n\nexport default buildModule(\"StorageModule\", (m) => {\n const storage = m.contract(\"Storage\");\n\n return { storage };\n});\n```\n\nDeploy the contract to Polkadot Hub TestNet:\n\n```bash\nnpx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet\n```\n\nYou should see output similar to:\n\n
\n npx hardhat ignition deploy ./ignition/modules/Storage.ts --network polkadotTestNet\n WARNING: You are using Node.js 23.11.0 which is not supported by Hardhat.\n Please upgrade to 22.10.0 or a later LTS version (even major version number)\n ✔ Confirm deploy to network polkadotTestNet (420420420)? … yes\n Hardhat Ignition 🚀\n Deploying [ StorageModule ]\n Batch #1\n Executed StorageModule#Storage\n [ StorageModule ] successfully deployed 🚀\n Deployed Addresses\n StorageModule#Storage - 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3\n
\n\n!!! note\n Save the deployed contract address - you'll need it when building your dApp. In the following sections, we'll reference a pre-deployed contract at `0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3`, but you can use your own deployed contract address instead."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 8, "depth": 3, "title": "Export the Contract ABI", "anchor": "export-the-contract-abi", "start_char": 7216, "end_char": 7603, "estimated_token_count": 89, "token_estimator": "heuristic-v1", "text": "### Export the Contract ABI\n\nAfter deployment, you'll need the contract's Application Binary Interface (ABI) for your dApp. You can find it in the `artifacts/contracts/Storage.sol/Storage.json` file generated by Hardhat. You'll use this in the next section when setting up your dApp.\n\nNow that you have your contract deployed, you're ready to build the dApp that will interact with it!"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 9, "depth": 2, "title": "Set Up the dApp Project", "anchor": "set-up-the-dapp-project", "start_char": 7603, "end_char": 7800, "estimated_token_count": 59, "token_estimator": "heuristic-v1", "text": "## Set Up the dApp Project\n\nNavigate to the root of the project, and create a new Next.js project called `dapp`:\n\n```bash\nnpx create-next-app dapp --ts --eslint --tailwind --app --yes\ncd dapp\n```"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 10, "depth": 2, "title": "Install Dependencies", "anchor": "install-dependencies", "start_char": 7800, "end_char": 7959, "estimated_token_count": 50, "token_estimator": "heuristic-v1", "text": "## Install Dependencies\n\nInstall viem and related packages:\n\n```bash\nnpm install viem@2.38.5\nnpm install --save-dev typescript@5.9.3 @types/node@22.19.24\n```"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 11, "depth": 2, "title": "Connect to Polkadot Hub", "anchor": "connect-to-polkadot-hub", "start_char": 7959, "end_char": 10056, "estimated_token_count": 509, "token_estimator": "heuristic-v1", "text": "## Connect to Polkadot Hub\n\nTo interact with Polkadot Hub, you need to set up a [Public Client](https://viem.sh/docs/clients/public#public-client){target=\\_blank} that connects to the blockchain. In this example, you will interact with the Polkadot Hub TestNet, to experiment safely. Start by creating a new file called `utils/viem.ts` and add the following code:\n\n```typescript title=\"viem.ts\"\nimport { createPublicClient, http, createWalletClient, custom } from 'viem'\nimport 'viem/window';\n\nconst transport = http('http://127.0.0.1:8545') // TODO: change to the paseo asset hub RPC URL when it's available\n\n// Configure the Polkadot Testnet Hub chain\nexport const polkadotTestnet = {\n id: 420420420,\n name: 'Polkadot Testnet',\n network: 'polkadot-testnet',\n nativeCurrency: {\n decimals: 18,\n name: 'PAS',\n symbol: 'PAS',\n },\n rpcUrls: {\n default: {\n http: ['http://127.0.0.1:8545'], // TODO: change to the paseo asset hub RPC URL\n },\n },\n} as const\n\n// Create a public client for reading data\nexport const publicClient = createPublicClient({\n chain: polkadotTestnet,\n transport\n})\n\n// Create a wallet client for signing transactions\nexport const getWalletClient = async () => {\n if (typeof window !== 'undefined' && window.ethereum) {\n const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' });\n return createWalletClient({\n chain: polkadotTestnet,\n transport: custom(window.ethereum),\n account,\n });\n }\n throw new Error('No Ethereum browser provider detected');\n};\n```\n\nThis file initializes a viem client, providing helper functions for obtaining a Public Client and a [Wallet Client](https://viem.sh/docs/clients/wallet#wallet-client){target=\\_blank}. The Public Client enables reading blockchain data, while the Wallet Client allows users to sign and send transactions. Also, note that by importing `viem/window` the global `window.ethereum` will be typed as an `EIP1193Provider`, check the [`window` Polyfill](https://viem.sh/docs/typescript#window-polyfill){target=\\_blank} reference for more information."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 12, "depth": 2, "title": "Set Up the Smart Contract Interface", "anchor": "set-up-the-smart-contract-interface", "start_char": 10056, "end_char": 11947, "estimated_token_count": 415, "token_estimator": "heuristic-v1", "text": "## Set Up the Smart Contract Interface\n\nFor this dApp, you'll use a simple [Storage contract](/tutorials/smart-contracts/launch-your-first-project/create-contracts){target=\\_blank} that's already deployed in the Polkadot Hub TestNet: `0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3`. To interact with it, you need to define the contract interface.\n\nCreate a folder called `abis` at the root of your project, then create a file named `Storage.json` and paste the corresponding ABI of the Storage contract. You can copy and paste the following:\n\n```bash\ncp ./storage-contract/artifacts/contracts/Storage.sol/Storage.json ./dapp/abis/Storage.json\n```\n\nNext, create a file called `utils/contract.ts`:\n\n```typescript title=\"contract.ts\"\nimport { getContract } from 'viem';\nimport { publicClient, getWalletClient } from './viem';\nimport StorageABI from '../abis/Storage.json';\n\nexport const CONTRACT_ADDRESS = '0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3'; // TODO: change when the paseo asset hub RPC URL is available, and the contract is redeployed\nexport const CONTRACT_ABI = StorageABI.abi;\n\n// Create a function to get a contract instance for reading\nexport const getContractInstance = () => {\n return getContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n client: publicClient,\n });\n};\n\n// Create a function to get a contract instance with a signer for writing\nexport const getSignedContract = async () => {\n const walletClient = await getWalletClient();\n return getContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n client: walletClient,\n });\n};\n```\n\nThis file defines the contract address, ABI, and functions to create a viem [contract instance](https://viem.sh/docs/contract/getContract#contract-instances){target=\\_blank} for reading and writing operations. viem's contract utilities enable more efficient, type-safe interaction with smart contracts."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 13, "depth": 2, "title": "Create the Wallet Connection Component", "anchor": "create-the-wallet-connection-component", "start_char": 11947, "end_char": 17972, "estimated_token_count": 1343, "token_estimator": "heuristic-v1", "text": "## Create the Wallet Connection Component\n\nNow, let's create a component to handle wallet connections. Create a new file called `components/WalletConnect.tsx`:\n\n```typescript title=\"WalletConnect.tsx\"\n\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { polkadotTestnet } from \"../utils/viem\";\n\ninterface WalletConnectProps {\n onConnect: (account: string) => void;\n}\n\nconst WalletConnect: React.FC = ({ onConnect }) => {\n const [account, setAccount] = useState(null);\n const [chainId, setChainId] = useState(null);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n // Check if user already has an authorized wallet connection\n const checkConnection = async () => {\n if (typeof window !== 'undefined' && window.ethereum) {\n try {\n // eth_accounts doesn't trigger the wallet popup\n const accounts = await window.ethereum.request({\n method: 'eth_accounts',\n }) as string[];\n \n if (accounts.length > 0) {\n setAccount(accounts[0]);\n const chainIdHex = await window.ethereum.request({\n method: 'eth_chainId',\n }) as string;\n setChainId(parseInt(chainIdHex, 16));\n onConnect(accounts[0]);\n }\n } catch (err) {\n console.error('Error checking connection:', err);\n setError('Failed to check wallet connection');\n }\n }\n };\n\n checkConnection();\n\n if (typeof window !== 'undefined' && window.ethereum) {\n // Setup wallet event listeners\n window.ethereum.on('accountsChanged', (accounts: string[]) => {\n setAccount(accounts[0] || null);\n if (accounts[0]) onConnect(accounts[0]);\n });\n\n window.ethereum.on('chainChanged', (chainIdHex: string) => {\n setChainId(parseInt(chainIdHex, 16));\n });\n }\n\n return () => {\n // Cleanup event listeners\n if (typeof window !== 'undefined' && window.ethereum) {\n window.ethereum.removeListener('accountsChanged', () => {});\n window.ethereum.removeListener('chainChanged', () => {});\n }\n };\n }, [onConnect]);\n\n const connectWallet = async () => {\n if (typeof window === 'undefined' || !window.ethereum) {\n setError(\n 'MetaMask not detected! Please install MetaMask to use this dApp.'\n );\n return;\n }\n\n try {\n // eth_requestAccounts triggers the wallet popup\n const accounts = await window.ethereum.request({\n method: 'eth_requestAccounts',\n }) as string[];\n \n setAccount(accounts[0]);\n\n const chainIdHex = await window.ethereum.request({\n method: 'eth_chainId',\n }) as string;\n \n const currentChainId = parseInt(chainIdHex, 16);\n setChainId(currentChainId);\n\n // Prompt user to switch networks if needed\n if (currentChainId !== polkadotTestnet.id) {\n await switchNetwork();\n }\n\n onConnect(accounts[0]);\n } catch (err) {\n console.error('Error connecting to wallet:', err);\n setError('Failed to connect wallet');\n }\n };\n\n const switchNetwork = async () => {\n console.log('Switch network')\n try {\n await window.ethereum.request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: `0x${polkadotTestnet.id.toString(16)}` }],\n });\n } catch (switchError: any) {\n // Error 4902 means the chain hasn't been added to MetaMask\n if (switchError.code === 4902) {\n try {\n await window.ethereum.request({\n method: 'wallet_addEthereumChain',\n params: [\n {\n chainId: `0x${polkadotTestnet.id.toString(16)}`,\n chainName: polkadotTestnet.name,\n rpcUrls: [polkadotTestnet.rpcUrls.default.http[0]],\n nativeCurrency: {\n name: polkadotTestnet.nativeCurrency.name,\n symbol: polkadotTestnet.nativeCurrency.symbol,\n decimals: polkadotTestnet.nativeCurrency.decimals,\n },\n },\n ],\n });\n } catch (addError) {\n setError('Failed to add network to wallet');\n }\n } else {\n setError('Failed to switch network');\n }\n }\n };\n\n // UI-only disconnection - MetaMask doesn't support programmatic disconnection\n const disconnectWallet = () => {\n setAccount(null);\n };\n\n return (\n
\n {error &&

{error}

}\n\n {!account ? (\n \n Connect Wallet\n \n ) : (\n
\n \n {`${account.substring(0, 6)}...${account.substring(38)}`}\n \n \n Disconnect\n \n {chainId !== polkadotTestnet.id && (\n \n Switch to Polkadot Testnet\n \n )}\n
\n )}\n
\n );\n};\n\nexport default WalletConnect;\n```\n\nThis component handles connecting to the wallet, switching networks if necessary, and keeping track of the connected account. It provides a button for users to connect their wallet and displays the connected account address once connected."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 14, "depth": 2, "title": "Create the Read Contract Component", "anchor": "create-the-read-contract-component", "start_char": 17972, "end_char": 20506, "estimated_token_count": 617, "token_estimator": "heuristic-v1", "text": "## Create the Read Contract Component\n\nNow, let's create a component to read data from the contract. Create a file called `components/ReadContract.tsx`:\n\n```typescript title=\"ReadContract.tsx\"\n'use client';\n\nimport React, { useState, useEffect } from 'react';\nimport { publicClient } from '../utils/viem';\nimport { CONTRACT_ADDRESS, CONTRACT_ABI } from '../utils/contract';\n\nconst ReadContract: React.FC = () => {\n const [storedNumber, setStoredNumber] = useState(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n // Function to read data from the blockchain\n const fetchData = async () => {\n try {\n setLoading(true);\n // Call the smart contract's storedNumber function\n const number = await publicClient.readContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n functionName: 'storedNumber',\n args: [],\n }) as bigint;\n\n setStoredNumber(number.toString());\n setError(null);\n } catch (err) {\n console.error('Error fetching stored number:', err);\n setError('Failed to fetch data from the contract');\n } finally {\n setLoading(false);\n }\n };\n\n fetchData();\n\n // Poll for updates every 10 seconds to keep UI in sync with blockchain\n const interval = setInterval(fetchData, 10000);\n\n // Clean up interval on component unmount\n return () => clearInterval(interval);\n }, []);\n\n return (\n
\n

Contract Data

\n {loading ? (\n
\n
\n
\n ) : error ? (\n

{error}

\n ) : (\n
\n

\n Stored Number: {storedNumber}\n

\n
\n )}\n
\n );\n};\n\nexport default ReadContract;\n```\n\nThis component reads the `storedNumber` value from the contract and displays it to the user. It also sets up a polling interval to refresh the data periodically, ensuring that the UI stays in sync with the blockchain state."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 15, "depth": 2, "title": "Create the Write Contract Component", "anchor": "create-the-write-contract-component", "start_char": 20506, "end_char": 28615, "estimated_token_count": 1825, "token_estimator": "heuristic-v1", "text": "## Create the Write Contract Component\n\nFinally, let's create a component that allows users to update the stored number. Create a file called `components/WriteContract.tsx`:\n\n```typescript title=\"WriteContract.tsx\"\n\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { publicClient, getWalletClient } from '../utils/viem';\nimport { CONTRACT_ADDRESS, CONTRACT_ABI } from '../utils/contract';\n\ninterface WriteContractProps {\n account: string | null;\n}\n\nconst WriteContract: React.FC = ({ account }) => {\n const [newNumber, setNewNumber] = useState(\"\");\n const [status, setStatus] = useState<{\n type: string | null;\n message: string;\n }>({\n type: null,\n message: \"\",\n });\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isCorrectNetwork, setIsCorrectNetwork] = useState(true);\n\n // Check if the account is on the correct network\n useEffect(() => {\n const checkNetwork = async () => {\n if (!account) return;\n\n try {\n // Get the chainId from the public client\n const chainId = await publicClient.getChainId();\n\n // Get the user's current chainId from their wallet\n const walletClient = await getWalletClient();\n if (!walletClient) return;\n\n const walletChainId = await walletClient.getChainId();\n\n // Check if they match\n setIsCorrectNetwork(chainId === walletChainId);\n } catch (err) {\n console.error(\"Error checking network:\", err);\n setIsCorrectNetwork(false);\n }\n };\n\n checkNetwork();\n }, [account]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n\n // Validation checks\n if (!account) {\n setStatus({ type: \"error\", message: \"Please connect your wallet first\" });\n return;\n }\n\n if (!isCorrectNetwork) {\n setStatus({\n type: \"error\",\n message: \"Please switch to the correct network in your wallet\",\n });\n return;\n }\n\n if (!newNumber || isNaN(Number(newNumber))) {\n setStatus({ type: \"error\", message: \"Please enter a valid number\" });\n return;\n }\n\n try {\n setIsSubmitting(true);\n setStatus({ type: \"info\", message: \"Initiating transaction...\" });\n\n // Get wallet client for transaction signing\n const walletClient = await getWalletClient();\n\n if (!walletClient) {\n setStatus({ type: \"error\", message: \"Wallet client not available\" });\n return;\n }\n\n // Check if account matches\n if (\n walletClient.account?.address.toLowerCase() !== account.toLowerCase()\n ) {\n setStatus({\n type: \"error\",\n message:\n \"Connected wallet account doesn't match the selected account\",\n });\n return;\n }\n\n // Prepare transaction and wait for user confirmation in wallet\n setStatus({\n type: \"info\",\n message: \"Please confirm the transaction in your wallet...\",\n });\n\n // Simulate the contract call first\n console.log('newNumber', newNumber);\n const { request } = await publicClient.simulateContract({\n address: CONTRACT_ADDRESS,\n abi: CONTRACT_ABI,\n functionName: \"setNumber\",\n args: [BigInt(newNumber)],\n account: walletClient.account,\n });\n\n // Send the transaction with wallet client\n const hash = await walletClient.writeContract(request);\n\n // Wait for transaction to be mined\n setStatus({\n type: \"info\",\n message: \"Transaction submitted. Waiting for confirmation...\",\n });\n\n const receipt = await publicClient.waitForTransactionReceipt({\n hash,\n });\n\n setStatus({\n type: \"success\",\n message: `Transaction confirmed! Transaction hash: ${receipt.transactionHash}`,\n });\n\n setNewNumber(\"\");\n } catch (err: any) {\n console.error(\"Error updating number:\", err);\n\n // Handle specific errors\n if (err.code === 4001) {\n // User rejected transaction\n setStatus({ type: \"error\", message: \"Transaction rejected by user.\" });\n } else if (err.message?.includes(\"Account not found\")) {\n // Account not found on the network\n setStatus({\n type: \"error\",\n message:\n \"Account not found on current network. Please check your wallet is connected to the correct network.\",\n });\n } else if (err.message?.includes(\"JSON is not a valid request object\")) {\n // JSON error - specific to your current issue\n setStatus({\n type: \"error\",\n message:\n \"Invalid request format. Please try again or contact support.\",\n });\n } else {\n // Other errors\n setStatus({\n type: \"error\",\n message: `Error: ${err.message || \"Failed to send transaction\"}`,\n });\n }\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n
\n

Update Stored Number

\n\n {!isCorrectNetwork && account && (\n
\n ⚠️ You are not connected to the correct network. Please switch\n networks in your wallet.\n
\n )}\n\n {status.message && (\n \n {status.message}\n
\n )}\n\n
\n setNewNumber(e.target.value)}\n disabled={isSubmitting || !account}\n className=\"w-full p-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-pink-400\"\n />\n \n {isSubmitting ? \"Updating...\" : \"Update\"}\n \n \n\n {!account && (\n

\n Connect your wallet to update the stored number.\n

\n )}\n
\n );\n};\n\nexport default WriteContract;\n```\n\nThis component allows users to input a new number and send a transaction to update the value stored in the contract. It provides appropriate feedback during each step of the transaction process and handles error scenarios.\n\nUpdate the `app/page.tsx` file to integrate all components:\n\n```typescript title=\"page.tsx\"\n\"use client\";\n\nimport { useState } from \"react\";\nimport WalletConnect from \"./components/WalletConnect\";\nimport ReadContract from \"./components/ReadContract\";\nimport WriteContract from \"./components/WriteContract\";\n\nexport default function Home() {\n const [account, setAccount] = useState(null);\n\n const handleConnect = (connectedAccount: string) => {\n setAccount(connectedAccount);\n };\n\n return (\n
\n

\n Polkadot Hub - Zero To Hero DApp\n

\n \n \n \n
\n );\n}\n```\n\nRun the dApp:\n\n```bash\nnpm run dev\n```\n\nNavigate to `http://localhost:3000` in your browser, and you should see your dApp with the wallet connection button, the stored number displayed, and the form to update the number. You should see something like this:"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 16, "depth": 2, "title": "How It Works", "anchor": "how-it-works", "start_char": 28615, "end_char": 28708, "estimated_token_count": 18, "token_estimator": "heuristic-v1", "text": "## How It Works\n\nThis dApp uses components to interact with the blockchain in several ways."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 17, "depth": 3, "title": "Wallet Connection", "anchor": "wallet-connection", "start_char": 28708, "end_char": 29014, "estimated_token_count": 60, "token_estimator": "heuristic-v1", "text": "### Wallet Connection \n\nThe `WalletConnect` component uses the browser's Ethereum provider (MetaMask) to connect to the user's wallet and handles network switching to ensure the user is connected to the Polkadot Hub TestNet. Once connected, it provides the user's account address to the parent component."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 18, "depth": 3, "title": "Data Reads", "anchor": "data-reads", "start_char": 29014, "end_char": 29315, "estimated_token_count": 57, "token_estimator": "heuristic-v1", "text": "### Data Reads\n\nThe `ReadContract` component uses viem's `readContract` function to call the `storedNumber` view function and periodically poll for updates to keep the UI in sync with the blockchain state. The component also displays a loading indicator while fetching data and handles error states."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 19, "depth": 3, "title": "Data Writes", "anchor": "data-writes", "start_char": 29315, "end_char": 29717, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "### Data Writes\n\nThe `WriteContract` component uses viem's `writeContract` function to send a transaction to the `setNumber` function and ensures the wallet is connected before allowing a transaction. The component shows detailed feedback during transaction submission and confirmation. After a successful transaction, the value displayed in the `ReadContract` component will update on the next poll."} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 20, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 29717, "end_char": 30614, "estimated_token_count": 178, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nCongratulations! You've successfully built a fully functional dApp that interacts with a smart contract on Polkadot Hub using viem and Next.js. Your application can now:\n\n- Create a smart contract with Hardhat and deploy it to Polkadot Hub TestNet.\n- Connect to a user's wallet and handle network switching.\n- Read data from a smart contract and keep it updated.\n- Write data to the blockchain through transactions.\n\nThese fundamental skills provide the foundation for building more complex dApps on Polkadot Hub. With this knowledge, you can extend your application to interact with more sophisticated smart contracts and create advanced user interfaces.\n\nTo get started right away with a working example, you can clone the repository and navigate to the implementation:\n\n```bash\ngit clone https://github.com/polkadot-developers/revm-hardhat-examples.git\ncd zero-to-hero-dapp\n```"} +{"page_id": "smart-contracts-cookbook-dapps-zero-to-hero", "page_title": "Zero to Hero Smart Contract DApp", "index": 21, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 30614, "end_char": 31207, "estimated_token_count": 147, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Guide __Port Ethereum Projects to Polkadot Hub__\n\n ---\n\n Learn how to port an Ethereum project to Polkadot Hub using Hardhat and Viem.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/eth-dapps/)\n\n- Guide __Dive Deeper into Polkadot Precompiles__\n\n ---\n\n Learn how to use the Polkadot precompiles to interact with the blockchain.\n\n [:octicons-arrow-right-24: Get Started](/smart-contracts/cookbook/polkadot-precompiles/)\n
"} {"page_id": "smart-contracts-cookbook-eth-dapps-uniswap-v2", "page_title": "Deploying Uniswap V2 on Polkadot", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 191, "end_char": 857, "estimated_token_count": 131, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nDecentralized exchanges (DEXs) are a cornerstone of the DeFi ecosystem, allowing for permissionless token swaps without intermediaries. [Uniswap V2](https://docs.uniswap.org/contracts/v2/overview){target=\\_blank}, with its Automated Market Maker (AMM) model, revolutionized DEXs by enabling liquidity provision for any ERC-20 token pair.\n\nThis tutorial will guide you through how Uniswap V2 works so you can take advantage of it in your projects deployed to Polkadot Hub. By understanding these contracts, you'll gain hands-on experience with one of the most influential DeFi protocols and understand how it functions across blockchain ecosystems."} {"page_id": "smart-contracts-cookbook-eth-dapps-uniswap-v2", "page_title": "Deploying Uniswap V2 on Polkadot", "index": 1, "depth": 2, "title": "Prerequisites", "anchor": "prerequisites", "start_char": 857, "end_char": 1357, "estimated_token_count": 124, "token_estimator": "heuristic-v1", "text": "## Prerequisites\n\nBefore starting, make sure you have:\n\n- Node.js (v16.0.0 or later) and npm installed.\n- Basic understanding of Solidity and JavaScript.\n- Familiarity with [`hardhat-polkadot`](/smart-contracts/dev-environments/hardhat/get-started/){target=\\_blank} development environment.\n- Some PAS test tokens to cover transaction fees (obtained from the [Polkadot faucet](https://faucet.polkadot.io/?parachain=1111){target=\\_blank}).\n- Basic understanding of how AMMs and liquidity pools work."} {"page_id": "smart-contracts-cookbook-eth-dapps-uniswap-v2", "page_title": "Deploying Uniswap V2 on Polkadot", "index": 2, "depth": 2, "title": "Set Up the Project", "anchor": "set-up-the-project", "start_char": 1357, "end_char": 3682, "estimated_token_count": 570, "token_estimator": "heuristic-v1", "text": "## Set Up the Project\n\nLet's start by cloning the Uniswap V2 project:\n\n1. Clone the Uniswap V2 repository:\n\n ```\n git clone https://github.com/polkadot-developers/polkavm-hardhat-examples.git -b v0.0.6\n cd polkavm-hardhat-examples/uniswap-v2-polkadot/\n ```\n\n2. Install the required dependencies:\n\n ```bash\n npm install\n ```\n\n3. Update the `hardhat.config.js` file so the paths for the Substrate node and the ETH-RPC adapter match with the paths on your machine. For more info, check the [Testing your Contract](/smart-contracts/dev-environments/hardhat/compile-and-test/){target=\\_blank} section in the Hardhat guide.\n\n ```js title=\"hardhat.config.js\"\n hardhat: {\n polkavm: true,\n nodeConfig: {\n nodeBinaryPath: '../bin/substrate-node',\n rpcPort: 8000,\n dev: true,\n },\n adapterConfig: {\n adapterBinaryPath: '../bin/eth-rpc',\n dev: true,\n },\n },\n ```\n\n4. Create a `.env` file in your project root to store your private keys (you can use as an example the `env.example` file):\n\n ```text title=\".env\"\n LOCAL_PRIV_KEY=\"INSERT_LOCAL_PRIVATE_KEY\"\n AH_PRIV_KEY=\"INSERT_AH_PRIVATE_KEY\"\n ```\n\n Ensure to replace `\"INSERT_LOCAL_PRIVATE_KEY\"` with a private key available in the local environment (you can get them from this [file](https://github.com/paritytech/hardhat-polkadot/blob/main/packages/hardhat-polkadot-node/src/constants.ts#L22){target=\\_blank}). And `\"INSERT_AH_PRIVATE_KEY\"` with the account's private key you want to use to deploy the contracts. You can get this by exporting the private key from your wallet (e.g., MetaMask).\n\n !!!warning\n Keep your private key safe, and never share it with anyone. If it is compromised, your funds can be stolen.\n\n5. Compile the contracts:\n\n ```bash\n npx hardhat compile\n ```\n\nIf the compilation is successful, you should see the following output:\n\n
\n npx hardhat compile\n Compiling 12 Solidity files\n Successfully compiled 12 Solidity files\n
\n\nAfter running the above command, you should see the compiled contracts in the `artifacts-pvm` directory. This directory contains the ABI and bytecode of your contracts."} @@ -1581,6 +1560,18 @@ {"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 32, "depth": 3, "title": "debug_traceCall", "anchor": "debug_tracecall", "start_char": 28867, "end_char": 31324, "estimated_token_count": 767, "token_estimator": "heuristic-v1", "text": "### debug_traceCall\n\nExecutes a new message call and returns a detailed execution trace without creating a transaction on the blockchain.\n\n**Parameters**:\n\n- **`transaction` ++\"object\"++**: The transaction call object, similar to `eth_call` parameters.\n - **`to` ++\"string\"++**: Recipient address of the call. Must be a [20-byte data](https://ethereum.org/en/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`data` ++\"string\"++**: Hash of the method signature and encoded parameters. Must be a [data](https://ethereum.org/en/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`from` ++\"string\"++**: (Optional) Sender's address for the call. Must be a [20-byte data](https://ethereum.org/en/developers/docs/apis/json-rpc/#unformatted-data-encoding){target=\\_blank} string.\n - **`gas` ++\"string\"++**: (Optional) Gas limit to execute the call. Must be a [quantity](https://ethereum.org/en/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`gasPrice` ++\"string\"++**: (Optional) Gas price per unit of gas. Must be a [quantity](https://ethereum.org/en/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n - **`value` ++\"string\"++**: (Optional) Value in wei to send with the call. Must be a [quantity](https://ethereum.org/en/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string.\n- **`blockValue` ++\"string\"++**: (Optional) Block tag or block number to execute the call at. Must be a [quantity](https://ethereum.org/en/developers/docs/apis/json-rpc/#quantities-encoding){target=\\_blank} string or a [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block){target=\\_blank}.\n- **`options` ++\"object\"++**: (Optional) An object containing tracer options (e.g., `tracer: \"callTracer\"`).\n\n**Example**:\n\n```bash title=\"debug_traceCall\"\ncurl -X POST https://testnet-passet-hub-eth-rpc.polkadot.io \\\n-H \"Content-Type: application/json\" \\\n--data '{\n \"jsonrpc\":\"2.0\",\n \"method\":\"debug_traceCall\",\n \"params\":[{\n \"from\": \"INSERT_SENDER_ADDRESS\",\n \"to\": \"INSERT_RECIPIENT_ADDRESS\",\n \"data\": \"INSERT_ENCODED_CALL\"\n }, \"INSERT_BLOCK_VALUE\", {\"tracer\": \"callTracer\"}],\n \"id\":1\n}'\n```\n\nEnsure to replace the `INSERT_SENDER_ADDRESS`, `INSERT_RECIPIENT_ADDRESS`, `INSERT_ENCODED_CALL`, and `INSERT_BLOCK_VALUE` with the proper value.\n\n---"} {"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 33, "depth": 2, "title": "Response Format", "anchor": "response-format", "start_char": 31324, "end_char": 31507, "estimated_token_count": 57, "token_estimator": "heuristic-v1", "text": "## Response Format\n\nAll responses follow the standard JSON-RPC 2.0 format:\n\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"result\": ... // The return value varies by method\n}\n```"} {"page_id": "smart-contracts-for-eth-devs-json-rpc-apis", "page_title": "JSON-RPC APIs", "index": 34, "depth": 2, "title": "Error Handling", "anchor": "error-handling", "start_char": 31507, "end_char": 31726, "estimated_token_count": 64, "token_estimator": "heuristic-v1", "text": "## Error Handling\n\nIf an error occurs, the response will include an error object:\n\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"error\": {\n \"code\": -32000,\n \"message\": \"Error message here\"\n }\n}\n```"} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 37, "end_char": 303, "estimated_token_count": 40, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThis guide helps Ethereum developers migrate their smart contracts to Polkadot Hub. Most contracts work without modifications on the REVM backend, while the PolkaVM backend offers enhanced performance with minimal adaptation for standard patterns."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 1, "depth": 2, "title": "Migration Considerations", "anchor": "migration-considerations", "start_char": 303, "end_char": 645, "estimated_token_count": 62, "token_estimator": "heuristic-v1", "text": "## Migration Considerations\n\nTake into account the following considerations before migrating your contracts:\n\n- Standard ERC-20, ERC-721, ERC-1155 tokens work without changes.\n- DeFi protocols, DEXs, and AMMs migrate seamlessly.\n- DAOs and governance contracts are fully compatible.\n- Most Solidity contracts deploy identically to Ethereum."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 2, "depth": 2, "title": "Migration Checklist", "anchor": "migration-checklist", "start_char": 645, "end_char": 1058, "estimated_token_count": 81, "token_estimator": "heuristic-v1", "text": "## Migration Checklist\n\nBefore migrating your contracts, review this checklist:\n\n- Factory contracts using PVM bytecode need pre-uploaded dependencies.\n- Contracts using `EXTCODECOPY` for runtime manipulation require review (for projects that will use PVM bytecode, not EVM bytecode).\n- Replace `transfer()` and `send()` with proper reentrancy guards (for projects that will use PVM bytecode, not EVM bytecode)."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 3, "depth": 2, "title": "Migration FAQs", "anchor": "migration-faqs", "start_char": 1058, "end_char": 1077, "estimated_token_count": 4, "token_estimator": "heuristic-v1", "text": "## Migration FAQs"} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 4, "depth": 3, "title": "Which backend should I choose?", "anchor": "which-backend-should-i-choose", "start_char": 1077, "end_char": 1706, "estimated_token_count": 107, "token_estimator": "heuristic-v1", "text": "### Which backend should I choose?\n\n- Choose REVM if you want:\n\n - Zero-modification deployment of existing Ethereum contracts.\n - Exact EVM behavior for audited code.\n - Compatibility with tools that inspect EVM bytecode.\n - Rapid deployment without optimization.\n\n- Choose PolkaVM if you want:\n\n - Better performance for computation-heavy applications.\n - Lower execution costs for intensive operations.\n - Access to next-generation smart contract features.\n\nIf you are unsure which to choose, start with REVM for immediate compatibility, then consider PolkaVM for performance optimization once deployed."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 5, "depth": 3, "title": "Do I need to rewrite my Solidity code?", "anchor": "do-i-need-to-rewrite-my-solidity-code", "start_char": 1706, "end_char": 1825, "estimated_token_count": 26, "token_estimator": "heuristic-v1", "text": "### Do I need to rewrite my Solidity code?\n\nNo, for most contracts. Standard Solidity patterns work on both backends."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 6, "depth": 3, "title": "What about factory contracts?", "anchor": "what-about-factory-contracts", "start_char": 1825, "end_char": 3177, "estimated_token_count": 244, "token_estimator": "heuristic-v1", "text": "### What about factory contracts?\n\n- **REVM**: Factory contracts work identically to Ethereum with no changes needed. \n \n The original factory pattern is:\n\n ```solidity\n contract TokenFactory {\n function createToken(string memory name) public returns (address) {\n // Creates new contract at runtime\n Token newToken = new Token(name);\n return address(newToken);\n }\n }\n ```\n\n- **PolkaVM**: Factory contracts require pre-uploading dependent contracts. \n\n Here's how to adapt the original factory pattern:\n\n ```solidity\n contract TokenFactory {\n // Reference pre-uploaded Token contract by hash\n bytes32 public tokenCodeHash;\n \n constructor(bytes32 _tokenCodeHash) {\n tokenCodeHash = _tokenCodeHash;\n }\n \n function createToken(string memory name) public returns (address) {\n // Instantiate from pre-uploaded code\n Token newToken = new Token{salt: keccak256(abi.encode(name))}(name);\n return address(newToken);\n }\n }\n ```\n\nThe deployment steps for PolkaVM factories are:\n\n1. Upload the contract code to the chain.\n2. Note the returned code hash.\n3. Deploy the Factory contract with the contract code hash.\n4. Factory can now instantiate contracts using the pre-uploaded code."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 7, "depth": 3, "title": "How do gas costs compare?", "anchor": "how-do-gas-costs-compare", "start_char": 3177, "end_char": 3328, "estimated_token_count": 47, "token_estimator": "heuristic-v1", "text": "### How do gas costs compare?\n\nFor more information on gas costs, see the [Gas Model](/smart-contracts/for-eth-devs/gas-model/){target=\\_blank} page."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 8, "depth": 3, "title": "Which Solidity features are not supported?", "anchor": "which-solidity-features-are-not-supported", "start_char": 3328, "end_char": 3915, "estimated_token_count": 133, "token_estimator": "heuristic-v1", "text": "### Which Solidity features are not supported?\n\nFor REVM, any Solidity feature will function smoothly without requiring changes or adaptations. For PVM, there are considerations, as was mentioned above. \n\nFor PolkaVM, there are some considerations:\n\n- `EXTCODECOPY`: Only works in constructor code.\n- Runtime code modification: Use on-chain constructors instead.\n- **Gas stipends**: `address.send()` and `address.transfer()` don't provide reentrancy protection.\n- **Unsupported operations**: `pc`, `extcodecopy`, `selfdestruct`, `blobhash`, and `blobbasefee` (blob-related operations)."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 9, "depth": 3, "title": "How do I handle the existential deposit?", "anchor": "how-do-i-handle-the-existential-deposit", "start_char": 3915, "end_char": 4518, "estimated_token_count": 121, "token_estimator": "heuristic-v1", "text": "### How do I handle the existential deposit?\n\nPolkadot requires accounts to maintain a minimum balance (existential deposit or ED) to remain active.\n\nThis is handled automatically for you:\n\n- Balance queries via Ethereum RPC automatically deduct the ED.\n- New account transfers include ED in transaction fees.\n- Contract-to-contract transfers draw ED from the transaction signer.\n\nYou typically don't need to do anything special, but be aware:\n\n- Accounts below ED threshold are automatically deleted.\n- ED is around 0.01 DOT (varies by network).\n- Your contracts don't need to manage this explicitly."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 10, "depth": 3, "title": "Can I use my existing development tools?", "anchor": "can-i-use-my-existing-development-tools", "start_char": 4518, "end_char": 5499, "estimated_token_count": 304, "token_estimator": "heuristic-v1", "text": "### Can I use my existing development tools?\n\nYes. Both backends support:\n\n- **Wallets**: [MetaMask](https://metamask.io/){target=\\_blank}, [Talisman](https://talisman.xyz/){target=\\_blank}, [SubWallet](https://www.subwallet.app/){target=\\_blank}\n- **Development frameworks**: [Hardhat](/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat/){target=\\_blank}, [Foundry](/smart-contracts/cookbook/smart-contracts/deploy-basic/foundry/){target=\\_blank}, [Remix](/smart-contracts/cookbook/smart-contracts/deploy-basic/remix/){target=\\_blank} (just consider that for PVM bytecode, you will use the Polkadot version of the tooling)\n- **Libraries**: [ethers.js](/smart-contracts/libraries/ethers-js/){target=\\_blank}, [web3.js](/smart-contracts/libraries/web3-js/){target=\\_blank}, [viem](/smart-contracts/libraries/viem/){target=\\_blank}\n- **Testing tools**: Your existing test suites work\n\nConnect to Polkadot Hub's Ethereum JSON-RPC endpoint and use your familiar workflow."} +{"page_id": "smart-contracts-for-eth-devs-migration", "page_title": "Migration FAQs and Considerations", "index": 11, "depth": 2, "title": "Conclusion", "anchor": "conclusion", "start_char": 5499, "end_char": 6247, "estimated_token_count": 153, "token_estimator": "heuristic-v1", "text": "## Conclusion\n\nMost Ethereum contracts migrate to Polkadot Hub with minimal or no changes. Use REVM for seamless compatibility or PolkaVM for enhanced performance.\n\nThere are a few key points to keep in mind during migration:\n\n- Replace `transfer()` and `send()` with `.call{value}(\"\")` and use reentrancy guards (for projects that will use PVM bytecode, not EVM bytecode).\n- PolkaVM factory contracts using PVM bytecode need pre-uploaded dependencies.\n- Don't hardcode gas values.\n- Test thoroughly on [TestNet](/smart-contracts/connect/#__tabbed_1_1){target=\\_blank} before mainnet deployment.\n\nYour existing Solidity knowledge and tooling transfer directly to Polkadot Hub, making migration straightforward for standard smart contract patterns."} {"page_id": "smart-contracts-get-started", "page_title": "Get Started with Smart Contracts", "index": 0, "depth": 2, "title": "Quick Starts", "anchor": "quick-starts", "start_char": 173, "end_char": 1843, "estimated_token_count": 456, "token_estimator": "heuristic-v1", "text": "## Quick Starts\n\nKick off development fast with curated links for connecting, funding, exploring, and deploying your first contract.\n\n| Quick Start | Tools | Description |\n| :-------------------------------------------------------------------------------------------------: | :-------------------: | :-------------------------------------------------------------: |\n| [Connect to Polkadot](/smart-contracts/connect/){target=\\_blank} | Polkadot.js, MetaMask | Add the network, configure RPC, verify activity in the explorer |\n| [Get Test Tokens](/smart-contracts/faucets/){target=\\_blank} | - | Request test funds to deploy and interact with contracts |\n| [Explore Transactions](/smart-contracts/explorers/){target=\\_blank} | Subscan | Inspect transactions, logs, token transfers, and contract state |\n| [Deploy with Remix](/smart-contracts/dev-environments/remix/deploy-a-contract/){target=\\_blank} | Remix | One‑click browser deployment to Polkadot Hub |\n| [Deploy with Foundry](/smart-contracts/dev-environments/foundry/deploy-a-contract/){target=\\_blank} | Foundry | Scripted deployments and testing from the CLI |\n| [Deploy with Hardhat](/smart-contracts/dev-environments/hardhat/deploy-a-contract/){target=\\_blank} | Hardhat | Project scaffolding, testing, and deployments |"} {"page_id": "smart-contracts-get-started", "page_title": "Get Started with Smart Contracts", "index": 1, "depth": 2, "title": "Build and Test Locally", "anchor": "build-and-test-locally", "start_char": 1843, "end_char": 4050, "estimated_token_count": 596, "token_estimator": "heuristic-v1", "text": "## Build and Test Locally\n\nSet up local environments and CI-friendly workflows to iterate quickly and validate changes before deploying.\n\n| Build and Test Locally | Tools | Description |\n| :--------------------------------------------------------------------------------------------------------: | :---------------: | :--------------------------------------------------: |\n| [Run a Local Dev Node](/smart-contracts/dev-environments/local-dev-node/){target=\\_blank} | Polkadot SDK node | Spin up a local node for iterative development |\n| [Remix: Get Started](/smart-contracts/dev-environments/remix/get-started/){target=\\_blank} | Remix | Connect Remix to Polkadot Hub and configure accounts |\n| [Remix: Verify a Contract](/smart-contracts/dev-environments/remix/verify-a-contract/){target=\\_blank} | Remix | Publish verified source on explorers |\n| [Foundry: Install and Config](/smart-contracts/dev-environments/foundry/install-and-config/){target=\\_blank} | Foundry | Install toolchain and configure networks |\n| [Foundry: Compile and Test](/smart-contracts/dev-environments/foundry/compile-and-test/){target=\\_blank} | Foundry | Write and run Solidity tests locally |\n| [Foundry: Verify a Contract](/smart-contracts/dev-environments/foundry/verify-a-contract/){target=\\_blank} | Foundry | Verify deployed bytecode and metadata |\n| [Hardhat: Install and Config](/smart-contracts/dev-environments/hardhat/install-and-config/){target=\\_blank} | Hardhat | Initialize a project and configure networks |\n| [Hardhat: Compile and Test](/smart-contracts/dev-environments/hardhat/compile-and-test/){target=\\_blank} | Hardhat | Unit test contracts and run scripts |\n| [Hardhat: Verify a Contract](/smart-contracts/dev-environments/hardhat/verify-a-contract/){target=\\_blank} | Hardhat | Verify deployments on explorers |"} {"page_id": "smart-contracts-get-started", "page_title": "Get Started with Smart Contracts", "index": 2, "depth": 2, "title": "Ethereum Developer Resources", "anchor": "ethereum-developer-resources", "start_char": 4050, "end_char": 5794, "estimated_token_count": 488, "token_estimator": "heuristic-v1", "text": "## Ethereum Developer Resources\n\nBridge your Ethereum knowledge with Polkadot Hub specifics: account mapping, fees, JSON‑RPC, and deployment.\n\n| Ethereum Developer Guides | Description |\n| :-------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------: |\n| [Accounts](/smart-contracts/for-eth-devs/accounts/){target=\\_blank} | How 20‑byte Ethereum addresses map to 32‑byte Polkadot accounts |\n| [Blocks, Transactions, and Fees](/smart-contracts/for-eth-devs/blocks-transactions-fees/){target=\\_blank} | Transaction types, fees, and multi‑dimensional metering |\n| [Gas Model](/smart-contracts/for-eth-devs/gas-model/){target=\\_blank} | Gas vs. weight, proof size, and storage deposits |\n| [Contract Deployment](/smart-contracts/for-eth-devs/contract-deployment/){target=\\_blank} | Deployment patterns and best practices on Polkadot Hub |\n| [JSON‑RPC APIs](/smart-contracts/for-eth-devs/json-rpc-apis/){target=\\_blank} | Supported Ethereum JSON‑RPC methods and examples |\n| [Migration](/smart-contracts/for-eth-devs/migration/){target=\\_blank} | Port existing apps and tooling to Polkadot Hub |\n| [Dual VM Stack](/smart-contracts/for-eth-devs/dual-vm-stack/){target=\\_blank} | Overview of EVM and native execution on the Hub |"} diff --git a/llms.txt b/llms.txt index 1eef49c49..21f939670 100644 --- a/llms.txt +++ b/llms.txt @@ -10,6 +10,7 @@ This directory lists URLs for raw Markdown pages that complement the rendered pa - Categories: 12 ## Docs +This section lists documentation pages by category. Each entry links to a raw markdown version of the page and includes a short description. A page may appear in multiple categories. Docs: Basics - [Register a Local Asset](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-token-operations-register-local-asset.md): Comprehensive guide to registering a local asset on the Asset Hub system parachain, including step-by-step instructions. @@ -21,7 +22,7 @@ Docs: Basics - [Add Pallets to the Runtime](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-add-pallet-to-runtime.md): Add pallets to your runtime for custom functionality. Learn to configure and integrate pallets in Polkadot SDK-based blockchains. - [Overview of FRAME](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime.md): Learn how Polkadot SDK’s FRAME framework simplifies blockchain development with modular pallets and support libraries for efficient runtime design. - [Get Started with Parachain Development](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-get-started.md): Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. -- [Install Polkadot SDK](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md): Install everything you need to begin working with the Polkadot SDK, the framework for building blockchains. +- [Install Polkadot SDK](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md): Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. - [Introduction to XCM](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-get-started.md): Unlock blockchain interoperability with XCM — Polkadot's Cross-Consensus Messaging format for cross-chain interactions. - [Set Up the Polkadot SDK Parachain Template](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-launch-a-parachain-set-up-the-parachain-template.md): Learn how to set up and run the Polkadot SDK Parachain Template locally, creating a ready-to-customize foundation for your parachain. - [Overview](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/polkadot-protocol-architecture-parachains-overview.md): Learn about the role, functionality, and implementation of parachains as a developer in the wider Polkadot architecture. @@ -95,6 +96,7 @@ Docs: Smart Contracts - [Block Explorers](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-explorers.md): Access PolkaVM explorers like Subscan, BlockScout, and Routescan to track transactions, analyze contracts, and view on-chain data from smart contracts. - [Faucet](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-faucet.md): Learn how to obtain test tokens from Polkadot faucets for development and testing purposes across different networks. - [Contract Deployment](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-contract-deployment.md): Compare deployment flows for REVM and PVM-based smart contracts on the Polkadot Hub. Includes single-step REVM flows and PVM’s two-step deployment model. +- [Migration FAQs and Considerations](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-migration.md): Learn how to migrate your existing Ethereum contracts to the Polkadot Hub using REVM and PolkaVM by following these considerations. - [Get Started with Smart Contracts](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-get-started.md): Practical examples for building and deploying smart contracts on Polkadot Hub, from connecting and tooling to deployment, integrations, and precompiles. - [Wallets for Polkadot Hub](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-integrations-wallets.md): Comprehensive guide to connecting and managing wallets for Polkadot Hub, covering step-by-step instructions for interacting with the ecosystem. - [Deploy Contracts to Polkadot Hub with Ethers.js](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-libraries-ethers-js.md): Learn how to interact with Polkadot Hub using Ethers.js, from compiling and deploying Solidity contracts to interacting with deployed smart contracts. @@ -118,18 +120,12 @@ Docs: Parachains - [Write Tests](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains-zombienet-write-tests.md): Write and execute tests for blockchain networks with Zombienet's DSL. Learn to evaluate metrics, logs, events, and more for robust validation. - [Add an Existing Pallet to the Runtime](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-existing-pallets.md): Learn how to include and configure pallets in a Polkadot SDK-based runtime, from adding dependencies to implementing necessary traits. - [Add Multiple Pallet Instances](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-pallet-instances.md): Learn how to implement multiple instances of the same pallet in your Polkadot SDK-based runtime, from adding dependencies to configuring unique instances. -- [Add Smart Contract Functionality](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md): Add smart contract capabilities to your Polkadot SDK-based blockchain. Explore EVM and Wasm integration for enhanced chain functionality. +- [Add Smart Contract Functionality](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md): Add smart contract capabilities to your Polkadot SDK-based blockchain. Explore PVM, EVM, and Wasm integration for enhanced chain functionality. - [Add Pallets to the Runtime](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-add-pallet-to-runtime.md): Add pallets to your runtime for custom functionality. Learn to configure and integrate pallets in Polkadot SDK-based blockchains. - [Benchmarking FRAME Pallets](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-benchmark-pallet.md): Learn how to use FRAME's benchmarking framework to measure extrinsic execution costs and provide accurate weights for on-chain computations. -<<<<<<< HEAD -- [Make a Custom Pallet](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-create-a-pallet.md): Learn how to create custom pallets using FRAME, allowing for flexible, modular, and scalable blockchain development. Follow the step-by-step guide. -- [Mock Runtime for Pallet Testing](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-mock-runtime.md): Learn to create a mock environment in the Polkadot SDK for testing intra-pallet functionality and inter-pallet interactions seamlessly. -- [Pallet Unit Testing](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md): Learn how to write comprehensive unit tests for your custom pallets using mock runtimes, ensuring reliability and correctness before deployment. -======= - [Create a Custom Pallet](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-create-a-pallet.md): Learn how to create custom pallets using FRAME, allowing for flexible, modular, and scalable blockchain development. Follow the step-by-step guide. - [Mock Your Runtime](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-mock-runtime.md): Learn how to create a mock runtime environment for testing your custom pallets in isolation, enabling comprehensive unit testing before runtime integration. -- [Pallet Testing](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md): Learn how to efficiently test pallets in the Polkadot SDK, ensuring the reliability and security of your pallets operations. ->>>>>>> staging/product-ia +- [Pallet Unit Testing](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md): Learn how to write comprehensive unit tests for your custom pallets using mock runtimes, ensuring reliability and correctness before deployment. - [Overview of FRAME](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime.md): Learn how Polkadot SDK’s FRAME framework simplifies blockchain development with modular pallets and support libraries for efficient runtime design. - [Get Started with Parachain Development](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-get-started.md): Practical examples and tutorials for building and deploying Polkadot parachains, covering everything from launch to customization and cross-chain messaging. - [Opening HRMP Channels Between Parachains](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-interoperability-channels-between-parachains.md): Learn how to open HRMP channels between parachains on Polkadot. Discover the step-by-step process for establishing uni- and bidirectional communication. @@ -228,7 +224,7 @@ Docs: Infrastructure Docs: Tooling - [Quickstart Parachain Development with Pop CLI](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-quickstart-pop-cli.md): Quickly bootstrap parachain projects, scaffold templates, deploy local networks, and streamline development workflows using Pop CLI. - [Write Tests](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-toolkit-parachains-spawn-chains-zombienet-write-tests.md): Write and execute tests for blockchain networks with Zombienet's DSL. Learn to evaluate metrics, logs, events, and more for robust validation. -- [Install Polkadot SDK](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md): Install everything you need to begin working with the Polkadot SDK, the framework for building blockchains. +- [Install Polkadot SDK](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-install-polkadot-sdk.md): Install all required Polkadot SDK dependencies, set up the SDK itself, and verify that it runs correctly on your machine. - [Indexers](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-indexers.md): Discover blockchain indexers. Enhance data access, enable fast and complex queries, and optimize blockchain data for seamless app performance. - [Oracles](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-oracles.md): Learn about blockchain oracles, the essential bridges connecting blockchains with real-world data for decentralized applications in the Polkadot ecosystem. - [Wallets](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-integrations-wallets.md): Explore blockchain wallets. Securely manage digital assets with hot wallets for online access or cold wallets for offline, enhanced security. @@ -293,7 +289,7 @@ Docs: Uncategorized - [Replay and Dry Run XCMs](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-send-transactions-interoperability-debug-and-preview-xcms.md): Replay and dry-run XCMs using Chopsticks with full logging enabled. Diagnose issues, trace message flow, and debug complex cross-chain interactions. - [XCM Fee Estimation](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-send-transactions-interoperability-estimate-xcm-fees.md): This tutorial demonstrates how to estimate the fees for teleporting assets from the Paseo Asset Hub parachain to the Paseo Bridge Hub chain. - [chain-interactions-send-transactions-interoperability-transfer-assets-out-of-polkadot](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-send-transactions-interoperability-transfer-assets-out-of-polkadot.md): No description available. -- [Transfer Tokens Between Parachains](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-send-transactions-interoperability-transfer-assets-parachains.md): A step-by-step guide to using the ParaSpell XCM SDK to build, verify, and execute a transfer from one Parachain to another. +- [Transfer Assets Between Parachains](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-send-transactions-interoperability-transfer-assets-parachains.md): A step-by-step guide to using the ParaSpell XCM SDK to build, verify, and execute a transfer from one Parachain to another. - [Send a Transaction While Paying the Fee with a Different Token](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-send-transactions-pay-fees-with-different-tokens.md): This tutorial demonstrates how to send a DOT transfer transaction while paying the fees using a different token on the Asset Hub. - [chain-interactions-send-transactions-with-sdks](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions-send-transactions-with-sdks.md): No description available. - [chain-interactions](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/chain-interactions.md): No description available. @@ -359,7 +355,6 @@ Docs: Uncategorized - [ParaSpell XCM SDK](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-paraspell.md): A powerful open-source library that simplifies XCM integration, enabling developers to easily build interoperable dApps on Polkadot. - [reference-tools-zombienet](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-zombienet.md): No description available. - [reference](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md): No description available. -- [smart-contracts-cookbook-dapps-zero-to-hero](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-dapps-zero-to-hero.md): No description available. - [smart-contracts-cookbook-smart-contracts-deploy-basic](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic.md): No description available. - [smart-contracts-dev-environments-foundry-compile-and-test](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-dev-environments-foundry-compile-and-test.md): No description available. - [smart-contracts-dev-environments-foundry-deploy-a-contract](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-dev-environments-foundry-deploy-a-contract.md): No description available. @@ -376,7 +371,6 @@ Docs: Uncategorized - [smart-contracts-dev-environments-remix-troubleshooting](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-dev-environments-remix-troubleshooting.md): No description available. - [smart-contracts-dev-environments-remix-verify-a-contract](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-dev-environments-remix-verify-a-contract.md): No description available. - [Gas Model on the Polkadot Hub](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-gas-model.md): Learn how gas estimation, pricing, and weight mapping work in the Polkadot Hub. -- [smart-contracts-for-eth-devs-migration](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-migration.md): No description available. - [smart-contracts-integrations-indexers](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-integrations-indexers.md): No description available. - [smart-contracts-integrations-oracles](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-integrations-oracles.md): No description available. - [Advanced Functionalities via Precompiles](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-precompiles.md): Explores how Polkadot integrates precompiles to run essential functions natively, improving the speed and efficiency of smart contracts on the Hub. diff --git a/parachains/customize-runtime/pallet-development/pallet-testing.md b/parachains/customize-runtime/pallet-development/pallet-testing.md index 3cfff42ad..f33a35229 100644 --- a/parachains/customize-runtime/pallet-development/pallet-testing.md +++ b/parachains/customize-runtime/pallet-development/pallet-testing.md @@ -169,7 +169,7 @@ running 1 test test tests::increment_works ... ok ``` -🎉 Congratulations! You've written and run your first pallet test. +Congratulations! You've written and run your first pallet test. ## Test Error Conditions @@ -360,7 +360,7 @@ test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out These tests are automatically generated from your mock runtime setup and help ensure the test environment itself is valid. -🎉 Congratulations! You have a well-tested pallet covering the essential testing patterns! +Congratulations! You have a well-tested pallet covering the essential testing patterns! These tests demonstrate comprehensive coverage including basic operations, error conditions, access control, event emission, state management, and genesis configuration. As you build more complex pallets, you'll apply these same patterns to test additional functionality. From a127e47e07a37ed75965d00f4b117b861542beb4 Mon Sep 17 00:00:00 2001 From: Bruno Galvao Date: Wed, 12 Nov 2025 09:53:41 +0700 Subject: [PATCH 07/10] resolve llms --- .ai/categories/basics.md | 125 ++++++++++++++++++++++++++++ .ai/categories/dapps.md | 125 ++++++++++++++++++++++++++++ .ai/categories/infrastructure.md | 125 ++++++++++++++++++++++++++++ .ai/categories/networks.md | 125 ++++++++++++++++++++++++++++ .ai/categories/parachains.md | 125 ++++++++++++++++++++++++++++ .ai/categories/polkadot-protocol.md | 125 ++++++++++++++++++++++++++++ .ai/categories/reference.md | 125 ++++++++++++++++++++++++++++ .ai/categories/smart-contracts.md | 125 ++++++++++++++++++++++++++++ .ai/categories/tooling.md | 125 ++++++++++++++++++++++++++++ .ai/pages/reference.md | 119 +++++++++++++++++++++++++- .ai/site-index.json | 89 ++++++++++---------- llms-full.jsonl | 13 +-- llms.txt | 4 +- 13 files changed, 1300 insertions(+), 50 deletions(-) diff --git a/.ai/categories/basics.md b/.ai/categories/basics.md index be88860cb..53c8a870a 100644 --- a/.ai/categories/basics.md +++ b/.ai/categories/basics.md @@ -8032,6 +8032,131 @@ tail -f /tmp/zombie-794af21178672e1ff32c612c3c7408dc_-2397036-6717MXDxcS55/alic After running this command, you will see the logs of the `alice` node in real-time, which can be useful for debugging purposes. The logs of the `bob` and `collator01` nodes can be checked similarly. +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: Testing and Debugging diff --git a/.ai/categories/dapps.md b/.ai/categories/dapps.md index 481cbe15f..342bcc7f9 100644 --- a/.ai/categories/dapps.md +++ b/.ai/categories/dapps.md @@ -11430,6 +11430,131 @@ To submit a transaction, you must construct an extrinsic, sign it with your priv Now that you've covered the basics dive into the official [subxt documentation](https://docs.rs/subxt/latest/subxt/book/index.html){target=\_blank} for comprehensive reference materials and advanced features. +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: Testing and Debugging diff --git a/.ai/categories/infrastructure.md b/.ai/categories/infrastructure.md index 305a83525..6602e7d55 100644 --- a/.ai/categories/infrastructure.md +++ b/.ai/categories/infrastructure.md @@ -11551,6 +11551,131 @@ To unbond tokens, go to **Network > Staking > Account Actions** on Polkadot.js A Once the unbonding period is complete, your tokens will be available for use in transactions or transfers outside of staking. +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: Testing and Debugging diff --git a/.ai/categories/networks.md b/.ai/categories/networks.md index 28c6d88b7..9b389fef5 100644 --- a/.ai/categories/networks.md +++ b/.ai/categories/networks.md @@ -9272,6 +9272,131 @@ tail -f /tmp/zombie-794af21178672e1ff32c612c3c7408dc_-2397036-6717MXDxcS55/alic After running this command, you will see the logs of the `alice` node in real-time, which can be useful for debugging purposes. The logs of the `bob` and `collator01` nodes can be checked similarly. +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: Testing and Debugging diff --git a/.ai/categories/parachains.md b/.ai/categories/parachains.md index 3121edae3..04c7ba2ec 100644 --- a/.ai/categories/parachains.md +++ b/.ai/categories/parachains.md @@ -18103,6 +18103,131 @@ The primary trade-off is increased implementation complexity, as you must manage For a complete implementation example of multi-block migrations, refer to the [official example](https://github.com/paritytech/polkadot-sdk/tree/polkadot-stable2506-2/substrate/frame/examples/multi-block-migrations){target=\_blank} in the Polkadot SDK. +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: Testing and Debugging diff --git a/.ai/categories/polkadot-protocol.md b/.ai/categories/polkadot-protocol.md index 1da5e8aee..3461527b6 100644 --- a/.ai/categories/polkadot-protocol.md +++ b/.ai/categories/polkadot-protocol.md @@ -10228,6 +10228,131 @@ tail -f /tmp/zombie-794af21178672e1ff32c612c3c7408dc_-2397036-6717MXDxcS55/alic After running this command, you will see the logs of the `alice` node in real-time, which can be useful for debugging purposes. The logs of the `bob` and `collator01` nodes can be checked similarly. +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: Testing and Debugging diff --git a/.ai/categories/reference.md b/.ai/categories/reference.md index 9b259cf0b..a2ce3408f 100644 --- a/.ai/categories/reference.md +++ b/.ai/categories/reference.md @@ -1240,6 +1240,131 @@ If an error occurs, the response will include an error object: ``` +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: XCM Config diff --git a/.ai/categories/smart-contracts.md b/.ai/categories/smart-contracts.md index 65cacb7c7..8039a1abd 100644 --- a/.ai/categories/smart-contracts.md +++ b/.ai/categories/smart-contracts.md @@ -14391,6 +14391,131 @@ tail -f /tmp/zombie-794af21178672e1ff32c612c3c7408dc_-2397036-6717MXDxcS55/alic After running this command, you will see the logs of the `alice` node in real-time, which can be useful for debugging purposes. The logs of the `bob` and `collator01` nodes can be checked similarly. +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: Testing and Debugging diff --git a/.ai/categories/tooling.md b/.ai/categories/tooling.md index 23ea85110..06631fbf1 100644 --- a/.ai/categories/tooling.md +++ b/.ai/categories/tooling.md @@ -19925,6 +19925,131 @@ To submit a transaction, you must construct an extrinsic, sign it with your priv Now that you've covered the basics dive into the official [subxt documentation](https://docs.rs/subxt/latest/subxt/book/index.html){target=\_blank} for comprehensive reference materials and advanced features. +--- + +Page Title: Technical Reference Overview + +- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md +- Canonical (HTML): https://docs.polkadot.com/reference/ +- Summary: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. + +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
+ + --- Page Title: Test and Deploy with Hardhat diff --git a/.ai/pages/reference.md b/.ai/pages/reference.md index d05701a93..59bc64741 100644 --- a/.ai/pages/reference.md +++ b/.ai/pages/reference.md @@ -1,5 +1,122 @@ --- +title: Technical Reference Overview +description: Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. +categories: Basics, Polkadot Protocol, Reference url: https://docs.polkadot.com/reference/ --- -TODO +## Introduction + +The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need. + +Polkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\_blank} to the [governance](/reference/glossary#governance){target=\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants. + +This guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem. + +## Polkadot Hub + +[Polkadot Hub](/reference/polkadot-hub/){target=\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain. + +The Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include: + +- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications. +- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem. +- **Staking**: Participate in network security and earn rewards by staking DOT. +- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov. +- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities. +- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem. +- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations. + +## Parachains + +[Parachains](/reference/parachains/){target=\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers: + +- **Accounts**: Deep dive into account types, storage, and management on parachains. +- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms. +- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus. +- **Chain data**: Explore data structures, storage layouts, and state management. +- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains. +- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility. +- **Networks**: Learn about networking protocols and peer-to-peer communication. +- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\_blank}, the standard for cross-chain communication. +- **Randomness**: Understand how randomness is generated and used in Polkadot chains. +- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\_blank}. + +## On-Chain Governance + +[On-Chain governance](/reference/governance/){target=\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details: + +- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums. +- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity. +- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance. +- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system. + +## Glossary + +The [Glossary](/reference/glossary/){target=\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include: + +- Blockchain concepts (blocks, transactions, state) +- Consensus mechanisms (validators, collators, finality) +- Polkadot-specific terms (relay chain, parachain, XCM, FRAME) +- Network components (nodes, runtimes, storage) +- Governance terminology (origins, tracks, referendums) + +## Tools + +The [Tools](/reference/tools/){target=\_blank} section documents essential development and interaction tools for the Polkadot ecosystem: + +- **Light clients**: Lightweight solutions for interacting with the network without running full nodes. +- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\_blank} and [PAPI](/reference/tools/papi/){target=\_blank} for building applications. +- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\_blank} and other Rust-based libraries for SDK development. +- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\_blank} for Python developers. +- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\_blank}, and [Omninode](/reference/tools/omninode/){target=\_blank} for smart contract and parachain testing. +- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\_blank} for substrate interaction. +- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\_blank} for XCM integration and asset transfers. + +## Where to Go Next + +For detailed exploration of specific areas, proceed to any of the main sections: + +
+ +- Learn **Polkadot Hub** + + --- + + Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance. + + [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/) + +- Learn **Parachains** + + --- + + Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains. + + [:octicons-arrow-right-24: Reference](/reference/parachains/) + +- Learn **On-Chain Governance** + + --- + + Explore Polkadot's decentralized governance framework and how to participate in network decision-making. + + [:octicons-arrow-right-24: Reference](/reference/governance/) + +- Guide **Glossary** + + --- + + Quick reference for Polkadot-specific terminology and concepts used throughout the documentation. + + [:octicons-arrow-right-24: Reference](/reference/glossary/) + +- Guide **Tools** + + --- + + Discover development tools, libraries, and frameworks for building and interacting with Polkadot. + + [:octicons-arrow-right-24: Reference](/reference/tools/) + +
diff --git a/.ai/site-index.json b/.ai/site-index.json index 7c56615cd..7fd6d3df0 100644 --- a/.ai/site-index.json +++ b/.ai/site-index.json @@ -725,11 +725,7 @@ "headings": 9, "estimated_token_count_total": 1488 }, -<<<<<<< HEAD - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", -======= "hash": "sha256:ff1d106bd19f80de0c8108b0a658cfef83d73a4560a012ace9c842acdeefd1a5", ->>>>>>> origin/staging/product-ia "token_estimator": "heuristic-v1" }, { @@ -5351,11 +5347,7 @@ "headings": 21, "estimated_token_count_total": 5344 }, -<<<<<<< HEAD "hash": "sha256:91981098cfa2fc26c44b817041ce5cda73c50567972407bee491cc17c45b386c", -======= - "hash": "sha256:8568dfa238b9a649a4e6e60510625c2e7879b76a93187b0b8b8dccf6bc467ae6", ->>>>>>> origin/staging/product-ia "token_estimator": "heuristic-v1" }, { @@ -5417,20 +5409,12 @@ } ], "stats": { -<<<<<<< HEAD - "chars": 8236, -======= "chars": 8237, ->>>>>>> origin/staging/product-ia "words": 1101, "headings": 9, "estimated_token_count_total": 1828 }, -<<<<<<< HEAD - "hash": "sha256:ad58d1c942b567acc4519abc35c0a049ab3e04711c2a49089ceba6324a5aa7ea", -======= "hash": "sha256:28501589d5290f932b55cd3319f6a3fd78d7297ba42810da5ad2784a297224fd", ->>>>>>> origin/staging/product-ia "token_estimator": "heuristic-v1" }, { @@ -5970,11 +5954,7 @@ "headings": 9, "estimated_token_count_total": 4129 }, -<<<<<<< HEAD - "hash": "sha256:fde940bced4380fc01b1840907059d03f6d47b6cb54bf78c95269ac57adbc99e", -======= "hash": "sha256:7309d3487c653951bf264013eb3402a72a1cbb5e0b6f89ae4e678f239cd63b80", ->>>>>>> origin/staging/product-ia "token_estimator": "heuristic-v1" }, { @@ -6127,21 +6107,12 @@ } ], "stats": { -<<<<<<< HEAD - "chars": 10591, - "words": 1510, - "headings": 11, - "estimated_token_count_total": 2377 - }, - "hash": "sha256:1277261cb3de71cac194f26e765124ea9f3e09cffdcd94bb717965a11cb7f374", -======= "chars": 10588, "words": 1510, "headings": 11, "estimated_token_count_total": 2375 }, "hash": "sha256:380063fe7c00ae8bde05fa76688b8ae4902e6566147f1cfe0e0260ad1aa05aa6", ->>>>>>> origin/staging/product-ia "token_estimator": "heuristic-v1" }, { @@ -9934,22 +9905,60 @@ }, { "id": "reference", - "title": "reference", + "title": "Technical Reference Overview", "slug": "reference", "categories": [ - "Uncategorized" + "Basics", + "Polkadot Protocol", + "Reference" ], "raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md", "html_url": "https://docs.polkadot.com/reference/", - "preview": "TODO", - "outline": [], + "preview": "The Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need.", + "outline": [ + { + "depth": 2, + "title": "Introduction", + "anchor": "introduction" + }, + { + "depth": 2, + "title": "Polkadot Hub", + "anchor": "polkadot-hub" + }, + { + "depth": 2, + "title": "Parachains", + "anchor": "parachains" + }, + { + "depth": 2, + "title": "On-Chain Governance", + "anchor": "on-chain-governance" + }, + { + "depth": 2, + "title": "Glossary", + "anchor": "glossary" + }, + { + "depth": 2, + "title": "Tools", + "anchor": "tools" + }, + { + "depth": 2, + "title": "Where to Go Next", + "anchor": "where-to-go-next" + } + ], "stats": { - "chars": 5, - "words": 1, - "headings": 0, - "estimated_token_count_total": 0 + "chars": 7648, + "words": 937, + "headings": 7, + "estimated_token_count_total": 1682 }, - "hash": "sha256:56ba36249ea8216ad513b13df3de6c0e490ba214897674d30331f1c7e7edbef3", + "hash": "sha256:9f71f3b4018f7a9e127cff51fab7cfe1168adcde2553cd1fc5dc8c25fb97a30d", "token_estimator": "heuristic-v1" }, { @@ -14092,11 +14101,7 @@ "headings": 6, "estimated_token_count_total": 2837 }, -<<<<<<< HEAD "hash": "sha256:ad43951deac53a539a3d8a2317500aec351aa7e85f3cc49b386aa30baf6bcc09", -======= - "hash": "sha256:df60044893f48dd7f37a11de275a16bf32adb31317ed70a789fd7fac64150e1a", ->>>>>>> origin/staging/product-ia "token_estimator": "heuristic-v1" }, { diff --git a/llms-full.jsonl b/llms-full.jsonl index 1f6493e08..770805dbe 100644 --- a/llms-full.jsonl +++ b/llms-full.jsonl @@ -750,15 +750,9 @@ {"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 5, "depth": 2, "title": "Compile the Runtime", "anchor": "compile-the-runtime", "start_char": 5097, "end_char": 6061, "estimated_token_count": 189, "token_estimator": "heuristic-v1", "text": "## Compile the Runtime\n\nNow that you understand the template structure, let's compile the runtime to ensure everything is working correctly.\n\n1. Compile the runtime:\n\n ```bash\n cargo build --release --locked\n ```\n\n !!!tip\n Initial compilation may take several minutes, depending on your machine specifications. Use the `--release` flag for improved runtime performance compared to the default `--debug` build. If you need to troubleshoot issues, the `--debug` build provides better diagnostics.\n \n For production deployments, consider using a dedicated `--profile production` flag - this can provide an additional 15-30% performance improvement over the standard `--release` profile.\n\n2. Upon successful compilation, you should see output indicating the build was successful. The compiled runtime will be located at:\n \n `./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm`"} {"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 6, "depth": 2, "title": "Verify the Build", "anchor": "verify-the-build", "start_char": 6061, "end_char": 6394, "estimated_token_count": 71, "token_estimator": "heuristic-v1", "text": "## Verify the Build\n\nAfter compilation completes, verify that the runtime was created successfully by checking for the Wasm blob:\n\n```bash\nls -la ./target/release/wbuild/parachain-template-runtime/\n```\n\nYou should see the `parachain_template_runtime.compact.compressed.wasm` file in the output, confirming the build was successful."} {"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 7, "depth": 2, "title": "Run the Node Locally", "anchor": "run-the-node-locally", "start_char": 6394, "end_char": 8108, "estimated_token_count": 343, "token_estimator": "heuristic-v1", "text": "## Run the Node Locally\n\nAfter successfully compiling your runtime, you can spin up a local chain and produce blocks. This process will start your local parachain using the Polkadot Omni Node and allow you to interact with it. You'll first need to generate a chain specification that defines your network's identity, initial connections, and genesis state, providing the foundational configuration for how your nodes connect and what initial state they agree upon.\n\nFollow these steps to launch your node in development mode:\n\n1. Generate the chain specification file of your parachain:\n\n ```bash\n chain-spec-builder create -t development \\\n --relay-chain paseo \\\n --para-id 1000 \\\n --runtime ./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm \\\n named-preset development\n ```\n\n2. Start the Omni Node with the generated chain spec. You'll start it in development mode (without a relay chain config), producing and finalizing blocks:\n\n ```bash\n polkadot-omni-node --chain ./chain_spec.json --dev\n ```\n\n The `--dev` option does the following:\n\n - Deletes all active data (keys, blockchain database, networking information) when stopped.\n - Ensures a clean working state each time you restart the node.\n\n3. Verify that your node is running by reviewing the terminal output. You should see log messages indicating block production and finalization.\n\n4. Confirm that your blockchain is producing new blocks by checking if the number after `finalized` is increasing in the output.\n\nThe details of the log output will be explored in a later tutorial. For now, knowing that your node is running and producing blocks is sufficient."} -<<<<<<< HEAD -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 8, "depth": 2, "title": "Interact with the Node", "anchor": "interact-with-the-node", "start_char": 8108, "end_char": 9677, "estimated_token_count": 414, "token_estimator": "heuristic-v1", "text": "## Interact with the Node\n\nWhen running the template node, it's accessible by default at `ws://localhost:9944`. To interact with your node using the [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} interface, follow these steps:\n\n1. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} in your web browser and click the network icon (which should be the Polkadot logo) in the top left corner:\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-01.webp)\n\n2. Connect to your local node:\n\n 1. Scroll to the bottom and select **Development**.\n 2. Choose **Custom**.\n 3. Enter `ws**: //localhost:9944` in the **custom endpoint** input field.\n 4. Click the **Switch** button.\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-02.webp)\n\n3. Once connected, you should see **parachain-template-runtime** in the top left corner, with the interface displaying information about your local blockchain.\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-03.webp)\n\nYou are now connected to your local node and can interact with it through the Polkadot.js Apps interface. This tool enables you to explore blocks, execute transactions, and interact with your blockchain's features. For in-depth guidance on using the interface effectively, refer to the [Polkadot.js Guides](https://wiki.polkadot.com/general/polkadotjs/){target=\\_blank} available on the Polkadot Wiki."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 9, "depth": 2, "title": "Stop the Node", "anchor": "stop-the-node", "start_char": 9677, "end_char": 10183, "estimated_token_count": 115, "token_estimator": "heuristic-v1", "text": "## Stop the Node\n\nWhen you're done exploring your local node, you can stop it to remove any state changes you've made. Since you started the node with the `--dev` option, stopping the node will purge all persistent block data, allowing you to start fresh the next time.\n\nTo stop the local node:\n\n1. Return to the terminal window where the node output is displayed.\n2. Press `Control-C` to stop the running process.\n3. Verify that your terminal returns to the prompt in the `parachain-template` directory."} -{"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 10, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 10183, "end_char": 10591, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Tutorial __Deploy to Polkadot__\n\n ---\n\n Learn how to deploy your parachain template to a relay chain testnet. Configure your chain specification, register as a parachain, and start producing blocks.\n\n [:octicons-arrow-right-24: Get Started](/parachains/launch-a-parachain/deploy-to-polkadot.md)\n\n
"} -======= {"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 8, "depth": 2, "title": "Interact with the Node", "anchor": "interact-with-the-node", "start_char": 8108, "end_char": 9674, "estimated_token_count": 412, "token_estimator": "heuristic-v1", "text": "## Interact with the Node\n\nWhen running the template node, it's accessible by default at `ws://localhost:9944`. To interact with your node using the [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} interface, follow these steps:\n\n1. Open [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\\_blank} in your web browser and click the network icon (which should be the Polkadot logo) in the top left corner:\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-01.webp)\n\n2. Connect to your local node:\n\n 1. Scroll to the bottom and select **Development**.\n 2. Choose **Custom**.\n 3. Enter `ws://localhost:9944` in the **custom endpoint** input field.\n 4. Click the **Switch** button.\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-02.webp)\n\n3. Once connected, you should see **parachain-template-runtime** in the top left corner, with the interface displaying information about your local blockchain.\n \n ![](/images/parachains/launch-a-parachain/set-up-the-parachain-template/parachain-template-03.webp)\n\nYou are now connected to your local node and can interact with it through the Polkadot.js Apps interface. This tool enables you to explore blocks, execute transactions, and interact with your blockchain's features. For in-depth guidance on using the interface effectively, refer to the [Polkadot.js Guides](https://wiki.polkadot.com/general/polkadotjs/){target=\\_blank} available on the Polkadot Wiki."} {"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 9, "depth": 2, "title": "Stop the Node", "anchor": "stop-the-node", "start_char": 9674, "end_char": 10180, "estimated_token_count": 115, "token_estimator": "heuristic-v1", "text": "## Stop the Node\n\nWhen you're done exploring your local node, you can stop it to remove any state changes you've made. Since you started the node with the `--dev` option, stopping the node will purge all persistent block data, allowing you to start fresh the next time.\n\nTo stop the local node:\n\n1. Return to the terminal window where the node output is displayed.\n2. Press `Control-C` to stop the running process.\n3. Verify that your terminal returns to the prompt in the `parachain-template` directory."} {"page_id": "parachains-launch-a-parachain-set-up-the-parachain-template", "page_title": "Set Up the Polkadot SDK Parachain Template", "index": 10, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 10180, "end_char": 10588, "estimated_token_count": 100, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\n
\n\n- Tutorial __Deploy to Polkadot__\n\n ---\n\n Learn how to deploy your parachain template to a relay chain testnet. Configure your chain specification, register as a parachain, and start producing blocks.\n\n [:octicons-arrow-right-24: Get Started](/parachains/launch-a-parachain/deploy-to-polkadot.md)\n\n
"} ->>>>>>> origin/staging/product-ia {"page_id": "parachains-runtime-maintenance-runtime-upgrades", "page_title": "Runtime Upgrades", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 20, "end_char": 926, "estimated_token_count": 147, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nOne of the defining features of Polkadot SDK-based blockchains is the ability to perform forkless runtime upgrades. Unlike traditional blockchains, which require hard forks and node coordination for upgrades, Polkadot networks enable seamless updates without network disruption.\n\nForkless upgrades are achieved through WebAssembly (Wasm) runtimes stored on-chain, which can be securely swapped and upgraded as part of the blockchain's state. By leveraging decentralized consensus, runtime updates can happen trustlessly, ensuring continuous improvement and evolution without halting operations.\n\nThis guide explains how Polkadot's runtime versioning, Wasm deployment, and storage migrations enable these upgrades, ensuring the blockchain evolves smoothly and securely. You'll also learn how different upgrade processes apply to solo chains and parachains, depending on the network setup."} {"page_id": "parachains-runtime-maintenance-runtime-upgrades", "page_title": "Runtime Upgrades", "index": 1, "depth": 2, "title": "How Runtime Upgrades Work", "anchor": "how-runtime-upgrades-work", "start_char": 926, "end_char": 1650, "estimated_token_count": 165, "token_estimator": "heuristic-v1", "text": "## How Runtime Upgrades Work\n\nIn FRAME, the [`system`](https://paritytech.github.io/polkadot-sdk/master/frame_system/index.html){target=\\_blank} pallet uses the [`set_code`](https://paritytech.github.io/polkadot-sdk/master/frame_system/pallet/enum.Call.html#variant.set_code){target=\\_blank} extrinsic to update the Wasm code for the runtime. This method allows solo chains to upgrade without disruption. \n\nFor parachains, upgrades are more complex. Parachains must first call `authorize_upgrade`, followed by `apply_authorized_upgrade`, to ensure the relay chain approves and applies the changes. Additionally, changes to current functionality that impact storage often require a [storage migration](#storage-migrations)."} {"page_id": "parachains-runtime-maintenance-runtime-upgrades", "page_title": "Runtime Upgrades", "index": 2, "depth": 3, "title": "Runtime Versioning", "anchor": "runtime-versioning", "start_char": 1650, "end_char": 4915, "estimated_token_count": 664, "token_estimator": "heuristic-v1", "text": "### Runtime Versioning\n\nThe executor is the component that selects the runtime execution environment to communicate with. Although you can override the default execution strategies for custom scenarios, in most cases, the executor selects the appropriate binary to use by evaluating and comparing key parameters from the native and Wasm runtime binaries.\n\nThe runtime includes a [runtime version struct](https://paritytech.github.io/polkadot-sdk/master/sp_version/struct.RuntimeVersion.html){target=\\_blank} to provide the needed parameter information to the executor process. A sample runtime version struct might look as follows:\n\n```rust\npub const VERSION: RuntimeVersion = RuntimeVersion {\n spec_name: create_runtime_str!(\"node-template\"),\n impl_name: create_runtime_str!(\"node-template\"),\n authoring_version: 1,\n spec_version: 1,\n impl_version: 1,\n apis: RUNTIME_API_VERSIONS,\n transaction_version: 1,\n};\n```\n\nThe struct provides the following parameter information to the executor:\n\n- **`spec_name`**: The identifier for the different runtimes.\n- **`impl_name`**: The name of the implementation of the spec. Serves only to differentiate code of different implementation teams.\n- **`authoring_version`**: The version of the authorship interface. An authoring node won't attempt to author blocks unless this is equal to its native runtime.\n- **`spec_version`**: The version of the runtime specification. A full node won't attempt to use its native runtime in substitute for the on-chain Wasm runtime unless the `spec_name`, `spec_version`, and `authoring_version` are all the same between the Wasm and native binaries. Updates to the `spec_version` can be automated as a CI process. This parameter is typically incremented when there's an update to the `transaction_version`.\n- **`impl_version`**: The version of the implementation of the specification. Nodes can ignore this. It is only used to indicate that the code is different. As long as the `authoring_version` and the `spec_version` are the same, the code might have changed, but the native and Wasm binaries do the same thing. In general, only non-logic-breaking optimizations would result in a change of the `impl_version`.\n- **`transaction_version`**: The version of the interface for handling transactions. This parameter can be useful to synchronize firmware updates for hardware wallets or other signing devices to verify that runtime transactions are valid and safe to sign. This number must be incremented if there is a change in the index of the pallets in the `construct_runtime!` macro or if there are any changes to dispatchable functions, such as the number of parameters or parameter types. If `transaction_version` is updated, then the `spec_version` must also be updated.\n- **`apis`**: A list of supported [runtime APIs](https://paritytech.github.io/polkadot-sdk/master/sp_api/macro.impl_runtime_apis.html){target=\\_blank} along with their versions.\n\nThe executor follows the same consensus-driven logic for both the native runtime and the Wasm runtime before deciding which to execute. Because runtime versioning is a manual process, there is a risk that the executor could make incorrect decisions if the runtime version is misrepresented or incorrectly defined."} @@ -1254,6 +1248,13 @@ {"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 4, "depth": 3, "title": "Astar XCM Tools", "anchor": "astar-xcm-tools", "start_char": 2667, "end_char": 4207, "estimated_token_count": 369, "token_estimator": "heuristic-v1", "text": "### Astar XCM Tools\n\nThe [Astar parachain](https://github.com/AstarNetwork/Astar/tree/master){target=\\_blank} offers a crate with a set of utilities for interacting with the XCM protocol. The [xcm-tools](https://github.com/AstarNetwork/Astar/tree/master/bin/xcm-tools){target=\\_blank} crate provides a straightforward method for users to locate a sovereign account or calculate an XC20 asset ID. Some commands included by the xcm-tools crate allow users to perform the following tasks:\n\n- **Sovereign accounts**: Obtain the sovereign account address for any parachain, either on the Relay Chain or for sibling parachains, using a simple command.\n- **XC20 EVM addresses**: Generate XC20-compatible Ethereum addresses for assets by entering the asset ID, making it easy to integrate assets across Ethereum-compatible environments.\n- **Remote accounts**: Retrieve remote account addresses needed for multi-location compatibility, using flexible options to specify account types and parachain IDs.\n\nTo start using these tools, clone the [Astar repository](https://github.com/AstarNetwork/Astar){target=\\_blank} and compile the xcm-tools package:\n\n```bash\ngit clone https://github.com/AstarNetwork/Astar &&\ncd Astar &&\ncargo build --release -p xcm-tools\n```\n\nAfter compiling, verify the setup with the following command:\n\n```bash\n./target/release/xcm-tools --help\n```\nFor more details on using Astar xcm-tools, consult the [official documentation](https://docs.astar.network/docs/learn/interoperability/xcm/integration/tools/){target=\\_blank}."} {"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 5, "depth": 3, "title": "Chopsticks", "anchor": "chopsticks", "start_char": 4207, "end_char": 4517, "estimated_token_count": 65, "token_estimator": "heuristic-v1", "text": "### Chopsticks\n\nThe Chopsticks library provides XCM functionality for testing XCM messages across networks, enabling you to fork multiple parachains along with a relay chain. For further details, see the [Chopsticks documentation](/tutorials/polkadot-sdk/testing/fork-live-chains/){target=\\_blank} about XCM."} {"page_id": "reference-tools-xcm-tools", "page_title": "XCM Tools", "index": 6, "depth": 3, "title": "Moonbeam XCM SDK", "anchor": "moonbeam-xcm-sdk", "start_char": 4517, "end_char": 6146, "estimated_token_count": 385, "token_estimator": "heuristic-v1", "text": "### Moonbeam XCM SDK\n\nThe [Moonbeam XCM SDK](https://github.com/moonbeam-foundation/xcm-sdk){target=\\_blank} enables developers to easily transfer assets between chains, either between parachains or between a parachain and the relay chain, within the Polkadot/Kusama ecosystem. With the SDK, you don't need to worry about determining the [Multilocation](https://github.com/polkadot-fellows/xcm-format?tab=readme-ov-file#7-universal-consensus-location-identifiers){target=\\_blank} of the origin or destination assets or which extrinsics are used on which networks.\n\nThe SDK consists of two main packages:\n\n- **[XCM SDK](https://github.com/moonbeam-foundation/xcm-sdk/tree/main/packages/sdk){target=\\_blank}**: Core SDK for executing XCM transfers between chains in the Polkadot/Kusama ecosystem.\n- **[MRL SDK](https://github.com/moonbeam-foundation/xcm-sdk/tree/main/packages/mrl){target=\\_blank}**: Extension of the XCM SDK for transferring liquidity into and across the Polkadot ecosystem from other ecosystems like Ethereum.\n\nKey features include:\n\n- **Simplified asset transfers**: Abstracts away complex multilocation determinations and extrinsic selection.\n- **Cross-ecosystem support**: Enables transfers between Polkadot/Kusama chains and external ecosystems.\n- **Developer-friendly API**: Provides intuitive interfaces for cross-chain functionality.\n- **Comprehensive documentation**: Includes usage guides and API references for both packages.\n\nFor detailed usage examples and API documentation, visit the [official Moonbeam XCM SDK documentation](https://moonbeam-foundation.github.io/xcm-sdk/latest/){target=\\_blank}."} +{"page_id": "reference", "page_title": "Technical Reference Overview", "index": 0, "depth": 2, "title": "Introduction", "anchor": "introduction", "start_char": 0, "end_char": 1097, "estimated_token_count": 199, "token_estimator": "heuristic-v1", "text": "## Introduction\n\nThe Technical Reference section provides comprehensive documentation of Polkadot's architecture, core concepts, and development tooling. Whether you're exploring how Polkadot's relay chain coordinates parachains, understanding governance mechanisms, or building applications on the network, this reference covers the technical foundations you need.\n\nPolkadot is a multi-chain network that enables diverse, interconnected blockchains to share security and communicate seamlessly. Understanding how these components interact from the [relay chain](/polkadot-protocol/glossary#relay-chain){target=\\_blank} that validates [parachains](/polkadot-protocol/glossary#parachain){target=\\_blank} to the [governance](/reference/glossary#governance){target=\\_blank} mechanisms that evolve the protocol is essential for developers, validators, and network participants.\n\nThis guide organizes technical documentation across five core areas: Polkadot Hub, Parachains, On-Chain Governance, Glossary, and Tools, each providing detailed information on different aspects of the Polkadot ecosystem."} +{"page_id": "reference", "page_title": "Technical Reference Overview", "index": 1, "depth": 2, "title": "Polkadot Hub", "anchor": "polkadot-hub", "start_char": 1097, "end_char": 2378, "estimated_token_count": 247, "token_estimator": "heuristic-v1", "text": "## Polkadot Hub\n\n[Polkadot Hub](/reference/polkadot-hub/){target=\\_blank} is the entry point to Polkadot for all users and application developers. It provides access to essential Web3 services, including smart contracts, staking, governance, identity management, and cross-ecosystem interoperability—without requiring you to deploy or manage a parachain.\n\nThe Hub encompasses a set of core functionality that enables developers and users to build and interact with applications on Polkadot. Key capabilities include:\n\n- **Smart contracts**: Deploy Ethereum-compatible smart contracts and build decentralized applications.\n- **Assets and tokens**: Create, manage, and transfer fungible tokens and NFTs across the ecosystem.\n- **Staking**: Participate in network security and earn rewards by staking DOT.\n- **Governance**: Vote on proposals and participate in Polkadot's decentralized decision-making through OpenGov.\n- **Identity services**: Register and manage on-chain identities, enabling access to governance roles and network opportunities.\n- **Cross-chain interoperability**: Leverage XCM messaging to interact securely with other chains in the Polkadot ecosystem.\n- **Collectives and DAOs**: Participate in governance collectives and decentralized autonomous organizations."} +{"page_id": "reference", "page_title": "Technical Reference Overview", "index": 2, "depth": 2, "title": "Parachains", "anchor": "parachains", "start_char": 2378, "end_char": 3697, "estimated_token_count": 293, "token_estimator": "heuristic-v1", "text": "## Parachains\n\n[Parachains](/reference/parachains/){target=\\_blank} are specialized blockchains that connect to the Polkadot relay chain, inheriting its security while maintaining their own application-specific logic. The parachains documentation covers:\n\n- **Accounts**: Deep dive into account types, storage, and management on parachains.\n- **Blocks, transactions and fees**: Understand block production, transaction inclusion, and fee mechanisms.\n- **Consensus**: Learn how parachain blocks are validated and finalized through the relay chain's consensus.\n- **Chain data**: Explore data structures, storage layouts, and state management.\n- **Cryptography**: Study cryptographic primitives used in Polkadot SDK-based chains.\n- **Data encoding**: Understand how data is encoded and decoded for blockchain compatibility.\n- **Networks**: Learn about networking protocols and peer-to-peer communication.\n- **Interoperability**: Discover [Cross-Consensus Messaging (XCM)](/parachains/interoperability/get-started/){target=\\_blank}, the standard for cross-chain communication.\n- **Randomness**: Understand how randomness is generated and used in Polkadot chains.\n- **Node and runtime**: Learn about parachain nodes, runtime environments, and the [Polkadot SDK](https://github.com/paritytech/polkadot-sdk){target=\\_blank}."} +{"page_id": "reference", "page_title": "Technical Reference Overview", "index": 3, "depth": 2, "title": "On-Chain Governance", "anchor": "on-chain-governance", "start_char": 3697, "end_char": 4577, "estimated_token_count": 170, "token_estimator": "heuristic-v1", "text": "## On-Chain Governance\n\n[On-Chain governance](/reference/governance/){target=\\_blank} is the decentralized decision-making mechanism for the Polkadot network. It manages the evolution and modification of the network's runtime logic, enabling community oversight and approval for proposed changes. The governance documentation details:\n\n- **OpenGov framework**: Understand Polkadot's next-generation governance system with enhanced delegation, flexible tracks, and simultaneous referendums.\n- **Origins and tracks**: Learn how governance proposals are categorized, prioritized, and executed based on their privilege level and complexity.\n- **Voting and delegation**: Explore conviction voting, vote delegation, and how token holders participate in governance.\n- **Governance evolution**: See how Polkadot's governance has evolved from Governance V1 to the current OpenGov system."} +{"page_id": "reference", "page_title": "Technical Reference Overview", "index": 4, "depth": 2, "title": "Glossary", "anchor": "glossary", "start_char": 4577, "end_char": 5018, "estimated_token_count": 90, "token_estimator": "heuristic-v1", "text": "## Glossary\n\nThe [Glossary](/reference/glossary/){target=\\_blank} provides quick-reference definitions for Polkadot-specific terminology. Essential terms include:\n\n- Blockchain concepts (blocks, transactions, state)\n- Consensus mechanisms (validators, collators, finality)\n- Polkadot-specific terms (relay chain, parachain, XCM, FRAME)\n- Network components (nodes, runtimes, storage)\n- Governance terminology (origins, tracks, referendums)"} +{"page_id": "reference", "page_title": "Technical Reference Overview", "index": 5, "depth": 2, "title": "Tools", "anchor": "tools", "start_char": 5018, "end_char": 6285, "estimated_token_count": 349, "token_estimator": "heuristic-v1", "text": "## Tools\n\nThe [Tools](/reference/tools/){target=\\_blank} section documents essential development and interaction tools for the Polkadot ecosystem:\n\n- **Light clients**: Lightweight solutions for interacting with the network without running full nodes.\n- **JavaScript/TypeScript tools**: Libraries like [Polkadot.js API](/reference/tools/polkadot-js-api/){target=\\_blank} and [PAPI](/reference/tools/papi/){target=\\_blank} for building applications.\n- **Rust tools**: [Polkadart](/reference/tools/polkadart/){target=\\_blank} and other Rust-based libraries for SDK development.\n- **Python tools**: [py-substrate-interface](/reference/tools/py-substrate-interface/){target=\\_blank} for Python developers.\n- **Testing and development**: Tools like [Moonwall](/reference/tools/moonwall/){target=\\_blank}, [Chopsticks](/reference/tools/chopsticks/){target=\\_blank}, and [Omninode](/reference/tools/omninode/){target=\\_blank} for smart contract and parachain testing.\n- **Indexing and monitoring**: [Sidecar](/reference/tools/sidecar/){target=\\_blank} for data indexing and [Dedot](/reference/tools/dedot/){target=\\_blank} for substrate interaction.\n- **Cross-chain tools**: [ParaSpell](/reference/tools/paraspell/){target=\\_blank} for XCM integration and asset transfers."} +{"page_id": "reference", "page_title": "Technical Reference Overview", "index": 6, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 6285, "end_char": 7648, "estimated_token_count": 334, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nFor detailed exploration of specific areas, proceed to any of the main sections:\n\n
\n\n- Learn **Polkadot Hub**\n\n ---\n\n Understand the relay chain's role in coordinating parachains, providing shared security, and enabling governance.\n\n [:octicons-arrow-right-24: Reference](/reference/polkadot-hub/)\n\n- Learn **Parachains**\n\n ---\n\n Deep dive into parachain architecture, consensus, data structures, and building application-specific blockchains.\n\n [:octicons-arrow-right-24: Reference](/reference/parachains/)\n\n- Learn **On-Chain Governance**\n\n ---\n\n Explore Polkadot's decentralized governance framework and how to participate in network decision-making.\n\n [:octicons-arrow-right-24: Reference](/reference/governance/)\n\n- Guide **Glossary**\n\n ---\n\n Quick reference for Polkadot-specific terminology and concepts used throughout the documentation.\n\n [:octicons-arrow-right-24: Reference](/reference/glossary/)\n\n- Guide **Tools**\n\n ---\n\n Discover development tools, libraries, and frameworks for building and interacting with Polkadot.\n\n [:octicons-arrow-right-24: Reference](/reference/tools/)\n\n
"} {"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 0, "depth": 2, "title": "Networks Details", "anchor": "networks-details", "start_char": 951, "end_char": 1604, "estimated_token_count": 137, "token_estimator": "heuristic-v1", "text": "## Networks Details\n\nDevelopers can leverage smart contracts across diverse networks, from TestNets to MainNet. This section outlines the network specifications and connection details for each environment.\n\n=== \"Polkadot Hub TestNet\"\n\n Network name\n\n ```text\n Polkadot Hub TestNet\n ```\n\n ---\n\n Currency symbol\n \n ```text\n PAS\n ```\n\n ---\n \n Chain ID\n \n ```text\n 420420422\n ```\n\n ---\n \n RPC URL\n \n ```text\n https://testnet-passet-hub-eth-rpc.polkadot.io\n ```\n\n ---\n \n Block explorer URL\n \n ```text\n https://blockscout-passet-hub.parity-testnet.parity.io/\n ```"} {"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 1, "depth": 2, "title": "Test Tokens", "anchor": "test-tokens", "start_char": 1604, "end_char": 2618, "estimated_token_count": 233, "token_estimator": "heuristic-v1", "text": "## Test Tokens\n\nYou will need testnet tokens to perform transactions and engage with smart contracts on any chain. Here's how to obtain Paseo (PAS) tokens for testing purposes:\n\n1. Navigate to the [Polkadot Faucet](https://faucet.polkadot.io/?parachain=1111){target=\\_blank}. If the desired network is not already selected, choose it from the Network drop-down.\n\n2. Copy your address linked to the TestNet and paste it into the designated field.\n\n ![](/images/smart-contracts/connect/connect-to-polkadot-01.webp)\n\n3. Click the **Get Some PASs** button to request free test PAS tokens. These tokens will be sent to your wallet shortly.\n\n ![](/images/smart-contracts/connect/connect-to-polkadot-02.webp)\n\nNow that you have obtained PAS tokens in your wallet, you’re ready to deploy and interact with smart contracts on Polkadot Hub TestNet! These tokens will allow you to pay for gas fees when executing transactions, deploying contracts, and testing your dApp functionality in a secure testnet environment."} {"page_id": "smart-contracts-connect", "page_title": "Connect to Polkadot", "index": 2, "depth": 2, "title": "Where to Go Next", "anchor": "where-to-go-next", "start_char": 2618, "end_char": 3459, "estimated_token_count": 188, "token_estimator": "heuristic-v1", "text": "## Where to Go Next\n\nFor your next steps, explore the various smart contract guides demonstrating how to use and integrate different tools and development environments into your workflow.\n\n
\n\n- Guide __Deploy your first contract with Remix__\n\n ---\n\n Explore the smart contract development and deployment process on Polkadot Hub using the Remix IDE.\n\n [:octicons-arrow-right-24: Build with Remix IDE](/smart-contracts/dev-environments/remix/get-started/)\n\n- Guide __Interact with the blockchain with viem__\n\n ---\n\n Use viem for interacting with Ethereum-compatible chains, to deploy and interact with smart contracts on Polkadot Hub.\n\n [:octicons-arrow-right-24: Build with viem](/smart-contracts/libraries/viem/)\n\n
"} diff --git a/llms.txt b/llms.txt index 802acd0d5..7aef2c5f4 100644 --- a/llms.txt +++ b/llms.txt @@ -45,6 +45,7 @@ Docs: Basics - [Parachains Overview](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-parachains.md): Learn about parachains, specialized blockchains on Polkadot that gain shared security and interoperability. Discover how they work and the tools to build them. - [Overview of the Polkadot Relay Chain](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-relay-chain.md): Explore Polkadot's core architecture, including its multi-chain vision, shared security, and the DOT token's governance and staking roles. - [XCM Tools](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-xcm-tools.md): Explore essential XCM tools across Polkadot, crafted to enhance cross-chain functionality and integration within the ecosystem. +- [Technical Reference Overview](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md): Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. - [Deploy an ERC-20 to Polkadot Hub](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20-erc20-remix.md): Deploy an ERC-20 token contract on Polkadot Hub. This guide covers contract creation, compilation, deployment, and interaction via the Remix IDE. - [Deploy an ERC-20 to Polkadot Hub](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-erc20.md): Deploy an ERC-20 token on Polkadot Hub using PolkaVM. This guide covers contract creation, compilation, deployment, and interaction via Polkadot Remix IDE. - [Deploy an NFT to Polkadot Hub with Ethers.js](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-nft-ethers.md): Learn how to deploy an ERC-721 NFT contract to Polkadot Hub using Ethers.js, giving you complete programmatic control over the deployment process. @@ -202,6 +203,7 @@ Docs: Polkadot Protocol - [Proof of Stake Consensus](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-pos-consensus.md): Explore Polkadot's consensus protocols for secure, scalable, and decentralized network operation, including NPoS, BABE, GRANDPA, and BEEFY. - [Overview of the Polkadot Relay Chain](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-consensus-and-security-relay-chain.md): Explore Polkadot's core architecture, including its multi-chain vision, shared security, and the DOT token's governance and staking roles. - [People Chain](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-polkadot-hub-people-and-identity.md): Learn how People chain secures decentralized identity management, empowering users to control and verify digital identities without central authorities. +- [Technical Reference Overview](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md): Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. - [Accounts in Asset Hub Smart Contracts](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-accounts.md): Bridges Ethereum's 20-byte addresses with Polkadot's 32-byte accounts, enabling seamless interaction while maintaining compatibility with Ethereum tooling. - [Transactions and Fees on Asset Hub](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-blocks-transactions-fees.md): Explore how Asset Hub smart contracts handle blocks, transactions, and fees with EVM compatibility, supporting various Ethereum transaction types. - [Dual Virtual Machine Stack](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-dual-vm-stack.md): Compare Polkadot’s dual smart contract VMs—REVM for EVM compatibility and PolkaVM for RISC-V performance, flexibility, and efficiency. @@ -264,6 +266,7 @@ Docs: Reference - [XCM Config](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-interoperability-xcm-config.md): Learn how the XCM Executor configuration works for your custom Polkadot SDK-based runtime with detailed guidance and references. - [XCM Runtime APIs](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/develop-interoperability-xcm-runtime-apis.md): Learn about XCM Runtime APIs in Polkadot for cross-chain communication. Explore the APIs to simulate and test XCM messages before execution on the network. - [Glossary](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-glossary.md): Glossary of terms used within the Polkadot ecosystem, Polkadot SDK, its subsequent libraries, and other relevant Web3 terminology. +- [Technical Reference Overview](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md): Learn about Polkadot's technical architecture, governance framework, parachain ecosystem, and the tools you need to build and interact with the network. - [JSON-RPC APIs](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-for-eth-devs-json-rpc-apis.md): JSON-RPC APIs guide for Polkadot Hub, covering supported methods, parameters, and examples for interacting with the chain. Docs: Chain Interactions @@ -356,7 +359,6 @@ Docs: Uncategorized - [reference-tools-chopsticks](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-chopsticks.md): No description available. - [ParaSpell XCM SDK](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-paraspell.md): A powerful open-source library that simplifies XCM integration, enabling developers to easily build interoperable dApps on Polkadot. - [reference-tools-zombienet](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference-tools-zombienet.md): No description available. -- [reference](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/reference.md): No description available. - [smart-contracts-cookbook-smart-contracts-deploy-basic](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-cookbook-smart-contracts-deploy-basic.md): No description available. - [smart-contracts-dev-environments-foundry-compile-and-test](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-dev-environments-foundry-compile-and-test.md): No description available. - [smart-contracts-dev-environments-foundry-deploy-a-contract](https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/smart-contracts-dev-environments-foundry-deploy-a-contract.md): No description available. From d81697fc3fc4aca389102c72a7f341352cf5fb8d Mon Sep 17 00:00:00 2001 From: Taylor Lucero Date: Thu, 13 Nov 2025 11:06:23 -0500 Subject: [PATCH 08/10] Formatting --- .../pallet-development/pallet-testing.md | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/parachains/customize-runtime/pallet-development/pallet-testing.md b/parachains/customize-runtime/pallet-development/pallet-testing.md index f33a35229..a7846e29b 100644 --- a/parachains/customize-runtime/pallet-development/pallet-testing.md +++ b/parachains/customize-runtime/pallet-development/pallet-testing.md @@ -8,35 +8,35 @@ categories: Parachains ## Introduction -Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation. +Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the [previous guide](/parachains/customize-runtime/pallet-development/mock-runtime/), you can now write comprehensive tests that verify your pallet's behavior in isolation. In this guide, you'll learn how to: -- Structure test modules effectively -- Test dispatchable functions -- Verify storage changes -- Check event emission -- Test error conditions -- Use genesis configurations in tests +- Structure test modules effectively. +- Test dispatchable functions. +- Verify storage changes. +- Check event emission. +- Test error conditions. +- Use genesis configurations in tests. ## Prerequisites -Before you begin, ensure you have: +Before you begin, ensure you: -- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide -- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide -- The custom counter pallet with mock runtime in `pallets/pallet-custom` -- Basic understanding of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\_blank} +- Completed the [Make a Custom Pallet](/parachains/customize-runtime/pallet-development/create-a-pallet/) guide. +- Completed the [Mock Your Runtime](/parachains/customize-runtime/pallet-development/mock-runtime/) guide. +- Configured custom counter pallet with mock runtime in `pallets/pallet-custom`. +- Understood the basics of [Rust testing](https://doc.rust-lang.org/book/ch11-00-testing.html){target=\_blank}. ## Understanding FRAME Testing Tools -FRAME provides specialized testing macros and utilities that make pallet testing more efficient: +[FRAME](/reference/glossary/#frame-framework-for-runtime-aggregation-of-modularized-entities){target=\_blank} provides specialized testing macros and utilities that make pallet testing more efficient: ### Assertion Macros - **[`assert_ok!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_ok.html){target=\_blank}** - Asserts that a dispatchable call succeeds. - **[`assert_noop!`](https://paritytech.github.io/polkadot-sdk/master/frame_support/macro.assert_noop.html){target=\_blank}** - Asserts that a call fails without changing state (no operation). -- **`assert_eq!`** - Standard Rust equality assertion. +- **[`assert_eq!`](https://doc.rust-lang.org/std/macro.assert_eq.html){target=\_blank}** - Standard Rust equality assertion. !!!info "`assert_noop!` Explained" Use `assert_noop!` to ensure the operation fails without any state changes. This is critical for testing error conditions - it verifies both that the error occurs AND that no storage was modified. @@ -261,10 +261,11 @@ Verify that events are emitted correctly with the right data. ### Test Event Data -The `increment_works` test (shown earlier) already demonstrates event testing by: -1. Setting the block number to 1 to enable event emission -2. Calling the dispatchable function -3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data +The [`increment_works`](/parachains/customize-runtime/pallet-development/pallet-testing/#test-basic-increment) test (shown earlier) already demonstrates event testing by: + +1. Setting the block number to 1 to enable event emission. +2. Calling the dispatchable function. +3. Using `System::assert_last_event()` to verify the correct event was emitted with expected data. This pattern applies to all dispatchables that emit events. For a dedicated event-only test focusing on the `set_counter_value` function: From d074804e78d0ea37ee5727646aba7ef29cf3f74d Mon Sep 17 00:00:00 2001 From: Taylor Lucero Date: Thu, 13 Nov 2025 11:17:37 -0500 Subject: [PATCH 09/10] terminal element --- .../pallet-development/pallet-testing.md | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/parachains/customize-runtime/pallet-development/pallet-testing.md b/parachains/customize-runtime/pallet-development/pallet-testing.md index a7846e29b..7ee83532b 100644 --- a/parachains/customize-runtime/pallet-development/pallet-testing.md +++ b/parachains/customize-runtime/pallet-development/pallet-testing.md @@ -332,26 +332,29 @@ cargo test --package pallet-custom You should see all tests passing: -``` -running 15 tests -test mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok -test mock::test_genesis_config_builds ... ok -test tests::decrement_fails_on_underflow ... ok -test tests::decrement_tracks_multiple_interactions ... ok -test tests::decrement_works ... ok -test tests::different_users_tracked_separately ... ok -test tests::genesis_config_works ... ok -test tests::increment_fails_on_overflow ... ok -test tests::increment_respects_max_value ... ok -test tests::increment_tracks_multiple_interactions ... ok -test tests::increment_works ... ok -test tests::mixed_increment_and_decrement_works ... ok -test tests::set_counter_value_requires_root ... ok -test tests::set_counter_value_respects_max_value ... ok -test tests::set_counter_value_works ... ok -test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` +
+ $ cargo test --package pallet-custom + running 15 tests + test mock::__construct_runtime_integrity_test::runtime_integrity_tests ... ok + test mock::test_genesis_config_builds ... ok + test tests::decrement_fails_on_underflow ... ok + test tests::decrement_tracks_multiple_interactions ... ok + test tests::decrement_works ... ok + test tests::different_users_tracked_separately ... ok + test tests::genesis_config_works ... ok + test tests::increment_fails_on_overflow ... ok + test tests::increment_respects_max_value ... ok + test tests::increment_tracks_multiple_interactions ... ok + test tests::increment_works ... ok + test tests::mixed_increment_and_decrement_works ... ok + test tests::set_counter_value_requires_root ... ok + test tests::set_counter_value_respects_max_value ... ok + test tests::set_counter_value_works ... ok + + test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +
+ !!!note "Mock Runtime Tests" You'll notice 2 additional tests from the `mock` module: From db8af0c82bb294d99008fea484f973275b1921e3 Mon Sep 17 00:00:00 2001 From: Taylor Lucero Date: Thu, 13 Nov 2025 11:19:59 -0500 Subject: [PATCH 10/10] fix spacing --- .../customize-runtime/pallet-development/pallet-testing.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/parachains/customize-runtime/pallet-development/pallet-testing.md b/parachains/customize-runtime/pallet-development/pallet-testing.md index 7ee83532b..1bc102974 100644 --- a/parachains/customize-runtime/pallet-development/pallet-testing.md +++ b/parachains/customize-runtime/pallet-development/pallet-testing.md @@ -332,7 +332,6 @@ cargo test --package pallet-custom You should see all tests passing: -
$ cargo test --package pallet-custom running 15 tests @@ -355,7 +354,6 @@ You should see all tests passing: test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
- !!!note "Mock Runtime Tests" You'll notice 2 additional tests from the `mock` module: