How to use the web3-provider-engine/subproviders/wallet 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 dexlab-io / dexpay-pos / src / class / ethereum / EthereumHDWallet.js View on Github external
return new Promise(async (resolve, reject) => {
      // for modern dapp browsers

      // if (this.address && !ethereum && !web3 && !web3.currentProvider) {
      if (this.address) {
        const engine = new ProviderEngine();
        Web3.providers.HttpProvider.prototype.sendAsync =
          Web3.providers.HttpProvider.prototype.send;

        if (!this.watchOnly) {
          engine.addProvider(new WalletSubprovider(this.instanceWallet, {}));
        }

        engine.addProvider(
          new RpcSubprovider({
            rpcUrl: this.networkUrl
          })
        );

        engine.start();
        this.web3 = new Web3(engine);
        this.web3.eth.defaultAccount = this.getAddress();
        resolve();
        return;
      }

      if (ethereum) {
github eltcoin / eltwallet / src / utils / wallet.js View on Github external
static getWeb3Instance() {
    const wallet = this.getWallet();

    const engine = new ProviderEngine();

    engine.addProvider(new WalletSubprovider(wallet, {}));
    engine.addProvider(new ProviderSubprovider(this.getWeb3HTTPProvider()));

    engine.start();

    const web3 = new Web3(engine);

    web3.eth.defaultAccount = wallet.getAddressString();

    return web3;
  }
github transmute-industries / transmute / packages / transmute-framework / src / __mocks__ / getWeb3.ts View on Github external
export const getWeb3FromWalletWithMneumonic = () => {
  const engine = new ProviderEngine()
  const mneumonic = TransmuteCrypto.generateMnemonic()
  const wallet = TransmuteCrypto.getWalletFromMnemonic(mneumonic)
  const address = TransmuteCrypto.getDefaultAddressFromWallet(wallet)
  engine.addProvider(new WalletSubprovider(wallet, {}))
  engine.addProvider(
    new RpcSubprovider({
      rpcUrl: RPC_HOST
    })
  )
  engine.start()
  return {
    web3: new Web3(engine),
    address
  }
}
github transmute-industries / transmute / packages / transmute-framework / src / __mocks__ / getWeb3.ts View on Github external
export const getWeb3FromWalletWithPrivateKey = async () => {
  const engine = new ProviderEngine()
  const sodium = await TransmuteCrypto.getSodium()
  const alice = sodium.crypto_box_keypair()
  const unPrefixedPrivateKeyHexString = sodium.to_hex(alice.privateKey)
  const wallet = TransmuteCrypto.getWalletFromPrivateKey(unPrefixedPrivateKeyHexString)
  const address = TransmuteCrypto.getDefaultAddressFromWallet(wallet)
  engine.addProvider(new WalletSubprovider(wallet, {}))

  engine.addProvider(
    new RpcSubprovider({
      rpcUrl: RPC_HOST
    })
  )
  engine.start()
  return {
    web3: new Web3(engine),
    address
  }
}