1

I launch web3 at nodejs server,not in explorer(no MetaMask).

const END_POINT = 'http://localhost:8545';
web3 = new Web3(new Web3.providers.HttpProvider(END_POINT));
web3.eth.getAccounts()
.then((accounts)=>{console.log})

I can get accounts from localhost:8085.

const END_POINT = 'https://ropsten.infura.io/v3/XXXXXXXXXXXXXXXXXX';
web3 = new Web3(new Web3.providers.HttpProvider(END_POINT));
web3.eth.getAccounts()
.then((accounts)=>{console.log})

But I can't get accounts from infura,return array is 0 length. If no accounts that I will get error like "Specified signerAddress 0x4897b54979b9bf339f13dd461628476430cf0ea5 isn't available through the supplied web3 provider".

How to add available accounts?

2

Infura is only an API provider, they do not provide a wallet or account service.

When you use metamask or something similar, your accounts are stored locally, and a provider such as infura is only used to query the blockchain state (Account balances, interact with contracts, nonce, etc), or to broadcast transactions. The private keys are held locally.

You will need to run a provider such as the truffle-hdwallet-provider locally to manage your external accounts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.