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):
00dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90c0efa54fe993c0f2de5236b46deaa4bc34b36c7c388f53eb51c9885a
This string is apparently the representation of the so called BaseAddress
.
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 addr_vkh1msg86ma08lxtlt5tw3rwxuplxqsqc7hzwelxqlygvz9fq6dx76x
for 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):
addr_test1qrwpqlt04ulue0aw3d6ydcms8uczqrr6ufm8ucru3psg4yxqa7j5l6vncredu53kk3k74f9uxjekclpc3af7k5wf3pdqtk6tn9
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 ?