1

I want to transfer the management of my dot account from polkadat.js to trustwallet. The problem I am facing is that the same mnemonic give different key in those applications. How to deal with that? How to add the dot account to my trust wallet? I have both mnemonic phrase and the recovery json file stored.

Test mnemonic: neck glance normal build soccer reason cotton island story control lemon theme

public key on polkadot.js: 162LT7DYzo3iHGfk3RDpZWeYq5NUxxmvZCFUMTAwuFYZYp89

public key in trust wallet: 16GEpjTJJgSX9Saoe7Y7uTDX78h6bAB6uiHhnXJ9AFXmUxby

2
  • Could be that they use a different crypto as default. You can use subkey inspect to check the derived key for all three different supported signature algorithms. One of them should match. Commented Aug 23, 2023 at 15:12
  • I’m voting to close this question because it lacks of detail.
    – AurevoirXavier
    Commented May 31 at 2:44

2 Answers 2

1

Different key derivation functions affect the ability to use the same mnemonic in multiple wallets as different wallets may use different functions to derive the secret from the mnemonic. See more information in the docs: Portability.

PolkadotJS uses BIP32, but I can't find what key derivation Trust wallet uses but probably a different one. In that case the only thing you can try is export/import the private key directly.

1

trust wallet use following derivePath = "m/44'/354'/0'/0'/0'"
Below is the code for create a wallet for specific derivePath.

import {mnemonicToSeed} from 'bip39';
import {derivePath} from 'ed25519-hd-key';
import {Keyring} from '@polkadot/keyring';

const createPolkadotWallet = async mnemonic => {
  try {
    const seed = await mnemonicToSeed(mnemonic);
    const privateKey = derivePath("m/44'/354'/0'/0'/0'", seed).key;
    const keyring = new Keyring({ss58Format: 0});
    const keypair = keyring.addFromSeed(privateKey);
    return {
      address: keypair.address,
      privateKey: privateKey?.toString('hex'),
    };
  } catch (e) {
    console.error('Error in createPolkadotWallet', e);
    throw e;
  }
};

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