5

I was trying to extract the staking address from an address and I was able to do that by using the bech32 decode, getting the last 56 bytes and encoding back again.

The question is: following this, I needed to add e1 (mainnet) or e0 (testnet) and it worked perfectly. The only thing though is that I don't know the reason. I mean, solving isn't enough, I wanted to understand why it's necessary to add those bytes as prefix.

Thank you.

1 Answer 1

6

The e comes from these address prefixes defined in the CDDL https://github.com/input-output-hk/cardano-ledger/blob/f2a783cf00911b7492e81dd6c7fb8a963f9ce8fe/eras/shelley/test-suite/cddl-files/shelley.cddl#L98

e equivalent in binary is 1110. The 0/1 is the part of the network ID defined in this part of the CDDL https://github.com/input-output-hk/cardano-ledger/blob/f2a783cf00911b7492e81dd6c7fb8a963f9ce8fe/eras/shelley/test-suite/cddl-files/shelley.cddl#L79

Combined they're the header that prefixes the payload defined here https://github.com/input-output-hk/cardano-ledger/blob/f2a783cf00911b7492e81dd6c7fb8a963f9ce8fe/eras/shelley/test-suite/cddl-files/shelley.cddl#L72

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.