How to select a single account in Ganache

0 votes

I can see the list of accounts using the following command:

web3.eth.getAccounts();

But now I am trying to select a single account using web3 but I dont know how to do it. I tried 

web3.eth.accounts[0]

But it is not working

Feb 5, 2019 in Blockchain by Joshi
1,790 views

1 answer to this question.

0 votes

When you use web3, selecting a single account is considered as a promise. Try this:

> var accounts;
> web3.eth.getAccounts(function(response) { account = response; });
> console.log(accounts[0]);
answered Feb 5, 2019 by Omkar
• 69,220 points

Related Questions In Blockchain

0 votes
1 answer

How to make sure transactions take no fee in a private Ethereum blockchain?

In a private ethereum network you have ...READ MORE

answered Mar 26, 2018 in Blockchain by Christine
• 15,790 points

edited Mar 26, 2018 by Christine 1,567 views
0 votes
1 answer

In a Blockchain, how difficult is it to modify the third to last block?

Technically, it's not difficult at all, all ...READ MORE

answered Apr 20, 2018 in Blockchain by Christine
• 15,790 points
1,027 views
0 votes
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,922 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,427 views
0 votes
1 answer

How to control a malicious user in hyperledger fabric?

Fabric is an implementation of blockchain. Blockchain ...READ MORE

answered Jun 29, 2018 in Blockchain by Omkar
• 69,220 points
1,064 views
0 votes
1 answer

How to set the hex-encoded data field in a Web3j Ethereum transaction?

You can use the "data" field of ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 69,220 points
3,003 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP