xclud / web3dart

Ethereum library, written in Dart.
https://pub.dev/packages/web3dart
MIT License
170 stars 94 forks source link

Get wallet from seed phrase #57

Open JAtoms opened 1 year ago

JAtoms commented 1 year ago

I'd like to know if we can get a wallet using seed phrases from a different wallet.

alexandrebottero commented 1 year ago

Got the same issue, I use bip39 lib but after I get wrong address (not the same that I see in metamask for example). Do you have any information about that @xclud

jvinai commented 1 year ago

Until we can do it with web3dart, this is how i do it:

I used 2 libs:

Code wise, i did:

import 'package:bip39/bip39.dart' as bip39;
import 'package:ethers/signers/wallet.dart' as EWallet;

String mnemonic = mnemonicController.text; //TextFormField controller
if (!bip39.validateMnemonic(mnemonic)) {
      //error
}
final walletMnemonic = EWallet.Wallet.fromMnemonic(mnemonic);
final privateKey = walletMnemonic.privateKey;
final credentials = EthPrivateKey.fromHex(privateKey!);

Now you can use web3dart EthPrivateKey/Credentials object.

Kujbor commented 10 months ago

ethers now is outdated. Any other solutions?