6

There are a lots of tutorials in Cardano CLI that uses --testnet-magic 3 or --testnet-magic 4 during reading values in address, minting native tokens etc. But none of them explain in detail about what actually the magic number is and how do we determine what magic number is to use?

For reference, there is an official doc that uses magic number 42 but I got lost trying to understand it.

paradox
  • 303
  • 3
  • 16
  • 1
    I think the `--testnet-magic 42` simply specifies which network to use. I remember that the number `42` specified the `FF-testnet` back in 2020 before the Shelley launch. So in terms of "what it does", that might clear it up a bit for you, but I don't know about a full list of magic numbers and which exact networks they correspond to... – Dostrelith May 02 '21 at 09:14
  • @DamjanOstrelic yes, I figured that out later. For me, I had to use the magic number 1097911063 while most of the tutorials used 3 and 4 (which didn't work for me). Still not sure how the network number is defined or used. – paradox May 02 '21 at 13:01

1 Answers1

8

As I mentioned in the comment, it is the network identifier. If you go to https://hydra.iohk.io/build/5822084/download/1/index.html, you'll see the config and genesis files for current networks: testnet and mainnet. You can find the networkMagic parameter in the testnet Shelley genesis https://hydra.iohk.io/build/5822084/download/1/testnet-shelley-genesis.json:

...
"maxLovelaceSupply": 45000000000000000,
"networkMagic": 1097911063, // <- network identifier / magic number
"epochLength": 432000,
"systemStart": "2019-07-24T20:20:16Z",
...
Dostrelith
  • 922
  • 5
  • 13