Skip to content

🧩 PragmaX, a provable oracle built as a custom starknet L3, powered by Rust 🦀

License

Notifications You must be signed in to change notification settings

astraly-labs/pragma-x

 
 

Repository files navigation

Madara App Chain Template

A fresh Madara app chain, ready for hacking 🚀

All bugs, suggestions, and feature requests should be made upstream in the Madara repository.

Getting Started

Depending on your operating system and Rust version, there might be additional packages required to compile this template. Check the Install instructions for your platform for the most common dependencies. Alternatively, you can use one of the alternative installation options.

Build

Use the following command to build the node without launching it:

cargo build --release

Embedded Docs

After you build the project, you can use the following command to explore its parameters and subcommands:

./target/release/app-chain-node -h

You can generate and view the Rust Docs for this template with this command:

cargo +nightly doc --open

Single-Node Development Chain

The following command starts a single-node development chain.

./target/release/app-chain-node --dev

Please note, Madara overrides the default dev flag in substrate to meet it's requirements. The following flags are automatically enabled with the --dev argument:

--alice, --rpc_external,--rpc-methods=unsafe,--force-authoring

To store the chain state in a specific folder, use the following command

./target/release/app-chain-node --base-path <path>

To start the development chain from a new fresh state you can either delete the data from the base-path or start from a new fresh database on each start using the following command

./target/release/app-chain-node --dev --tmp

To start the development chain with detailed logging, run the following command:

RUST_BACKTRACE=1 ./target/release/app-chain-node -ldebug --dev

Connect with Polkadot-JS Apps Front-End

After you start the app chain locally, you can interact with it using the hosted version of the Polkadot/Substrate Portal front-end by connecting to the local node endpoint. A hosted version is also available on IPFS (redirect) here or IPNS (direct) here. You can also find the source code and instructions for hosting your own instance on the polkadot-js/apps repository.

Multi-Node Local Testnet

If you want to see the multi-node consensus algorithm in action, see Simulate a network.

Template Structure

The app chain template gives you complete flexibility to modify exiting features of Madara and add new features as well.

Existing Pallets

Madara comes with only one pallet - pallet_starknet. This pallet allows app chains to execute Cairo contracts and have 100% RPC compatabiltiy with Starknet mainnet. This means all Cairo tooling should work out of the box with the app chain. At the same time, the pallet also allows the app chain to fine tune specific parameters to meet their own needs.

  • DisableTransactionFee: If true, calculate and store the Starknet state commitments
  • DisableNonceValidation: If true, check and increment nonce after a transaction
  • InvokeTxMaxNSteps: Maximum number of Cairo steps for an invoke transaction
  • ValidateMaxNSteps: Maximum number of Cairo steps when validating a transaction
  • MaxRecursionDepth: Maximum recursion depth for transactions
  • ChainId: The chain id of the app chain

All these options can be configured inside crates/runtime/src/pallets.rs

Genesis

The genesis state of the app chain is defined via a JSON file. It lives inside the config folder but can also be fetch from a url. You can read in more detail about how to setup the config from these two docs in the Madara repo.

New Pallets

Adding a new pallet is the same as adding a pallet in any substrate based chain. An an example, pallet-template has been added on this template. You can read more about it here.

Runtime configuration

Similar to new pallets, runtime configurations can be just like they're done in Substrate. You can edit all the available parameters inside crates/runtime/src/config.rs.

For example, to change the block time, you can edit the MILLISECS_PER_BLOCK variable.

Alternatives Installations

Instead of installing dependencies and building this source directly, consider the following alternatives.

Nix

Install nix, and optionally direnv and lorri for a fully plug-and-play experience for setting up the development environment. To get all the correct dependencies, activate direnv direnv allow and lorri lorri shell.

Docker

Please use the Madara Dockerfile as a reference to build the Docker container with your App Chain node as a binary.

About

🧩 PragmaX, a provable oracle built as a custom starknet L3, powered by Rust 🦀

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 61.9%
  • Cairo 36.4%
  • Other 1.7%