TransWikia.com

unable to see the first address using web3.eth.getAddress()

Ethereum Asked by tithidey on November 10, 2021

I tried to see all address using

web3.eth.getAccounts()

It’s run perfectly. Next I tried to see the first address using

web3.eth.getAccounts().then(function(accounts) {return accounts[0]})

It’s also worked well. But now I want to use this address according to their index.

when I use getAccounts[0]or getAccounts[1] sometimes it’s work, sometimes not.

So is there any specific way to use those address using index?

One Answer

If i understand correctly you want to use the web3.eth.gethAccounts() method with an index based on which account you want to return.

Reading the documentation at https://web3js.readthedocs.io/en/v1.2.7/web3-eth.html#getaccounts the only parameter accepted by the method is the [callback] function so i think that you cannot use the index as an input parameter.

Hope this helps.

Answered by Gabriele Del Monte on November 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP