7

I'm trying to use the cardano-wallet API, but most of the endpoints I want to use are based on WALLET_ID parameter.

How can I find out the WALLET ID when all I have is the addr, for example addr1qyxwlgeux7f8t7552p8uh3de8yfakftt3lwmceuzs9jcw0gw3el5uu8gpznfcsthyvuf558epvsmjl2gmmkvax535tjsaglpn2?

0

2 Answers 2

7

Think of cardano-wallet as Daedalus, it can only manage locally created wallets and their addresses and transactions.

If you want to interact with the blockchain as a whole you should be using cardano-cli (I used Lars' Lobster Challenge address as an example instead to have some outputs):

  • Get some tech info:
$ cardano-cli address info --address addr1w8433zk2shufk42hn4x7zznjjuqwwyfmxffcjszw5l2ulesdt3jff
{
    "address": "addr1w8433zk2shufk42hn4x7zznjjuqwwyfmxffcjszw5l2ulesdt3jff",
    "base16": "71eb188aca85f89b55579d4de10a729700e7113b325389404ea7d5cfe6",
    "type": "payment",
    "encoding": "bech32",
    "era": "shelley"
}
  • Get ADA/tokens balance and Plutus stuff
$ cardano-cli query utxo --mainnet --address addr1w8433zk2shufk42hn4x7zznjjuqwwyfmxffcjszw5l2ulesdt3jff
                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
319752b414804415988fb1165358e69f46095a9e9b1c01ef0830c182dc57f78b     0        1000000 lovelace + TxOutDatumHashNone
4c34feb07e32aa4855a494306aefcf16743356811914d680e112a6ec12214455     0        1000000 lovelace + TxOutDatumHashNone
63091c70aa6f8b402faffd24909d93c7721cbdced7094b62e52d157da8fb44e4     0        5000000 lovelace + TxOutDatumHashNone
67d318fabdd9905033bfe6156c6595716c952d496cabb9d98773c948974780ec     0        1000000 lovelace + TxOutDatumHashNone
cb7b44500fc9145cf5b13a533bc7616eb219b7a080bc49d7ce6204c06b351733     0        1000000 lovelace + TxOutDatumHashNone
cf944108d7130a8d53925ff9903a254d5133d5978b7e69e04c67d5b8776a6fb2     1        2034438 lovelace + 1 cc7888851f0f5aa64c136e0c8fb251e9702f3f6c9efcf3a60a54f419.LobsterNFT + 522 fda1b6b487bee2e7f64ecf24d24b1224342484c0195ee1b7b943db50.LobsterCounter + 501 fda1b6b487bee2e7f64ecf24d24b1224342484c0195ee1b7b943db50.LobsterVotes + TxOutDatumHash ScriptDataInAlonzoEra "45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0"
db250ed5eb4454843af19dea7ca84a8adda170fc88284e7e5e2381b41dab5f9b     1        30768137 lovelace + TxOutDatumHashNone
5
  • 1
    Would be helpful to see an example output of these commands.
    – eddex
    Oct 1, 2021 at 5:07
  • Thank you for the answer! Any idea why the cardano-cli query utxo --mainnet --address would return no utxos, when, for example, pool.pm shows 5? (cardano-node is fully synced)
    – K.M
    Oct 1, 2021 at 14:18
  • I'm not sure but it's like if pool.pm is showing everything regarding the wallet associated with the searched address. Your address shows 522 ADA and 2 NFTs, but if you see the NFTS's info they belong to two completely different addresses. Maybe those 522 ADA are shared among other addresses too because Cardano Explore shows no results neither explorer.cardano.org/en/… Oct 1, 2021 at 20:03
  • Although it's nice that you put some examples of getting info, there are no examples of how to get the wallet id from a receive address, regardless of what tool you're using.
    – melchoir55
    Dec 8, 2021 at 6:15
  • 1
    @melchoir55 A "wallet id" only has sense in the cardano-wallet local environment context. On the blockchain the equivalent would be the private key, and it'd be very bad if you can find it from the address. All you can have is the address, i.e. (one of) the wallet's public key(s). Dec 9, 2021 at 19:16
0

In JavaScript, from the Nami Wallet PAB demo:

exports.getWalletIdImpl = () => {
  return Promise.all([window.cardano.getUsedAddresses(), window.cardano.getUnusedAddresses()])
    .then(([walletUsedAddresses, walletUnusedAddresses]) => {
      const addresses = walletUnusedAddresses.concat(walletUsedAddresses)
      return require('blake2b')(20)
        .update(Buffer.from(addresses.map(a => a.to_bech32).join('')))
        .digest('hex')
    })
}

Your Answer

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

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