0

I have to create a wallet of polkadot like trustwallet. I tried to create a wallet with "type: ed25519" but it also return different address.

Here is the trust wallet configuration

  {
    "id": "polkadot",
    "name": "Polkadot",
    "coinId": 354,
    "symbol": "DOT",
    "decimals": 10,
    "blockchain": "Polkadot",
    "derivation": [
      {
        "path": "m/44'/354'/0'/0'/0'"
      }
    ],
    "curve": "ed25519",
    "publicKeyType": "ed25519",
    "addressHasher": "keccak256",
    "ss58Prefix": 0,
}

1 Answer 1

0

I solved the issues like this. below is 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;
  }
};

Your Answer

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

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