Difference between wallet addresses and those generated with cardano-cli address build

Hi, I have been going through some tutorials and came accros something I have not been able to figure out.

I generated a wallet using the cardano-wallet tool and deposited from a faucet on the first unused address.

  "id": "addr_test1qzu0llpjvjgh0425kzdvdadsakz2fn5xqtyqw2hxhvyyj3ykhkdfx00zjqujm3f6rnxc3hgqj66e53glqk7y8cclw6lsr74ste",
  "state": "unused"

I wanted to transfer tADA out of this wallet by building a raw transaction.
I generated the root key using the same passphrase used when creating the wallet, and derived the .skey and .vkey for the derivation path corresponding to this address above.

I was then able to build a raw transaction signed with .skey and successfully transfer funds from the address.

The part I don’t understand is the following.
I generated the payment address from the .vkey using the method shown in other tutorials, expecting it will match the address from which I got .vkey in the first place (above). But instead I got a completely different value and length.

$ cardano-cli address build --testnet-magic 2 --payment-verification-key-file keys/tn.pay-0.vkey
addr_test1vzu0llpjvjgh0425kzdvdadsakz2fn5xqtyqw2hxhvyyj3q29xwed

Why do the address vary in length?
The addresses are not equivalent, one contains funds and the other one doesn’t.

Why couldn’t go go full circle and generate the address back?
Does this mean that a .skey is not unique to one address?

Thanks.

The one created via wallet used payment + stake key to create a shelley address that can take part in staking. The one you created via CLI was simply using payment key - often called as enterprise addresses.
You might want to check this CIP for types of addresses and their formations

3 Likes

Thanks for the info, helped find the information I needed to recreate the address in full.

I do have a follow up question though.
I can recreate the address with derivation path 1852H/1815H/0H/0/0, but I have been unable to do the same with other addresses.

{
  "derivation_path": [
    "1852H",
    "1815H",
    "0H",
    "0",
    "0"
  ],
  "id": "addr_test1qqu7y6fmy924snn6qzr5ym3l954lwgpp0nkfstkf58su6hh3gkv3u9u7nxrquw2er7fcp0ptkkzkq6hhh04629h340ms64nzkj",
  "state": "used"
}

cardano-wallet key child 1852H/1815H/0H/0/0 < tn.root.prv > tn.pay.prv
cardano-wallet key public --without-chain-code < tn.pay.prv > tn.pay.pub
cardano-wallet key child 1852H/1815H/0H/2/0 < tn.root.prv > tn.stake.prv
cardano-wallet key public --without-chain-code < tn.stake.prv > tn.stake.pub
cardano-cli address build --testnet-magic 2 \
                          --payment-verification-key $(cat tn.pay.pub) \
                          --stake-verification-key $(cat tn.stake.pub)
addr_test1qqu7y6fmy924snn6qzr5ym3l954lwgpp0nkfstkf58su6hh3gkv3u9u7nxrquw2er7fcp0ptkkzkq6hhh04629h340ms64nzkj

But this did not work:

{
  "derivation_path": [
    "1852H",
    "1815H",
    "0H",
    "0",
    "1"
  ],
  "id": "addr_test1qquvzfjj6ggfesd3fweegvy0el79t77dty59fu587jj6y583gkv3u9u7nxrquw2er7fcp0ptkkzkq6hhh04629h340mshl3tl3",
  "state": "used"
}

cardano-wallet key child 1852H/1815H/0H/0/1 < tn.root.prv > tn.pay.prv
cardano-wallet key public --without-chain-code < tn.pay.prv > tn.pay.pub
cardano-wallet key child 1852H/1815H/0H/2/1 < tn.root.prv > tn.stake.prv
cardano-wallet key public --without-chain-code < tn.stake.prv > tn.stake.pub
cardano-cli address build --testnet-magic 2 \
                          --payment-verification-key $(cat tn.pay.pub) \
                          --stake-verification-key $(cat tn.stake.pub)
addr_test1qquvzfjj6ggfesd3fweegvy0el79t77dty59fu587jj6y5peha8sjvacr09yanyqxgctuv85ye5fpg3s077yufz3ewvqc2zg0e

Any idea why?

Thanks

That’s not how it is done. All addresses in an account use the stake address m/1852'/1815'/0'/2/0. After all, the reason for this is that they all contribute to the same stake, so they should all use the same stake address.

With

cardano-wallet key child 1852H/1815H/0H/0/1 < tn.root.prv > tn.pay.prv
cardano-wallet key public --without-chain-code < tn.pay.prv > tn.pay.pub
cardano-wallet key child 1852H/1815H/0H/2/0 < tn.root.prv > tn.stake.prv
cardano-wallet key public --without-chain-code < tn.stake.prv > tn.stake.pub
cardano-cli address build --testnet-magic 2 \
                          --payment-verification-key $(cat tn.pay.pub) \
                          --stake-verification-key $(cat tn.stake.pub)

you should get the correct result.

(Of course, you don’t have to recreate the stake key all the time. Just save it. It’s the same for all addresses.)

1 Like

Thanks for your reply and apologies for the noob questions, I have just started learning!

1 Like

Please keep on asking!

1 Like