Skip to content

Instantly share code, notes, and snippets.

@duanescarlett
Created March 10, 2022 19:57
Show Gist options
  • Save duanescarlett/85f86718ff587e38a9aa6c678705d982 to your computer and use it in GitHub Desktop.
Save duanescarlett/85f86718ff587e38a9aa6c678705d982 to your computer and use it in GitHub Desktop.
Import Wallet from Mnemonic - Ethers JS
ethers = require('ethers')
require('dotenv').config()
const main = async () => {
// Import a wallet
const wallet = new ethers.Wallet.fromMnemonic(process.env.MNEMONIC)
console.log('Address: ', wallet.address) // Wallet Address
console.log('Private Key: ', wallet.privateKey) // Wallet Private Key
}
main()
.then(() => process.exit(0))
.catch((err) => {
console.error(err)
process.exit(1)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment