Open yuwiggin opened 6 years ago
Currently, HDWalletProvider manages only one address at a time. It's the first address generated from the mnemonic. Both tokenIssuer and creator should be equal to this address.
@7flash is mainnet always the first address generated? Mostly wondering how to go about deploying to ropsten if this is the case
does anyone have a solution to this one now? I am having the same problem.
I went to truffle console
and check the eth.getAddress()
its shows an address that I am not familiar with and it has 0 eth
.
The only solution that worked for me was to replace truffle-hdwallet-provider
with rather truffle-privatekey-provider. So rather than using mnemonic I gave in my private key
I had the same problem and worked around by creating a new provider with ethjs using web3 provider hook.
const sign = require('ethjs-signer').sign;
const HookedWeb3Provider = require("hooked-web3-provider");
...
networks: {
rinkebyInfura: {
provider: () => new HookedWeb3Provider({
host: "https://rinkeby.infura.io/v3/" + infuraKey,
transaction_signer: {
hasAddress: (address, cb) => cb(null, true),
signTransaction: (rawTx, cb) => cb(null, sign(rawTx, '0x' + contractOwnerPrivateKey)),
}
}),
network_id: "4",
gas : 5000000,
from: contractOwner,
},
}
Though I still had issues with Infura when trying to deploy more than one contract with truffle migrate.
You can use private keys instead of mnemonic. https://github.com/trufflesuite/truffle-hdwallet-provider#private-keys
module.exports = {
networks: {
ropsten: {
provider: function() {
return new HDWalletProvider([
process.env.METAMASK_PRIVATE_KEY_1,
process.env.METAMASK_PRIVATE_KEY_2,
process.env.METAMASK_PRIVATE_KEY_3,
process.env.METAMASK_PRIVATE_KEY_4,
process.env.METAMASK_PRIVATE_KEY_5
], process.env.INFURA_API_ROPSTEN_ENDPOINT, 0, 5)
},
network_id: 3,
gas: 8000000
}
}
};
Any news on this?
You can use private keys instead of mnemonic. https://github.com/trufflesuite/truffle-hdwallet-provider#private-keys
module.exports = { networks: { ropsten: { provider: function() { return new HDWalletProvider([ process.env.METAMASK_PRIVATE_KEY_1, process.env.METAMASK_PRIVATE_KEY_2, process.env.METAMASK_PRIVATE_KEY_3, process.env.METAMASK_PRIVATE_KEY_4, process.env.METAMASK_PRIVATE_KEY_5 ], process.env.INFURA_API_ROPSTEN_ENDPOINT, 0, 5) }, network_id: 3, gas: 8000000 } } };
It help me a lot ! Thank you so much
I tried to deploy contract on ropsten network with truffle, metamask and infura.
truffle migrate --network ropsten
, but failed with the following error.My truffle.js is following:
My truffle version is:
The 2_deploy_contracts.js is following:
What Happened?