cardano_sdk/
chaininfo.rs

1//! Existing chain parameters for given chains (mainnet, preview, ..)
2
3use crate::protocol::Magic;
4
5/// Chain info hold all the specifics value for a given chain (MAINNET/TESTNET/...)
6#[derive(Clone, Debug)]
7pub struct ChainInfo {
8    pub protocol_magic: Magic,
9    pub network_id: u8, // only 4 bits
10    pub bech32_hrp_address: &'static str,
11}
12
13impl ChainInfo {
14    pub const MAINNET: Self = Self {
15        protocol_magic: Magic::MAINNET,
16        network_id: 0b0001,
17        bech32_hrp_address: "addr",
18    };
19
20    pub const TESTNET: Self = Self {
21        protocol_magic: Magic::TESTNET,
22        network_id: 0b0000,
23        bech32_hrp_address: "addr_test",
24    };
25
26    pub const PREPROD: Self = Self {
27        protocol_magic: Magic::PREPROD,
28        network_id: 0b0000,
29        bech32_hrp_address: "addr_test",
30    };
31
32    pub const PREVIEW: Self = Self {
33        protocol_magic: Magic::PREVIEW,
34        network_id: 0b0000,
35        bech32_hrp_address: "addr_test",
36    };
37}