How to use the web3.setProvider function in web3

To help you get started, we’ve selected a few web3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lexansoft / etherid.org / test / index.html View on Github external
"This page URL has this ipfs HASH: <b>" + hash + "<b>"
        }
        else
        {
            document.getElementById( "url_hash" ).innerHTML = 
                "This page was not open through IPFS"
        }
            
        try {

            /* first of all set up the web3 object. THis should work in Mist as well */
            if(typeof web3 === 'undefined')
                web3 = require('web3');     

            if( web3.currentProvider == null )
                web3.setProvider( new web3.providers.HttpProvider( ) );                

            /* Get the EtherID API object */
            EID = require( "etherid" )

            BCH_HASH = EID.getHash( web3, "test", "ipfs" )
            
            document.getElementById( "bch_hash" ).innerHTML = 
                "The proper hash for the page sould be: <b>" + BCH_HASH + "<b>"            
            
            if( hash == BCH_HASH )
            {
                document.getElementById( "action" ).innerHTML = 
                    "You see the CORRECT version of this website!" 
                document.getElementById( "action" ).style.color = "green"
            }
            else</b></b></b></b>
github jorisbontje / sleth / frontend / ng-blockwatch.html View on Github external
app.factory('web3', function() {
    var web3 = require('web3');
    web3.setProvider(new web3.providers.AutoProvider());
    return web3;
});