Skip to content

Instantly share code, notes, and snippets.

@frozeman
Last active July 22, 2021 01:00
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frozeman/fbc7465d0b0e6c1c4c23 to your computer and use it in GitHub Desktop.
Save frozeman/fbc7465d0b0e6c1c4c23 to your computer and use it in GitHub Desktop.
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?
@balamuraliv
Copy link

I am new to Blockchain and I' trying to do sample application using MIX IDE .How to display the transaction data in front end (index.html)
Can I use web3 object in MIX..Please guide me.

@ethernomad
Copy link

Relying on a global web3 seems to be incompatible with "use strict";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment