How to use @truffle/hdwallet-provider - 2 common examples

To help you get started, we’ve selected a few @truffle/hdwallet-provider 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 oceanprotocol / commons / client / src / context / BurnerWalletProvider.ts View on Github external
public async startLogin() {
        let mnemonic
        const isLogged = await this.isLogged()

        if (isLogged) {
            mnemonic = localStorage.getItem('seedphrase')
        } else {
            mnemonic = bip39.generateMnemonic()
            localStorage.setItem('seedphrase', mnemonic)
        }

        localStorage.setItem('logType', 'BurnerWallet')
        const provider = new HDWalletProvider(mnemonic, nodeUri, 0, 1)
        this.web3 = new Web3(provider as any)
        const accounts = await this.web3.eth.getAccounts()
        const balance = await this.web3.eth.getBalance(accounts[0])

        // fill with Ether if account balance is empty
        balance === '0' && (await requestFromFaucet(provider.getAddress(0)))
    }
github microsoft / vscode-azure-blockchain-ethereum / drizzleUI / src / App.js View on Github external
if (provider) {
      const { WebsocketProvider } = drizzle.web3.providers;
      const host = new URL(Url.normalize(provider.host));

      let web3Provider;

      if (
        Constants.regexps.providerTypes.azure.test(host.toString()) &&
        provider.options &&
        provider.options.mnemonic
      ) {
        host.protocol = 'wss';
        host.port = 3300;

        web3Provider = new HDWalletProvider(
          provider.options.mnemonic,
          new WebsocketProvider(host.toString()),
        );
      } else {
        host.protocol = 'ws';
        web3Provider = new WebsocketProvider(host.toString());
      }

      drizzle.web3.setProvider(web3Provider);
    }

    const address = contractInstance.address;
    const networkName = contractInstance.network.name;
    const accounts = await drizzle.web3.eth.getAccounts();

    const contractConfig = {

@truffle/hdwallet-provider

HD Wallet-enabled Web3 provider

MIT
Latest version published 1 year ago

Package Health Score

53 / 100
Full package analysis

Popular @truffle/hdwallet-provider functions