createOrRestoreShelleyWallet - 409 error (Conflict) #46

This is my code:

let phrase = "all foster both consider pay session trip comma liberty father bet coach reunion town news"
let mnemonic_sentence = Seed.toMnemonicList(phrase);
let rootKey = Seed.deriveRootKey(phrase);
privateKey = rootKey.to_bech32();
account = await walletServer.createOrRestoreShelleyWallet('aaa', mnemonic_sentence, 'bbb');

And I get this error:

response: {
    status: 409,
    statusText: 'Conflict',
data: {
      code: 'wallet_already_exists',
      message: 'This operation would yield a wallet with the following id: a91f4a5507c1af... However, I already know of a wallet with this id.'
  isAxiosError: true,
  toJSON: [Function: toJSON]

And after that, my server closed!

You seem to be interacting with cardano-wallet?

I think the error message says it all. You already have imported/restored that wallet and can just use it, but not import/restore it again.

(I really hope, the seed phrase is not some wallet you actually use. Edit: No, it’s not even a real seed phrase.)

1- I create a new wallet with this code:

const { WalletServer , Seed, AddressWallet } = require('cardano-wallet-js');
phrase = Seed.generateRecoveryPhrase();
let mnemonic_sentence = Seed.toMnemonicList(phrase);
account = await walletServer.createOrRestoreShelleyWallet('aa', mnemonic_sentence, 'aa-wallet');

Also, I write the phrase codes on a paper.

2- After one week, I want to login my wallet with my phrase.

I use this code:

let phrase = "..." // My phrase when I create the wallet
let mnemonic_sentence = Seed.toMnemonicList(phrase);
account = await walletServer.createOrRestoreShelleyWallet('aa', mnemonic_sentence, 'aa-wallet');

But I get wallet_already_exists error.
It’s OK! but I want to access my wallet with phrase.

It does not seem to be possible with cardano-wallet to get a wallet that the server already knows by seed phrase. You have to remember the walletId or get it from

Thank you.
So, How can I recovery wallets with phrase?!

The error you get means that you already have recovered (or created) with the phrase.

You can list the wallets to find it and then just use its walletId in the other possible requests.

Unfortunately, the 409 error does not give back the ID of the already existing wallet.

You could also list the wallets and then delete all of them with:
Afterwards, you will be able to create/restore again with the seed phrase.

If that is what you want, you could build your application to always delete the wallet at the end of your session.

1 Like