I used Truffle to setup a basic example dapp, which includes a frontend javascript file in which I see the following lines:
window.onload = function() {
web3.eth.getAccounts(function(err, accs) {
if (err != null) {
alert("There was an error fetching your accounts.");
return;
}
if (accs.length == 0) {
alert("Couldn't get any accounts! Make sure your Ethereum client is configured correctly.");
return;
}
accounts = accs;
account = accounts[0];
refreshBalance();
refreshBalances();
});
}
What I don't understand is; where does web3
come from in this context? In the index.html file, only this javascript file is imported, and I don't see any mentioning of web3
anywhere else.
Can anyone shed some light on this for me?