Created
October 1, 2024 15:13
-
-
Save DaWe35/20c8691d2e49957450624599b52289ac to your computer and use it in GitHub Desktop.
Generate Ethereum Wallet with NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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