[Ethereum] Unable to deploy contract to rinkeby test network using truffle

blockchaincontract-deploymentgo-ethereumsoliditytruffle

These are the steps I took in order to deploy my contracts to rinkeby network:

  1. Created a .rinkeby folder.
  2. Downloaded genesis json for rinkeby from here
  3. Ran this command :

    geth –datadir=$HOME/.rinkeby –light init rinkeby.json

  4. Ran this command :

    geth –networkid=4 –datadir=$HOME/.rinkeby –syncmode=light –bootnodes=enode://a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303?discport=30304 –rpc –rpcapi db,eth,net,web3,personal –rpcport 8545 –rpcaddr 127.0.0.1 –rpccorsdomain "*"

  5. After I had geth connected to the network, I used truffle with the following code & command to deploy the contract:

Code:

module.exports = {
  networks: {
    rinkeby: {
      network_id: 4,
      host: '127.0.0.1',
      port: 8545,
      gas: 4000000
    },
  },
  rpc: {
    // Use the default host and port when not using rinkeby
    host: 'localhost',
    port: 8080,
  },
};

Command:

truffle compile; truffle migrate --network rinkeby

This is the error I am getting :

Using network 'rinkeby'.

/usr/lib/node_modules/truffle/build/cli.bundled.js:23538
        throw new Error("Expected parameter '" + key + "' not passed to function.");
        ^

Error: Expected parameter 'from' not passed to function.
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:23538:15
    at Array.forEach (native)
    at Object.options (/usr/lib/node_modules/truffle/build/cli.bundled.js:23536:19)
    at Object.run (/usr/lib/node_modules/truffle/build/cli.bundled.js:66868:12)
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:88946:23
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:67033:9
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:66861:7
    at done (/usr/lib/node_modules/truffle/build/cli.bundled.js:155469:5)
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:155526:11
    at FSReqWrap.oncomplete (fs.js:153:5)

What is incorrect in the process that I followed? I cant understand why this error is coming and how to remove it.

Best Answer

The problem was in the truffle.js file.

module.exports = {
  networks: {
    rinkeby: {
      network_id: 4,
      host: '127.0.0.1',
      port: 8545,
      gas: 4000000,
      from: <your account address>
    },
  },
  rpc: {
    // Use the default host and port when not using rinkeby
    host: 'localhost',
    port: 8080,
  },
};

Just needed to add a from: <account address> into rinkeby's config information.

Related Topic