Skip to content

Instantly share code, notes, and snippets.

@Rami-Majdoub
Created March 31, 2023 10:46
Show Gist options
  • Save Rami-Majdoub/6ecc51b95718f6c067c7164b308e8fa5 to your computer and use it in GitHub Desktop.
Save Rami-Majdoub/6ecc51b95718f6c067c7164b308e8fa5 to your computer and use it in GitHub Desktop.
import { Wallet } from "ethers";
async function main() {
// const wallet = new Wallet("private key")
// const wallet = Wallet.fromMnemonic("mnemonic")
const wallet = Wallet.createRandom();
console.log(`Wallet mnemonic: ${wallet.mnemonic.phrase}`);
console.log(`Wallet encrypted:`);
console.log(await wallet.encrypt(""));
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment