How to generate private key from mnemonic phrase?

For example, the mnemonic phrase is “oblige salon price punch saddle immune slogan rare snap desert retire surprise”. Can I use TypeScript-SDK to obtain the private key address corresponding to this mnemonic phrase?

If possible, how should I write the code? If not, are there any other ways?

You can do it like this:

import { Wallet } from 'fuels';

const mnemonic = 'oblige salon price punch saddle immune slogan rare snap desert retire surprise';

const wallet = Wallet.fromMnemonic(mnemonic);

console.log(wallet.privateKey);

For more info, please check the relevant docs:

5 Likes

Thank you very much.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.