var Web3 = require('web3'); var fs = require('fs'); var web3 = new Web3(); web3.setProvider(new web3.providers.HttpProvider('http://home.mrdev023.fr:8545')); var account = undefined if(!fs.existsSync('account.json')){ var password = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);; web3.eth.personal.newAccount(password).then(function(address){ var obj = {"address": address, "password": password}; console.log(address); fs.writeFile('account.json', JSON.stringify(obj), 'utf8',run); account = obj run(); }) } else { fs.readFile('account.json', 'utf8', function readFileCallback(err, data){ if (err){ console.log(err); process.exit(1); } else { account = JSON.parse(data); //now it an object run(); }}); } function run() { }