# Pezkuwi SDK's Teyrchain Template

> This is a template for creating a [teyrchain](https://wiki.network.pezkuwichain.io/docs/learn-parachains) based on Pezkuwi SDK.
>
> This template is automatically updated after releases in the main [Pezkuwi SDK monorepo](https://github.com/pezkuwichain/pezkuwi-sdk).
## Table of Contents
- [Intro](#intro)
- [Template Structure](#template-structure)
- [Getting Started](#getting-started)
- [Starting a Development Chain](#starting-a-development-chain)
- [Omni Node](#omni-node-prerequisites)
- [Zombienet setup with Omni Node](#zombienet-setup-with-omni-node)
- [Teyrchain Template Node](#teyrchain-template-node)
- [Connect with the Pezkuwi-JS Apps Front-End](#connect-with-the-pezkuwi-js-apps-front-end)
- [Takeaways](#takeaways)
- [Runtime development](#runtime-development)
- [Contributing](#contributing)
- [Getting Help](#getting-help)
## Intro
- โซ This template provides a starting point to build a [teyrchain](https://wiki.network.pezkuwichain.io/docs/learn-parachains).
- โ๏ธ It is based on the
[Pezcumulus](https://docs.pezkuwichain.io/sdk/master/polkadot_sdk_docs/polkadot_sdk/pezcumulus/index.html) framework.
- ๐ง Its runtime is configured with a single custom pezpallet as a starting point, and a handful of ready-made pallets
such as a [Balances pezpallet](https://docs.pezkuwichain.io/sdk/master/pallet_balances/index.html).
- ๐ Learn more about teyrchains in the [Pezkuwi Wiki](https://wiki.network.pezkuwichain.io/docs/learn-teyrchains)
## Template Structure
A Pezkuwi SDK based project such as this one consists of:
- ๐งฎ the [Runtime](./runtime/README.md) - the core logic of the teyrchain.
- ๐จ the [Pallets](./pallets/README.md) - from which the runtime is constructed.
- ๐ฟ a [Node](./node/README.md) - the binary application, not part of the project default-members list and not compiled unless
building the project with `--workspace` flag, which builds all workspace members, and is an alternative to
[Omni Node](https://docs.pezkuwichain.io/sdk/master/polkadot_sdk_docs/reference_docs/omni_node/index.html).
## Getting Started
- ๐ฆ The template is using the Rust language.
- ๐ Check the
[Rust installation instructions](https://www.rust-lang.org/tools/install) for your system.
- ๐ ๏ธ Depending on your operating system and Rust version, there might be additional
packages required to compile this template - please take note of the Rust compiler output.
Fetch teyrchain template code:
```sh
git clone https://github.com/pezkuwichain/pezkuwi-sdk-teyrchain-template.git teyrchain-template
cd teyrchain-template
```
## Starting a Development Chain
The teyrchain template relies on a hardcoded teyrchain id which is defined in the runtime code
and referenced throughout the contents of this file as `{{TEYRCHAIN_ID}}`. Please replace
any command or file referencing this placeholder with the value of the `TEYRCHAIN_ID` constant:
```rust,ignore
pub const TEYRCHAIN_ID: u32 = 1000;
```
### Omni Node Prerequisites
[Omni Node](https://docs.pezkuwichain.io/sdk/master/polkadot_sdk_docs/reference_docs/omni_node/index.html) can
be used to run the teyrchain template's runtime. `pezkuwi-omni-node` binary crate usage is described at a high-level
[on crates.io](https://crates.io/crates/polkadot-omni-node).
#### Install `pezkuwi-omni-node`
```sh
cargo install pezkuwi-omni-node
```
> For more advanced options, please see the installation section at [`crates.io/omni-node`](https://crates.io/crates/polkadot-omni-node).
#### Build `teyrchain-template-runtime`
```sh
cargo build --profile production
```
#### Install `pezstaging-chain-spec-builder`
```sh
cargo install pezstaging-chain-spec-builder
```
> For more advanced options, please see the installation section at [`crates.io/pezstaging-chain-spec-builder`](https://crates.io/crates/pezstaging-chain-spec-builder).
#### Use `chain-spec-builder` to generate the `chain_spec.json` file
```sh
chain-spec-builder create --relay-chain "pezkuwichain-local" --runtime \
target/release/wbuild/teyrchain-template-runtime/teyrchain_template_runtime.wasm named-preset development
```
**Note**: the `relay-chain` flag is required by Omni Node. The `relay-chain` value is set in accordance
with the relay chain ID where this instantiation of teyrchain-template will connect to.
#### Run Omni Node
Start Omni Node with the generated chain spec. We'll start it in development mode (without a relay chain config), producing
and finalizing blocks based on manual seal, configured below to seal a block with each second.
```bash
pezkuwi-omni-node --chain