How to launch your first App-Chain with Madara
This guide will walk you through the process of launching your own App Chain using Madara.
Quick start tutorial
As an introduction to the following section, we created a video tutorial to give you more context how to launch your own App Chain.
/video goes here/
Step by step tutorial
Understand Madara Components
Now that you have some context around the Madara client, it's important to understand the fundamental components of Madara and how it functions as a Starknet client.
-
Chain Architecture: Madara currently works exactly like Starknet mainnet with a centralized sequencer that will produce the state of your chain. This one will then serve the data for proving trough SNOS and Sharp (the zk-stark prover). This means that your sequencer is the only one capable of producing state. You can then connect as many full nodes as you like to it. We recommend you to familiarize yourself with the architecture (opens in a new tab) to understand how the entire flow works.
-
Bootstrapper: To easily deploy your first set of contracts and authority accounts you'll have to use Madara Bootstrapper.
-
Smart Contracts: Madara allows you to deploy and interact with Cairo smart contracts. Understanding Cairo contracts will help you make the most of your self-hosted chain.
-
Interacting: Madara is 100% compatible with the latest Starknet specs. You can then easily interact with your Madara client trough its JSON-RPC endpoint or FGW.
Install Madara
This installation process will help you build the binary directly from the source code locally on your machine.
You'll find other installation methods such as Docker in the Installation section of the Node Operator category.
Install dependencies
We first need to make sure you have everything needed to complete this tutorial.
Dependency | Version | Installation |
---|---|---|
Rust | rustc 1.78 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs sh |
Clang | Latest | sudo apt-get install clang |
Scarb | v2.8.2 | curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh |
Get code
Fetch the code from the Official Madara (opens in a new tab) repository in the folder of your choice.
cd <your-destination-path>
git clone https://github.com/madara-alliance/madara .
Build program
Then let's build the dependencies. You can choose between 3 different build modes:
- Debug (fastest build mode, but lower performances, for testing purpose only)
cargo build
- Release (the recommend build mode)
cargo build --release
- Production (the recommend build mode for production performances)
cargo build --profile=production
Run Madara
This command will start the Madara client with a basic set arguments which will begin a basic deployment depending on your chosen mode:
cargo run --release -- \
--name Madara \
--sequencer
--base-path /var/lib/madara \
--l1-endpoint ${ETHEREUM_API_URL}
We recommend you to head up to the Configuration section to custom your client parameters
If you don't have an L1 endpoint url we recommend you to head up to the Verification section to get one
Now if you've ran the above command you should see an error like that:
Error: In Sequencer mode, you must define a Chain config path with `--chain-config-path <CHAIN CONFIG FILE PATH>` or use a preset with `--preset <PRESET NAME>`.
You now have your first App Chain running! We now recommend you to customize it in the following tutorial How to customize your App Chain.