Skip to content

Instantly share code, notes, and snippets.

@austintgriffith
Last active February 24, 2020 20:47
Show Gist options
  • Save austintgriffith/a96f6307c50ba51096e429f319080678 to your computer and use it in GitHub Desktop.
Save austintgriffith/a96f6307c50ba51096e429f319080678 to your computer and use it in GitHub Desktop.
create an ethereum account and store it in account.json
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