xclud / web3dart

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

How to export private key? #60

Open stefannovak opened 1 year ago

stefannovak commented 1 year ago

Hey, struggling with trying to find a way to get a private key from a wallet. I just want to test taking the private key and putting it in metamask.

Thanks

MahmoudKEA commented 1 year ago

Just use bytesToHex method to convert bytes private key to string

import 'package:web3dart/crypto.dart';

EthPrivateKey credentials = EthPrivateKey.fromHex("c87509a[...]dc0d3");
String privateKey = bytesToHex(credentials.privateKey, include0x: true);