<p>A. The &quot;last address&quot; and &quot;base address&quot; described above are the exact same data in different representations. What you're calling the &quot;base address&quot; is the hex representation of an address. The bech32 representation is just an encoding of that same data. The <code>bech32</code> CLI utility is really good for doing these conversions (although the nodejs one you reference above can be used as well)</p>
<pre><code>bech32 addr_test &lt;&lt;&lt; 00dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90c0efa54fe993c0f2de5236b46deaa4bc34b36c7c388f53eb51c9885a
addr_test1qrwpqlt04ulue0aw3d6ydcms8uczqrr6ufm8ucru3psg4yxqa7j5l6vncredu53kk3k74f9uxjekclpc3af7k5wf3pdqtk6tn9
</code></pre>
<p>B. The easiest way to understand address formats is at the binary level. You make an assertion above that mainnet addresses are 01 and testnet are 00, which is a true geeneralization, but doesn't explain the whole picture. The CDDL helps with understanding at a bit level how an address is made up: <a href="https://github.com/input-output-hk/cardano-ledger/blob/master/eras/shelley/test-suite/cddl-files/shelley.cddl#L89-L100" rel="nofollow noreferrer">https://github.com/input-output-hk/cardano-ledger/blob/master/eras/shelley/test-suite/cddl-files/shelley.cddl#L89-L100</a></p>
<p>From this, we see an enterprise address (a base address with no delegation credential) is 0110 if it isn't a script. The hex representation of this is <code>6</code>. So an enterprise address with just the payment key hash is <code>60dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90</code> or in bech32: <code>addr_test1vrwpqlt04ulue0aw3d6ydcms8uczqrr6ufm8ucru3psg4yq3c0kvn</code>.</p>
<p>Here's the cardano-address inspect for that address:</p>
<pre><code>cardano-address address inspect &lt;&lt;&lt; 60dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90
{
    &quot;stake_reference&quot;: &quot;none&quot;,
    &quot;spending_key_hash_bech32&quot;: &quot;addr_test1msg86ma08lxtlt5tw3rwxuplxqsqc7hzwelxqlygvz9fqltwcyd&quot;,
    &quot;address_style&quot;: &quot;Shelley&quot;,
    &quot;spending_key_hash&quot;: &quot;dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90&quot;,
    &quot;network_tag&quot;: 0
}
</code></pre>
<p>C. Yes</p>

CC BY-SA 4.0
2021-12-22T19:14:24.207Z
Thank you for the detailed answer ! So if I don't add the stake key hash it is an enterprise address. This explains why the Nami wallet doesn't recognise 'addr_test1vrw...0kvn' as its own address.
Jey
CC BY-SA 4.0
2021-12-22T17:46:27.957Z
2021-12-22T17:46:27.957Z
Samuel Leathers
<p>I'm trying to figure out the relations of the various types of addresses and how to convert one into the other.</p>
<p>The Nami wallet returns from its method <code>cardano.getUsedAddresses()</code> an array with one address that is 114 characters long and looks like this (testnet):</p>
<pre><code>00dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90c0efa54fe993c0f2de5236b46deaa4bc34b36c7c388f53eb51c9885a
</code></pre>
<p>This string is apparently the representation of the so called <code>BaseAddress</code>.</p>
<p>Now, I figured out that this format is the concatenation of three parts:</p>
<ol>
<li>two characters for the network. '00' for testnet and '01' for the main net</li>
<li>A hex encoded 56 characters long hash of the verification key</li>
<li>A hex encoded 56 characters long hash of the staking key</li>
</ol>
<p>So, I extracted the verification key hash and converted it into the bech32 format (elixir code):</p>
<pre><code>pkh_hex = &quot;dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90&quot;
bytes = Base.decode16!(pkh_hex, case: :lower)
bech_string = Bech32.encode(&quot;addr_vkh&quot;, bytes)
</code></pre>
<p>This gives me the value <code>addr_vkh1msg86ma08lxtlt5tw3rwxuplxqsqc7hzwelxqlygvz9fq6dx76x</code> for <code>bech_string</code> which corresponds to the one confirmed by the converter here: <a href="https://input-output-hk.github.io/cardano-addresses/demo" rel="nofollow noreferrer">https://input-output-hk.github.io/cardano-addresses/demo</a></p>
<p>The address shown on the receive screen of the Nami wallet is (testnet):</p>
<pre><code>addr_test1qrwpqlt04ulue0aw3d6ydcms8uczqrr6ufm8ucru3psg4yxqa7j5l6vncredu53kk3k74f9uxjekclpc3af7k5wf3pdqtk6tn9
</code></pre>
<p>I am wondering:</p>
<p><strong>A. How can I derive this last address string above from the base address ?</strong></p>
<p><strong>B. Also, how can I convert the <code>addr_vkh</code>-address into a <code>addr</code>-address (of course without the staking key part) ?</strong></p>
<p><strong>C. Is this verification key hash the thing that is called <code>PaymentPubKeyHash</code> in Plutus ?</strong></p>

<nami-wallet><cardano-address><payment>
Cardano address chaos
# Cardano address chaos

(Asked by: username_0 on 2021-12-22)

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 ?

**Tags:** nami-wallet, cardano-address, payment

---

## 1 answers

### Answer by username_1 on 2021-12-22. Score: 2 | Accepted answer

A. The "last address" and "base address" described above are the exact same data in different representations. What you're calling the "base address" is the hex representation of an address. The bech32 representation is just an encoding of that same data. The bech32 CLI utility is really good for doing these conversions (although the nodejs one you reference above can be used as well)
bech32 addr_test <<< 00dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90c0efa54fe993c0f2de5236b46deaa4bc34b36c7c388f53eb51c9885a
addr_test1qrwpqlt04ulue0aw3d6ydcms8uczqrr6ufm8ucru3psg4yxqa7j5l6vncredu53kk3k74f9uxjekclpc3af7k5wf3pdqtk6tn9

B. The easiest way to understand address formats is at the binary level. You make an assertion above that mainnet addresses are 01 and testnet are 00, which is a true geeneralization, but doesn't explain the whole picture. The CDDL helps with understanding at a bit level how an address is made up: https://github.com/input-output-hk/cardano-ledger/blob/master/eras/shelley/test-suite/cddl-files/shelley.cddl#L89-L100
From this, we see an enterprise address (a base address with no delegation credential) is 0110 if it isn't a script. The hex representation of this is 6. So an enterprise address with just the payment key hash is 60dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90 or in bech32: addr_test1vrwpqlt04ulue0aw3d6ydcms8uczqrr6ufm8ucru3psg4yq3c0kvn.
Here's the cardano-address inspect for that address:
cardano-address address inspect <<< 60dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90
{
    "stake_reference": "none",
    "spending_key_hash_bech32": "addr_test1msg86ma08lxtlt5tw3rwxuplxqsqc7hzwelxqlygvz9fqltwcyd",
    "address_style": "Shelley",
    "spending_key_hash": "dc107d6faf3fccbfae8b7446e3703f30200c7ae2767e607c88608a90",
    "network_tag": 0
}

C. Yes

> **Comments:**
> **username_0**: Thank you for the detailed answer ! So if I don't add the stake key hash it is an enterprise address. This explains why the Nami wallet doesn't recognise 'addr_test1vrw...0kvn' as its own address.  

---

