gpt4 book ai didi

ethereum - 错误 : insufficient funds for gas * price + value

转载 作者:行者123 更新时间:2023-12-02 01:06:13 24 4
gpt4 key购买 nike

我正在通过 first tutorial in the Ethereum website .

我已经使用 Remix 编译了合约代码并创建了以下脚本。为简洁起见,我删除了二进制字符串:

var _greeting = 'Hello World!';
var browser_untitled_sol_greeterContract = web3.eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]);
var browser_untitled_sol_greeter = browser_untitled_sol_greeterContract.new(
_greeting,
{
from: web3.eth.accounts[0],
data: 'BINARY_STRING',
gas: '4700000'
}, function (e, contract){
console.log(e, contract);
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
})

var browser_untitled_sol_mortalContract = web3.eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]);
var browser_untitled_sol_mortal = browser_untitled_sol_mortalContract.new(
{
from: web3.eth.accounts[0],
data: 'BINARY_STRING',
gas: '4700000'
}, function (e, contract){
console.log(e, contract);
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
})

加载此脚本时,我得到:
Error: insufficient funds for gas * price + value .

打电话时 eth.getBalance(eth.accounts[0])我得到: 399577000000000
我不知道我的余额中应该有多少 eth 才能运行这个脚本,或者我是否需要将 eth 转换为 gas。

最佳答案

您不会将以太“转换”为气体。您使用以太币支付所使用的天然气费用。

无论如何,您收到的错误消息似乎是正确的。你的余额很低。 eth.getBalance()返回Wei中的余额。你的余额只有 ~0.0004 ether,这是相当低的(你可以使用 https://etherconverter.online/ 转换为 ether 或使用 web3.fromWei(val, 'ether') 在代码中转换)。

您需要的以太币数量取决于合约中执行的操作,以及您愿意为所使用的 gas 支付多少(您可以覆盖交易对象中的默认值 gasPrice)。尝试挖掘或将更多以太币转移到您的帐户中。

关于ethereum - 错误 : insufficient funds for gas * price + value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47382146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com