Blockchain 无法使用Truffle控制台运行smartContract。获取错误

Blockchain 无法使用Truffle控制台运行smartContract。获取错误,blockchain,ethereum,truffle,cryptocurrency,go-ethereum,Blockchain,Ethereum,Truffle,Cryptocurrency,Go Ethereum,我正在尝试运行以下智能合约: pragma solidity ^0.5.0; contract Calculator{ function addition(uint a, uint b) public pure returns(uint) { return (a + b); } function substraction(uint a, uint b) public pure returns(uint) {

我正在尝试运行以下智能合约:

pragma solidity ^0.5.0;

contract Calculator{
        function addition(uint a, uint b) public pure returns(uint) {
                return (a + b);
        }

        function substraction(uint a, uint b) public pure returns(uint) {
                return (a - b);
        }

        function multiplication(uint a, uint b) public pure returns(uint) {
                return ( a * b);
        }

        function division (uint a, uint b) public pure returns(uint) {
                return (a / b);
        }
}
当我尝试使用truffle控制台运行智能合约时,它错误地指出“汽油资金不足”


知道为什么吗?或者你能给我一些关于如何让它工作的想法吗。我尝试过多次增加气体限制,但没有任何帮助。

气体属性定义每个事务发送的气体量。瓦斯含量很高。事务处理的总值为gas*gasPrice。因此,您在部署/发送期间默认发送16000000000 gwei(160以太)。若您使用一些测试客户端作为ganache,那个么测试地址的基本金额是每个帐户100以太

我尝试将合同部署到标准设置(天然气:6700000)上,一切都很好。在配置示例中,gas在部署期间超过了块限制。如果您以某种方式成功部署,这意味着您的“live env”配置允许这样的气体限制。EVM将剩余的tx气体返回给您,但在您的情况下,发送该气体太多

sudo truffle console
truffle(development)> Calculator.deployed().then(function(instance) { app = instance;})
undefined
truffle(development)> app.multiplication(5, 5, {from: web3.eth.accounts[0]});
Uncaught:
Error: Returned error: err: insufficient funds for gas * price + value (supplied gas 25000000)
    at evalmachine.<anonymous>:0:5
    at sigintHandlersWrap (vm.js:272:15)
    at Script.runInContext (vm.js:127:14)
    at runScript (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:251:1)
    at Console.interpret (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:266:1)
    at bound (domain.js:427:14)
    at REPLServer.runBound [as eval] (domain.js:440:12)
    at REPLServer.onLine (repl.js:760:10)
    at REPLServer.emit (events.js:315:20)
    at REPLServer.EventEmitter.emit (domain.js:483:12)
    at REPLServer.Interface._onLine (readline.js:329:10)
    at REPLServer.Interface._line (readline.js:658:8)
    at REPLServer.Interface._ttyWrite (readline.js:1003:14)
    at REPLServer.self._ttyWrite (repl.js:850:9)
    at ReadStream.onkeypress (readline.js:205:10)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:483:12)
    at emitKeys (internal/readline/utils.js:335:14)
    at emitKeys.next (<anonymous>)
    at ReadStream.onData (readline.js:1137:36)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:483:12)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at ReadStream.Readable.push (_stream_readable.js:212:10)
    at TTY.onStreamRead (internal/stream_base_commons.js:186:23)
    at TTY.callbackTrampoline (internal/async_hooks.js:120:14) {
  hijackedStack: 'Error: Returned error: err: insufficient funds for gas * price + value (supplied gas 25000000)\n' +
    '    at Object.ErrorResponse (/usr/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/errors.js:29:1)\n' +
    '    at /usr/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-requestmanager/src/index.js:140:1\n' +
    '    at /usr/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:112:1\n' +
    '    at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/webpack:/node_modules/web3-providers-http/src/index.js:96:1)\n' +
    '    at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)\n' +
    '    at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)\n' +
    '    at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:318:1)\n' +
    '    at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:289:47)\n' +
    '    at IncomingMessage.emit (events.js:327:22)\n' +
    '    at IncomingMessage.EventEmitter.emit (domain.js:506:15)\n' +
    '    at endReadableNT (_stream_readable.js:1220:12)\n' +
    '    at processTicksAndRejections (internal/process/task_queues.js:84:21)'
}
truffle(development)>
networks: {
    // Useful for testing. The `development` name is special - truffle uses it by default
    // if it's defined here and no other network is specified at the command line.
    // You should run a client (like ganache-cli, geth or parity) in a separate terminal
    // tab if you use this network and you must also set the `host`, `port` and `network_id`
    // options below to some value.
    //
     development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
     },
     live: {
       network_id: 2020,
       host: "127.0.0.1",
       port: 8545,
       from: "0x79b10CF39809f29160197ecbBdb21635684B0E45",
       gas: 8000000000,
       gasPrice: 20000000000
     },