I'm trying to figure out the relations of the various types of addresses and how to convert one into the other.
The Nami wallet returns from its method
cardano.getUsedAddresses() an array with one address that is 114 characters long and looks like this (testnet):
This string is apparently the representation of the so called
Now, I figured out that this format is the concatenation of three parts:
- two characters for the network. '00' for testnet and '01' for the main net
- A hex encoded 56 characters long hash of the verification key
- A hex encoded 56 characters long hash of the staking key
So, I extracted the verification key hash and converted it into the bech32 format (elixir code):
pkh_hex = "dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90" bytes = Base.decode16!(pkh_hex, case: :lower) bech_string = Bech32.encode("addr_vkh", bytes)
This gives me the value
bech_string which corresponds to the one confirmed by the converter here: https://input-output-hk.github.io/cardano-addresses/demo
The address shown on the receive screen of the Nami wallet is (testnet):
I am wondering:
A. How can I derive this last address string above from the base address ?
B. Also, how can I convert the
addr_vkh-address into a
addr-address (of course without the staking key part) ?
C. Is this verification key hash the thing that is called
PaymentPubKeyHash in Plutus ?