Truffle Console Rinkeby – How to Set Specific Account When Using Truffle Console Rinkeby

accountsrinkebysoliditytruffle

When I tested on ganache-cli at local, I could test on 'truffle console development' with some accounts which ganache-cli gave. But at rinkeby, I can't use function_name(argumets, {from: specific rinkeby account}) form. Is it possible to set the specific account on 'truffle console rinkeby(and mainnet also)'? (Something like using web3.eth. thing) If it is, how can I set that?

Best Answer

Since you are using HDWalletProvider it will only support accounts derived from the mnemonic. It doesn't know the private key required to sign messages from other addresses.

As alternative you pass to HDWalletProvider an array of private keys.

var privateKeys = [
  "3f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9580",
  "9549f39decea7b7504e15572b2c6a72766df0281cea22bd1a3bc87166b1ca290",
];
var provider = new HDWalletProvider(privateKeys, "http://localhost:8545", 0, 2); //start at address_index 0 and load both addresses
Related Topic