什么gasPrice用于在拥挤的以太坊主网上部署合同

时间:2018-01-10 15:08:07

标签: ethereum solidity truffle consensys-truffle

我正在尝试将合同部署到以太坊主网上,我已经指定:

network_id:1,

提供者:infura,

天然气:5000000,

gasPrice:140

我不断得到错误:

tb-gateway.log

2018-01-10 20:14:59,191 [main] WARN  o.t.g.e.m.client.MqttBrokerMonitor - [localhost:1883] MQTT broker connection failed!
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
    at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException: null
    at java.io.DataInputStream.readByte(Unknown Source)
    at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92)
    at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:116)
    ... 1 common frames omitted
2018-01-10 20:15:02,198 [main] WARN  o.t.g.e.m.client.MqttBrokerMonitor - [localhost:1883] MQTT broker connection failed!
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
    at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException: null
    at java.io.DataInputStream.readByte(Unknown Source)
    at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92)
    at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:116)
    ... 1 common frames omitted

Error: Contract transaction couldn't be found after 50 blocks

这是因为主网络如此拥挤,矿工在50个街区内没有收到我的交易吗?

其他人在主网上成功使用了哪些燃气/燃气价格?

2 个答案:

答案 0 :(得分:3)

例如,您可以在https://ethgasstation.info/查看当前的汽油价格。请注意,天然气价格通常以Gwei显示。所以21 Gwei是21000000000 wei或0.000021 eth。

答案 1 :(得分:2)

为了扩展安德烈的答案,你的气体太低了。从历史上看,您通常需要支付大约10-20 Gwei才能在平均时间内开采您的交易。如果你可以等待10分钟甚至数小时,你可以使用~5Gwei。如果您需要快速执行事务,或者如果您只想在网络真正拥塞时获得平均事务时间,那么您可能需要查看~40Gwei。

您可以使用web3.eth.getGasPrice(callback)根据最近开采的区块的中位汽油价格以编程方式设置您的汽油价格。 Source