Mist browser may include web3 as a global variable at some point.
As of right now, the discussion of how to include web3
in the Mist browser is still being discussed here:
https://gist.github.com/frozeman/fbc7465d0b0e6c1c4c23
If you have an argument for or against this proposition, I would suggest you post on the gist. I'm sure they would appreciate your input!
An excerpt from the gist proposing three options to handle web3
in the Mist browser:
Mist web3 loading proposal
/*
Basically "web3" comes from Mist,
but "Web3" CAN come from the dapp.
A Dapp has 3 ways to use web3.
2. and 3. would work when in Mist and outside.
*/
// 1. simply use, web3 comes already defined
web3
// 2. optional use web3 from mist, OR load if outside of mist
if(typeof web3 === 'undefined')
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// 3. always use web3 provided by the dapp ("Web3" won't be supplied by Mist), but the provider from mist
if(typeof web3 !== 'undefined')
web3 = new Web3(web3.currentProvider);
else
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// Add RPC version?
@frozeman
var web3 = new Web3()
. (just be careful not to manage events across instances of web3, it won't work and fails silently, and contracts cache their instance of web3.eth...). Or did you mean something else? – Paul S Apr 4 '16 at 17:27