Skip to content

Instantly share code, notes, and snippets.

@DaWe35
Created October 1, 2024 15:13
Show Gist options
  • Save DaWe35/20c8691d2e49957450624599b52289ac to your computer and use it in GitHub Desktop.
Save DaWe35/20c8691d2e49957450624599b52289ac to your computer and use it in GitHub Desktop.
Generate Ethereum Wallet with NodeJS
const ethers = require('ethers');
function generateEthereumKeyPair() {
// Generate a random wallet
const wallet = ethers.Wallet.createRandom();
// Get the private key
const privateKey = wallet.privateKey;
// Get the public key
const publicKey = wallet.publicKey;
// Get the Ethereum address
const address = wallet.address;
return {
privateKey,
publicKey,
address
};
}
// Generate and log the key pair
const keyPair = generateEthereumKeyPair();
console.log('Private Key:', keyPair.privateKey);
console.log('Public Key:', keyPair.publicKey);
console.log('Ethereum Address:', keyPair.address);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment