I am creating an address generator for cardano. I am struggling to figure out what the differences would be when building an address for testnet instead of mainnet. What components of the address are different?
If you are using
cardano-cli to build the address(es), the only difference would be in specifying which network (mainnet or testnet) the address is for. This is done via the
--testnet-magic <MAGIC_NUMBER> flags. The same payment/stake.vkey files can be used in either case.
For example, if you are building a shelley address for the public testnet using cardano-cli, you would replace the following
--mainnet flag with the
--testnet-magic 1097911063 flag:
cardano-cli address build \ --payment-verification-key-file payment.vkey \ --stake-verification-key-file stake.vkey \ --mainnet \ --out-file main-shelley.addr
cardano-cli address build \ --payment-verification-key-file payment.vkey \ --stake-verification-key-file stake.vkey \ --testnet-magic 1097911063 \ --out-file test-shelley.addr
Note: mainnet shelley addresses all begin with
addr1, whereas testnet shelley addresses all begin with