How to use the web3-provider-engine/subproviders/rpc.js function in web3-provider-engine

To help you get started, we’ve selected a few web3-provider-engine 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 LimeChain / etherlime / packages / etherlime / cli-commands / etherlime-test / etherlime-coverage.js View on Github external
ignoreFilesGlobs: ['**/node_modules/**']
	}

	if (ignoreFiles) {
		ignoreFiles = ignoreFiles.split(',')
		ignoreFiles = ignoreFiles.map(file => "**/" + file)
		coverageSubproviderConfig.ignoreFilesGlobs = coverageSubproviderConfig.ignoreFilesGlobs.concat(ignoreFiles)
	}
		
	global.coverageSubprovider = new CoverageSubprovider(
		artifactAdapter,
		defaultFromAddress,
		coverageSubproviderConfig
	);
	provider.addProvider(global.coverageSubprovider);
	provider.addProvider(new RpcProvider({ rpcUrl: `http://localhost:${port}` }));
	global.provider = provider;

	// start pulling blocks
	provider.start();
	return provider
}
github brave / ethereum-remote-client / app / scripts / lib / metamask-provider.js View on Github external
// filters
  engine.addProvider(new FilterSubprovider())

  // vm
  engine.addProvider(new VmSubprovider())

  // id mgmt
  engine.addProvider(new HookedWalletSubprovider({
    getAccounts: opts.getAccounts,
    approveTx: opts.approveTx,
    signTransaction: opts.signTransaction,
  }))

  // data source
  engine.addProvider(new RpcSubprovider({
    rpcUrl: opts.rpcUrl,
  }))

  // log new blocks
  engine.on('block', function(block){
    // console.log('================================')
    console.log('BLOCK CHANGED:', '#'+block.number.toString('hex'), '0x'+block.hash.toString('hex'))
    // console.log('================================')
  })

  // start polling for blocks
  engine.start()

  return engine

}
github MetaMask / zero-client / zero-provider.js View on Github external
eth_hashrate: '0x0',
    eth_mining: false,
    eth_syncing: true,
  }))

  // cache
  engine.addProvider(new CacheSubprovider())

  // filters - e.g.: eth_newBlockFilter
  engine.addProvider(new FilterSubprovider())

  // vm - e.g.: eth_call
  engine.addProvider(new VmSubprovider())

  // data source - e.g.: eth_getBalance
  engine.addProvider(new RpcSubprovider({
    rpcUrl: opts.rpcUrl || 'https://rpc.metamask.io/',
  }))

  engine.on('block', function(block){
    console.log('================================')
    console.log('BLOCK CHANGED:', '#'+block.number.toString('hex'), '0x'+block.hash.toString('hex'))
    console.log('================================')
  })

  // start polling for blocks
  engine.start()

  return engine
}
github ConsenSys / gnosis-twitter-bot / market-manager / getQR.js View on Github external
const QRProvider = require('./uportQRProvider.js');
const ProviderEngine = require('web3-provider-engine');
const RpcSubprovider = require('web3-provider-engine/subproviders/rpc.js')
const Web3 = require('web3');
const engine = new ProviderEngine();
const web3 = new Web3(engine);
const qrImage = require('qr-image');

if (process.argv.length != 6) {
  process.exit();
}

// Set web3
web3.eth.defaultAccount = '0xB42E70a3c6dd57003f4bFe7B06E370d21CDA8087'
engine.addProvider(new QRProvider());
engine.addProvider(new RpcSubprovider({
 rpcUrl: configObject.ethereumNodeURL,
}));
configObject.web3 = web3;
engine.start();

let marketAddress = process.argv[4];
let marketHash = process.argv[2];
let outcomeIndex = new BigNumber(process.argv[3]);
let userPrice = new BigNumber(process.argv[5]).mul(new BigNumber('1e18'));

gnosis.contracts.marketFactory.getMarketsProcessed(
  [marketHash],
  configObject,
  marketAddress
).then((response) => {
  let globalResponse = {};
github uport-project / uport-connect / index.js View on Github external
Uport.prototype.getUportProvider = function(rpcUrl) {
  var engine = new ProviderEngine();

  engine.addProvider(this.subprovider);

  // default url for now
  if (!rpcUrl) rpcUrl = INFURA_CONSENSYSNET;
  // data source
  var rpcSubprovider = new RpcSubprovider({
    rpcUrl: rpcUrl
  });
  engine.addProvider(rpcSubprovider);

  // start polling
  engine.start();
  engine.stop();
  return engine;
}
github ConsenSys / gnosis-twitter-bot / market-manager / getMarkets.js View on Github external
const ProviderEngine = require('web3-provider-engine');
const RpcSubprovider = require('web3-provider-engine/subproviders/rpc.js')
const Web3 = require('web3');
const engine = new ProviderEngine();
const web3 = new Web3(engine);

const filters = {
  tags: "twitter, Twitter",
  include_whitelisted_oracles: true,
  oracle_addresses: "0x0"
};

// Set web3
web3.eth.defaultAccount = '0xB42E70a3c6dd57003f4bFe7B06E370d21CDA8087'
engine.addProvider(new RpcSubprovider({
 rpcUrl: configObject.ethereumNodeURL,
}));
configObject.web3 = web3;
engine.start();

gnosis.config.initialize(
  configObject
)
.then(
  (config) => {
    gnosis.api.getContracts({}, config)
    .then(
      (addresses) => {
        let offChainOracles = addresses.data.offChainOracles.map(oracle => oracle.address);
        gnosis.state.updateEventDescriptions(config, filters)
        .then(
github LimeChain / etherlime / test / etherlime-lib / deployer / jsonrpc-deployer / jsonrpc-private-key-deployer.js View on Github external
it('Should set the right localNodeProvider if the deployer is runned from coverage command', () => {
			const provider = new ProviderEngine();
			global.coverageSubprovider = new CoverageSubprovider();
			provider.addProvider(global.coverageSubprovider);
			provider.addProvider(new RpcProvider({ rpcUrl: `http://localhost:${config.alternativePort}` }));
			global.provider = provider;
			const deployer = new etherlime.JSONRPCPrivateKeyDeployer(config.randomPrivateKey, config.alternativeNodeUrl, defaultConfigs);
			assert.deepEqual(global.provider._providers[1].rpcUrl, config.alternativeNodeUrl, "The stored provider url does not match the inputted one");
			assert.deepEqual(global.provider._providers[1].rpcUrl, deployer.provider.connection.url, "The stored connection url does not match the inputted one");

		})
github LimeChain / etherlime / test / etherlime-lib / deployer / jsonrpc-deployer / jsonrpc-private-key-deployer.js View on Github external
it('Should set the right localNodeProvider if the deployer is runned from coverage command', () => {
			const provider = new ProviderEngine();
			global.coverageSubprovider = new CoverageSubprovider();
			provider.addProvider(global.coverageSubprovider);
			provider.addProvider(new RpcProvider({ rpcUrl: `http://localhost:${config.alternativePort}` }));
			global.provider = provider;
			const deployer = new etherlime.JSONRPCPrivateKeyDeployer(config.randomPrivateKey, config.alternativeNodeUrl, defaultConfigs);
			assert.deepEqual(global.provider._providers[1].rpcUrl, config.alternativeNodeUrl, "The stored provider url does not match the inputted one");
			assert.deepEqual(global.provider._providers[1].rpcUrl, deployer.provider.connection.url, "The stored connection url does not match the inputted one");

		})
github chronicled / open-registry-ethereum / backendSDK / lib / provider.js View on Github external
},
      approveTransaction: function(txParams, cb) {
        cb(null, true);
      },
      signTransaction: function(txData, cb) {
        txData.gasPrice = parseInt(txData.gasPrice, 16);
        txData.nonce = parseInt(txData.nonce, 16);
        txData.gasLimit = txData.gas;
        var tx = wallet.txutils.createContractTx(addr, txData);
        var signed = wallet.signing.signTx(ks, pwDerivedKey, tx.tx, addr);
        cb(null, signed);
      }
    }));
  }

  engine.addProvider(new RpcSubprovider({
    rpcUrl: rpcUrl,
  }));
  engine.start();

  this.web3 = web3;
  this.address = addr;
}
github transmute-industries / transmute / packages / transmute-framework / src / web3.ts View on Github external
export const transmuteWeb3 = (config: ITransmuteWeb3Config, experimental = false) => {
  const engine = new ProviderEngine();

  if (config.wallet) {
    engine.addProvider(new WalletSubprovider(config.wallet, {}));
  }

  engine.addProvider(
    new RpcSubprovider({
      rpcUrl: config.providerUrl
    })
  );

  const web3 = new Web3(engine);
  engine.start();

  return web3;
};