Skip to content

Instantly share code, notes, and snippets.

@tomconte
Last active July 14, 2019 03:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tomconte/8ef602bf38c4dd11a6b47b7e1114e30c to your computer and use it in GitHub Desktop.
Save tomconte/8ef602bf38c4dd11a6b47b7e1114e30c to your computer and use it in GitHub Desktop.
Example Truffle 3.0 configuration file to allow deploying contracts to an Azure "Bletchley" Ethereum consortium network. Based on the Truffle docs for Infura (http://truffleframework.com/tutorials/using-infura-custom-provider).
var bip39 = require("bip39");
var ethwallet = require('ethereumjs-wallet');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
var Web3 = require("web3");
// Insert raw hex private key here, e.g. using MyEtherWallet
var wallet = ethwallet.fromPrivateKey(Buffer.from('abcdef', 'hex'));
var address = "0x" + wallet.getAddress().toString("hex");
var providerUrl = "http://tcolm3ew4.westeurope.cloudapp.azure.com:8545";
var engine = new ProviderEngine();
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: "*" // Match any network id
},
"bletchley": {
network_id: 10101010, // Use the ID provided at creation time
provider: engine, // Use our custom provider
from: address // Use the address we derived
}
},
rpc: {
host: "localhost",
port: 8545
}
};
@cbruguera
Copy link

If I leave the engine.start() line uncommented, truffle "hangs" even when making a compile... Any ideas?

@dryruner
Copy link

dryruner commented Nov 2, 2017

Same question as @cbruguera

@mckenn
Copy link

mckenn commented Nov 17, 2017

I had the same issue so I switched to truffle-hdwallet-provider. Works smoothly right out of the box.
https://github.com/trufflesuite/truffle-hdwallet-provider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment