1

Following this blogpost: https://medium.com/@guccimanepunk/how-to-deploy-a-truffle-contract-to-ropsten-e2fb817870c1

I created an account with geth --testnet account new

I requesed Ether into this account, but when I check

geth attach http://127.0.0.1:8545
personal.unlockAccount(eth.accounts[0])
Unlock account 0x78ca93e2a0621a1b5e198e85fd8e1d2db78d17ba
eth.getBalance(eth.accounts[0])
0

So maybe that's the problem? (The faucet worked fine for me with my Metamask address. I'm suspecting that my geth account isn't syncing)

I start testnest with this:

~/geth --testnet --fast --rpc --rpcapi eth,net,web3,personal

How do I connect to Ropsten test network and deploy my contract with truffle?

truffle migrate --network ropsten

Using network 'ropsten'.

Running migration: 1_initial_migration.js Deploying Migrations... ... undefined Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: insufficient funds for gas * price + value at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41484:16) at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:329530:36 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:176186:11 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:325200:9 at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:328229:7) at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176415:18) at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176705:12) at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176860:12) at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176820:24) at emitNone (events.js:111:20)

truffle.js:

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*" // Match any network id
    },
    ropsten: {
      network_id: 3,
      host: "127.0.0.1",
      port: 8545,
      gas: 9900000
    }
  }
};
Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145

3 Answers3

1

I was facing this issue when my contract was like this:


contract A {     
  function abc(unit a) public{    
     //doSomeAction     
  }
}    
Calling the contract in another contract like    
contract B {     
  contract A {    
     function abc(unit a) public;     
  }
....    
}    

Then I changed the contract B like: 
contract B{ 
import './A.sol'  
}   

After that, I didn't get this error. So pl check how you are calling the contracts to interact between each other and how much gas is consumed in each call.

Shane Fontaine
  • 18,036
  • 20
  • 54
  • 82
0

try reducing the gas price,

    module.exports = {
      // See <http://truffleframework.com/docs/advanced/configuration>
      networks: {
        development: {
          host: "127.0.0.1",
          port: 8545,
          network_id: "*" // Match any network id
        },
        ropsten: {
          network_id: 3,
          host: "127.0.0.1",
          port: 8545,
          from:  "" //<-- missing 
          gas: 4000000
        }
      }
jsphdnl
  • 101
  • Hello, I tried that, it looks like my geth is locked. How do I specify a password to decrypt? –  Jan 29 '18 at 21:34
0

This step:

personal.unlockAccount(eth.accounts[0])

The lock doesn't stay open for very long, so you will think you did it and the result will tend to mislead you because it locks itself up again.

Try:

personal.unlockAccount(eth.accounts[0], "<password>", 15000)

Meaning unlock, and stay unlocked for 15,000 seconds (plenty of time).

It's worked for others: truffle deploy: Network state unknown when geth is synced

Hope it helps.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145