I am running a private Ethereum network. I do use https://aws.amazon.com/blockchain/templates/
The entire setup has been done. Things look setup properly on AWS. Now, I am trying to create the account and retrieve all those accounts. For that, I am using methods as below.
Web3Service.js
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider(process.env.NETWORK_URL));
exports.getAccounts = function () {
return web3.eth.getAccounts();
};
exports.createAccount = function () {
return web3.eth.accounts.create();
};
app.js
var newAccount = await web3Service.createAccount();
console.log('newAccount ', newAccount);
var accounts = await web3Service.getAccounts();
console.log('accounts ', accounts);
I am not facing any errors at all. But in the response of the web3Service.getAccounts();
it's always empty []
array.
I have verified the Etherium setup. All nodes working perfectly.
You can find the entire codebase here : blockchain-node Sample entire codebase