4

I have another n00b question... sorry about that :(

I'm trying to deploy a smart contract to Ropsten. I have synched the Ropsten network with geth --testnet --fast --rpc --rpcapi eth,net,web3,personal, and it looks perfectly up to date.

Then I try to deploy that smart contract (which I've already deployed to my private testrpc network and it works poerfectly) to Ropsten. To do so I'm executing truffle migrate --network ropsten and I'm getting this pesky error:

Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)

The geth instance is in fact up and running, since I can connect to it with geth attach http://127.0.0.1:8545 and it works fine. It is accepting connections, since I used the --rpc option. It is accessible over the network because I've already accessed it... and I think than my Truffle configuration file is ok, here's how it looks:

require('babel-register')

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*' // Match any network id
    },
    ropsten: {
      host: "localhost",
      port: 8545,
      network_id: "3",
    }
  }
}

Can anyone please tell me why am I getting this error and what can I do to fix it?

Thank you so much in advance!!! :)

6

When I was deploying my contract through truffle in rinkeby network I too got the same error after adding from address and gas it got deployed. Try this

networks: {
  ropsten: {
    network_id: 3,
    host: '127.0.0.1',
    port: 8545,
    gas: 4000000,
    from: <your unlocked ropsten account address>
  },
  • Thanks a lot, Jazz! Well, looks a bit better, now I get this 2 new lines, but still it fails :( --->Using network 'ropsten'. --->Running migration: 1_initial_migration.js Could not connect to your Ethereum client (etc...) – JaVinci Sep 14 '17 at 8:17
  • Ok, looks like the problem might be that my blockchain database has been corrupted, so I need to synchronize again... Aaaarrgghhh!! – JaVinci Sep 14 '17 at 9:01
  • It finally worked, thanks a lot!! :) It's important to note that the only contents of truffle.js must be what you wrote... I had to remove another network I had configured in that file so this whole thing could work. – JaVinci Oct 3 '17 at 8:33
  • You could also use following command to specifically use a network, if you have multiple networks configured. truffle migrate --network ropsten – Ajay Jadhav Oct 27 '17 at 13:03
0

It's hard to get your ropsten account unlocked. You might opt for private key deployment. I've build lib for something like this.

const etherlime = require('etherlime');

const ICOTokenContract = require('./build/contracts/ICOToken.json');

const randomAddress = '0xda8a06f1c910cab18ad187be1faa2b8606c2ec86';

const defaultConfigs = {
    gasPrice: 20000000000,
    gasLimit: 4700000
}

const deployer = new etherlime.InfuraPrivateKeyDeployer('Your Privste KEY', 'ropsten', 'Your infura API key', defaultConfigs);

const runICODeployment = async () => {
    const contractWrapper = await deployer.deploy(ICOTokenContract);
    const transferTransaction = await contractWrapper.contract.transferOwnership(randomAddress);
    const result = await contractWrapper.verboseWaitForTransaction(transferTransaction.hash, 'Transfer Ownership');
}
runICODeployment()

Place this in a simple js file and run it with node. Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.