Ethereum 我的智能合约导致错误:汽油用完错误

Ethereum 我的智能合约导致错误:汽油用完错误,ethereum,solidity,Ethereum,Solidity,我的可靠性代码有问题。 我想,这个问题是由账户.转账 我用的是ganache,混音,metamask,web3 这是我的密码 `pragma solidity ^0.4.25; contract test{ address fire_account=0x6F3c5e42c340736eEa9a1C362592Bef9Ba2E5561; mapping(string => uint) fire_record; function fireDonation(string

我的可靠性代码有问题。 我想,这个问题是由
账户.转账

我用的是ganache,混音,metamask,web3

这是我的密码

`pragma solidity ^0.4.25;
contract test{
    address fire_account=0x6F3c5e42c340736eEa9a1C362592Bef9Ba2E5561;
    mapping(string => uint) fire_record;
    function fireDonation(string contributorName) payable{
        fire_account.transfer(msg.value);
        fire_balance+=msg.value;
        fire_contributor.push(contributorName);
    }
}`
和web3.js代码

var Courses;
async function init(){
    web3 = await new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));
    web3.eth.defaultAccount = web3.eth.accounts[2];
    console.log("Default account is ",web3.eth.accounts[2]);
    //Change the ABI here
    var CoursesContract = web3.eth.contract(/*skip*/);
    //Replace Deployed Smartcontract Address here
    var contractaddress = "0x9b95f972feaad42f2023246112f450c56d8921ae";
    Courses = CoursesContract.at(contractaddress);
}
init();
function fireDonate(){
    var amount=parseInt(document.getElementById('amount').value);
    console.log(amount);
    Courses.fireDonation(document.getElementById('contributor').value, {from: web3.eth.accounts[2], value: amount});
}
你能告诉我解决方案或链接吗?
我找不到链接。

看来您的智能合约需要比默认金额更多的汽油(费用)才能执行。您必须将gasLimit和gasPrice从其默认值增加。您可以像这样用十六进制指定它们

Courses.fireDonation(document.getElementById('contributor').value, {from: web3.eth.accounts[2], value: amount, gasLimit: '0x27100', gasPrice: '0x09184e72a00'});
您可能需要改变确切的值,以查看哪些适用于您的用例