Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectSecp256k1HdWallet.fromMnemonic error #1582

Open
snailAlice opened this issue Apr 22, 2024 · 1 comment
Open

DirectSecp256k1HdWallet.fromMnemonic error #1582

snailAlice opened this issue Apr 22, 2024 · 1 comment

Comments

@snailAlice
Copy link

The account restored through the mnemonic phrase is inconsistent with the wallet generated by importing it into the keprl wallet. The crossfi chain is used and the address produced by cosmos is consistent. What do I need to do to get the correct address?

import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"

const generateKey = async (): Promise => {
console.log(await (await DirectSecp256k1HdWallet.fromMnemonic("material have exile coconut family trick load door soldier feel busy depth glad seed turtle",{prefix: "mx",})).getAccounts())
console.error("Mnemonic with 1st account:", accounts[0].address)
}
generateKey()

run result: mx1ts9mz7p5p8yqwx84t2sucv3h6et2f8gj3s20hu
import keprl wallet: mx18hxcz64d0v5msqwqcm9dtfwgzqhwmnzuslc0sr

What do I need to do to get the correct address?

@webmaster128
Copy link
Member

Just a guess, but you might need a different path than the Cosmos Hub derivation path. In the second argument, fromMnemonic has an hdPath option

{
    prefix: "mx",
    hdPath: stringToPath("m/1/1/1"), // what does your chain typically use here?
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants