How to use the web3-provider-engine/subproviders/wallet.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 owocki / coloradocoin / truffle.js View on Github external
var Web3 = require("web3");

// Get our mnemonic and create an hdwallet

var mnemonic = require('./mnemonic.js');
var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic.mnemonic()));

// Get the first account using the standard hd path.
var wallet_hdpath = "m/44'/60'/0'/0/";
var wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet();
var address = "0x" + wallet.getAddress().toString("hex");
console.log(address);

var providerUrl = "https://testnet.infura.io";
var testnet_engine = new ProviderEngine();
testnet_engine.addProvider(new WalletSubprovider(wallet, {}));
testnet_engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
testnet_engine.start(); // Required by the provider engine.

var providerUrl = "https://mainnet.infura.io";
var mainnet_engine = new ProviderEngine();
mainnet_engine.addProvider(new WalletSubprovider(wallet, {}));
mainnet_engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
mainnet_engine.start(); // Required by the provider engine.

module.exports = {
  migrations_directory: "./migrations",
  networks: {
    ropsten: {
      network_id: 3,    // Official ropsten network id
      provider: testnet_engine, // Use our custom provider
      from: address,     // Use the address we derived
github gitcoinco / smart_contracts / truffle.js View on Github external
var Web3 = require("web3");

// Get our mnemonic and create an hdwallet

var mnemonic = require('./mnemonic.js');
var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic.mnemonic()));

// Get the first account using the standard hd path.
var wallet_hdpath = "m/44'/60'/0'/0/";
var wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet();
var address = "0x" + wallet.getAddress().toString("hex");
console.log("using address: " + address)

var providerUrl = "https://rinkeby.infura.io";
var testnet_engine = new ProviderEngine();
testnet_engine.addProvider(new WalletSubprovider(wallet, {}));
testnet_engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
testnet_engine.start(); // Required by the provider engine.

var providerUrl = "https://ropsten.infura.io";
var ropsten_engine = new ProviderEngine();
ropsten_engine.addProvider(new WalletSubprovider(wallet, {}));
ropsten_engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
ropsten_engine.start(); // Required by the provider engine.

var providerUrl = "https://mainnet.infura.io";
var mainnet_engine = new ProviderEngine();
mainnet_engine.addProvider(new WalletSubprovider(wallet, {}));
mainnet_engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
mainnet_engine.start(); // Required by the provider engine.

module.exports = {
github youvegoteth / youvegoteth.github.io / contracts / truffle.js View on Github external
// Get our mnemonic and create an hdwallet
var mnemonic = "solve couch unique spirit wine occur fine rhythm foot feature glory away";
//var mnemonic = "SECRET_MAINNET_MNEMONIC_GOES_HERE";
var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic));

// Get the first account using the standard hd path.
var wallet_hdpath = "m/44'/60'/0'/0/";
var wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet();
var address = "0x" + wallet.getAddress().toString("hex");

console.log(address);

var providerUrl = "https://testnet.infura.io";
var testnet_engine = new ProviderEngine();
testnet_engine.addProvider(new WalletSubprovider(wallet, {}));
testnet_engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
testnet_engine.start(); // Required by the provider engine.

var providerUrl = "https://mainnet.infura.io";
var mainnet_engine = new ProviderEngine();
mainnet_engine.addProvider(new WalletSubprovider(wallet, {}));
mainnet_engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
mainnet_engine.start(); // Required by the provider engine.

module.exports = {
  migrations_directory: "./migrations",
  networks: {
    ropsten: {
      network_id: 3,    // Official ropsten network id
      provider: testnet_engine, // Use our custom provider
      from: address     // Use the address we derived
github kioskprotocol / contracts / truffle.js View on Github external
function InfuraProvider(infuraURL) {
    var privateKeyBuffer = new Buffer(PRIVATE_KEY, "hex");
    this.wallet = new Wallet(privateKeyBuffer);
    this.address = "0x" + this.wallet.getAddress().toString("hex");
    this.engine = new ProviderEngine();
    this.engine.addProvider(new WalletSubprovider(this.wallet, {}));
    this.engine.addProvider(new FiltersSubprovider());
    this.engine.addProvider(new FetchSubprovider({ rpcUrl: infuraURL }));
    this.engine.start(); // Required by the provider engine.
}
github Propy / ethereum / truffle.js View on Github external
// Create wallet from existing private key
const privateKey = require('./network_keys/private/rinkeby');
const wallet = ethereumjsWallet.fromPrivateKey(new Buffer(privateKey, "hex"));
const sender = "0x" + wallet.getAddress().toString("hex");

// Using rinkeby testnet
const apiKey = require('./network_keys/api/infura');
const providerUrl = "https://rinkeby.infura.io/" + apiKey;
const engine = new ProviderEngine();

const provider = new Web3.providers.HttpProvider(providerUrl);
const web3 = new Web3(provider);

// filters
engine.addProvider(new FilterSubprovider());
engine.addProvider(new WalletSubprovider(wallet, {}));
engine.addProvider(new Web3Subprovider(provider));
engine.start();  // FIXME: Truffle hangs after compilation/migration because of this


module.exports = {
    networks: {
        development: {
            host: "localhost",
            port: 8545,
            network_id: "*", // Match any network id
            gas: 4000000,
        },
        rinkeby: {
            network_id: 4,
            provider: () => engine,
            from: sender,
github dfinity-side-projects / STIFTUNG-DFN-donations / app / javascripts / eth.js View on Github external
var EthForwarder = function (accounts, fdc) {
    this.accounts = accounts;
    this.fdc = fdc;
    if (ethProvider == null)
        ethProvider = new Web3.providers.HttpProvider(G.DEFAULT_ETHEREUM_NODE);
    
    var engine = new ProviderEngine.Engine();
    var wallet = Wallet.fromPrivateKey(EthJSUtil.toBuffer(accounts.ETH.priv))
    engine.addProvider(new WalletSubprovider(wallet, {}));
    engine.addProvider(new Web3Subprovider(ethProvider));
    engine.start(); // Required by the provider engine.
    FDC.setProvider(engine);
}
github asseth / dao1901 / customModules / protocol / truffle.js View on Github external
const WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js')
  const Web3Subprovider = require("web3-provider-engine/subproviders/web3.js")
  const Web3 = require("web3")

  // Get our mnemonic and create an hdwallet
  let mnemonic = MNEMONIC
  let hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic))

  // Get the first account using the standard hd path.
  let wallet_hdpath = "m/44'/60'/0'/0/"
  let wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet()
  address = "0x" + wallet.getAddress().toString("hex")
  let providerUrl = "https://kovan.infura.io"
  engine = new ProviderEngine()
  engine.addProvider(new FilterSubprovider())
  engine.addProvider(new WalletSubprovider(wallet, {}))
  engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)))
  engine.start() // Required by the provider engine.
}

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*',
    },
    kovan: {
      from: isTestnet ? address : null, // Use the address we derived
      gas:4900000,
      network_id: '42',
      provider: isTestnet ? engine : null, // Use our custom provider
github DOkwufulueze / eth-vue / truffle.js View on Github external
// Get our mnemonic and create an hdwallet
var mnemonic = "piano file obey immense polar rack great subject clutch camera maid ostrich";
var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic));

// Get the first account using the standard hd path.
var wallet_hdpath = "m/44'/60'/0'/0/";
var wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet();
var address = "0x" + wallet.getAddress().toString("hex");

var providerUrl = "https://testnet.infura.io";
var engine = new ProviderEngine();
// filters
engine.addProvider(new FilterSubprovider());

engine.addProvider(new WalletSubprovider(wallet, {}));
engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
engine.start(); // Required by the provider engine.

module.exports = {
  networks: {
    ropsten: {
      network_id: 3,    // Official ropsten network id
      provider: engine, // Use the custom provider
      from: address,     // Use the address derived address
      gas: 4444444
    },
    development: {
      host: "localhost",
      port: 8545, // This is the conventional port. If you're using the Ganache Blockchain, change port value to the Ganache default port 7545. If you're using Truffle develop network, change port value to 9545
      network_id: "*", // Match any network id. You may need to replace * with your network Id
      from: "", // Add your unlocked account within the double quotes
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;
};