Chain ID

Configuring Chain ID

Fetching your Chain ID:

The default chain ID on Madara is SN_GOERLI, to verify your chain ID, a POST call can be made to the RPC endpoint.

Initiate RPC Request:

    curl --location 'http://localhost:9944' \
    --header 'Content-Type: application/json' \
    --data '{
        "id": 0,
        "jsonrpc": "2.0",
        "method": "starknet_chainId",
        "params": {}

Parse Response:

Extract the chain ID in hex format from the "result" field within the JSON response.

        "jsonrpc": "2.0",
        "result": "0x534e5f474f45524c49",
        "id": 0

Translate Hex:

Use a hex converter tool (e.g., (opens in a new tab)) to obtain the readable string representation of the chain ID.

Setting a custom Chain ID:

The Chain ID for your Madara app chain is configured in crates/runtime/src/ In Madara your chain ID is represented as the montgomery representation for a string. To update this follow the below steps;

Define your Chain ID:

Choose a string to represent your app chain.

Convert Chain ID to felt

Navigate to and input your chosen string. The generated felt value is your hexadecimal representation for the string. stack

Generate montgomery representation:

Use Starkli to convert the felt value to a montgomery representation compatible with Madara.

starkli mont 85046245544016

Update the Chain ID:

Open crates/primitives/chain-id/src/ and add your Chain ID alongside existing definitions:

pub const MY_APP_CHAIN_ID: Felt252Wrapper = Felt252Wrapper(starknet_ff::FieldElement::from_mont([


Rebuild your Madara app chain with the updated file. Your app chain will now operate with your custom Chain ID.