Last active
February 24, 2020 20:47
-
-
Save austintgriffith/a96f6307c50ba51096e429f319080678 to your computer and use it in GitHub Desktop.
create an ethereum account and store it in account.json
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 fs = require('fs'); | |
const Web3 = require('web3'); | |
const web3 = new Web3("http://localhost:8545"); | |
const filename = "account.json" | |
if (fs.existsSync(filename)) { | |
console.log(filename+" already exists (delete it to create a new account)") | |
}else{ | |
let account = web3.eth.accounts.create(); | |
console.log(filename,account) | |
fs.writeFileSync(filename,JSON.stringify(account)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment