Go-Ethereum

網路狀態未知部署到測試網

  • December 30, 2018

在這篇博文之後:https ://medium.com/@guccimanepunk/how-to-deploy-a-truffle-contract-to-ropsten-e2fb817870c1

我創建了一個帳戶geth --testnet account new

我請求乙太幣進入這個賬戶,但是當我檢查

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

所以也許這就是問題所在?(水龍頭在我的 Metamask 地址上工作得很好。我懷疑我的 geth 帳戶沒有同步)

我用這個開始testnest:

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

如何連接到 Ropsten 測試網路並使用 truffle 部署我的合約?

truffle migrate --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)

松露.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
   }
 }
};

當我的契約是這樣的時,我遇到了這個問題:

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'  
}   

之後,我沒有收到此錯誤。因此,請檢查您如何呼叫合約以相互互動以及每次呼叫消耗了多少氣體。

嘗試降低gas價格,

   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:  "" //&lt;-- missing 
         gas: 4000000
       }
     }

引用自:https://ethereum.stackexchange.com/questions/36886