# Multichain Framework

## What is Multichain?

The multichain architecture is the organizational structure of co-existing blockchains within Plian, it contains one main chain and a number of parallel subchains. Each one of the parallel chains is secured by the nodes within it and pegged to the main chain, tying all chains together.&#x20;

## Responsibilities of Different Types of Chains

Plian has two types of chains, one is the main chain, which is the primary chain that everything is pegged to, and the other is subchains that help segregate network traffic for scalability and personalization.&#x20;

The main chain is responsible for balance record/transfer, and storage of subchain's data. The subchains are responsible for running smart contracts. For both main chain and subchains, PI is used to pay for the transaction execution. PI in main and subchains have the same value and can be used interchangeably and transferred between chains, with the total supply of PI and generation of new supply coming from the main chain.

## Multichain Architecture

Each chain has its own stack consisting of consensus mechanism, transaction structure, block structure, and EVM.

In Plian, the main chain and subchains run their stacks separately across the nodes operating within them. These stacks share the same logic for most modules, such as the consensus algorithm (PDBFT),  processing of transactions, block storage, execution of EVM, etc.

The difference between main chain’s and subchain’s stack is in the execution and deployment of smart contracts.&#x20;

Each chain consists of the following layers:

*   **RPC**

    Plian writes specific RPC logic for multi-chain with each subchain handling its own RPC requirements individually. When making RPC calls, specify chain by adding chain id in url’s path. For example, when access subchain ‘childchain-0’, the url to POST is [http://pchain-node/childchain-0](http://pchain-node/childchain-0).
*   **p2p**

    By taking advantage of the design of Ethereum’s P2P module, when a new chain is initiated, simply adding the mapping of chain and one sub protocol into ProtocolManager allows the network to adapt and route p2p messages to the proper chains.
*   **ChainManager and CrossChainHelper**

    There are 2 application entities operating outside the stacks that coordinate the chains. One is ChainManager, which holds all chain’s information such as epochs, the validators list, and also manages the initializing/start process of all chains.

    Another is CrossChainHelper, which is injected into every chain’s stack. When main/subchain needs to retrieve cross-chain information or call cross-chain functions, CrossChainHelper handles the request.

## What does Multichain Architecture Offer?

### Easily Create Private or Public Blockchains for Enterprise Use

Two of the main hurdles for enterprise use of blockchain is the cost of operating on public blockchains (fees and scalability) and the security offered by using cheaper alternatives (economic security and decentralization). Plian solves this by enabling the creation of public or private subchains to affordably integrate blockchain into their business while benefitting from the security of a much more established blockchain network from pegging to the main chain.&#x20;

### Multi-chain Co-operation to Achieve Large Scale Business Logic

Because each chain has its own processing power and independent EVM, business modules can be split apart and run independently of each other and deployed across several subchains. This enables large scale business logic that was previously unable to operate on blockchain, to be split and operate all within one blockchain network.&#x20;
