【问题标题】:insufficient funds for gas * price + value using geth --dev使用 geth --dev 的 gas * price + value 资金不足
【发布时间】:2019-01-03 07:27:56
【问题描述】:

我在部署智能合约(使用 netheruem)时不断出错。错误是:gas * price + value with geth 命令的资金不足:

geth --dev --rpc --rpcport "8545" --rpcapi="db,eth,net,web3,personal,web3" console

我读到我需要在我的 genesis.json 文件中调整 gas 限制,但我在初始化 geth 之前已经完成了这一步。这是我的 genesis.json 文件:

{
"config":{
   "chainId": 45,
   "homesteadBlock": 0,
   "eip155Block": 0,
   "eip158Block": 0,
   "byzantiumBlock": 12
},
"alloc" : {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : 
"0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : 
"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}

我在最新区块中的 gas 限制是 6283185,这应该足以部署智能合约。我需要检查配置吗?

谢谢

【问题讨论】:

  • 您的部署钱包中是否真的有足够的资金来支付交易费用?

标签: ethereum solidity geth


【解决方案1】:

您需要向您正在执行交易的账户提供资金,或者允许 0 汽油价格交易。

要为帐户注资,请在创建初始块时将分配添加到您的 genesis.json:

{
   ...
   "alloc": {
        "ACCOUNT_ADDRESS": {
            "balance": "9999999999999999999999999"
        }
    }
}

通过geth 创建帐户,然后在配置中使用该地址。值以 Wei 为单位。

您可以使用设置为 0 的 gas 价格代替使用资金,但您必须将 —gasPrice 设置为 0 来启动您的矿工(否则,您的矿工将忽略您的交易)。即使你使用 0 gas 价格,你仍然有 gas limit 限制。

【讨论】:

    猜你喜欢
    • 2018-03-20
    • 2017-08-15
    • 2018-05-03
    • 2021-11-19
    • 2019-04-18
    • 2022-06-11
    • 1970-01-01
    • 2018-04-30
    • 1970-01-01
    相关资源
    最近更新 更多