Blockchain 迁移耗尽了气体

Blockchain 迁移耗尽了气体,blockchain,ethereum,truffle,Blockchain,Ethereum,Truffle,我用的是Ganache。我开了宠物店。然后在contracts文件夹中,我创建了一个文件Election.sol,其中包含代码 pragma solidity ^0.5.8; contract Election{ string public candidate; constructor() public{ candidate = "candidate 1"; //state var } } 然后在migrations文件夹中,我制作了2\u

我用的是Ganache。我开了宠物店。然后在contracts文件夹中,我创建了一个文件
Election.sol
,其中包含代码

pragma solidity ^0.5.8;  

contract Election{
    string public candidate;
    constructor() public{
        candidate = "candidate 1"; //state var

    }   
}
然后在migrations文件夹中,我制作了
2\u deploy\u contract.js
,其中包含代码

var Election = artifacts.require("./Election.sol");

module.exports = function(deployer) {
  deployer.deploy(Election );
};
当我使用命令
-truffle migrate
执行truffle migrate时,会出现此错误

Compiling your contracts...
Everything is up to date, there is nothing to compile.

Migrations dry-run (simulation)
Network name: 'development-fork' Network id: 1 Block gas limit: 0x1388

1_initial_migration.js
Deploying 'Migrations'

Error: Error: Error: * Deployment Failed *

"Migrations" ran out of gas (using Truffle's estimate.) * Block limit: 0x50e7c * Gas sent: undefined * Try: + Setting a higher gas estimate multiplier for this contract + Using the solc optimizer settings in 'truffle-config.js' + Making your contract smaller + Making your contract constructor more efficient + Setting a higher network block limit if you are on a private network or test client (like ganache).

at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-migrate/index.js:92:1)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
编译您的合同。。。
一切都是最新的,没有什么可编译的。
迁移干运行(模拟)
网络名称:“开发分叉”网络id:1区块气体限值:0x1388
1_initial_migration.js
部署“迁移”
错误:错误:错误:*部署失败*
“迁移”用光了汽油(根据块菌的估计)*块限制:0x50e7c*发送的气体:未定义*尝试:+为此合同设置更高的气体估算乘数+使用'truffle config.js'中的solc优化器设置+使合同更小+使合同构造函数更高效+如果您在专用网络或测试客户端上,则设置更高的网络块限制(像加纳什)。
在Object.run(/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle migrate/index.js:92:1)
在
在进程中。_tick回调(内部/process/next_tick.js:188:7)

我已经看到一些类似问题的解决方案,但它无法解决我的问题。

问题看起来不错,我会检查并让您知道。谢谢,@Div!!请让我知道。我在这个问题上停留了很长时间,无法继续。当我运行“ganache cli”时,它会显示-command not found。当我执行“npm install-g ganache cli”时我得到这个错误-/home/neha/.npm global/bin/ganache cli->/home/neha/.npm global/lib/node\u modules/ganache cli/cli.js/home/neha/.npm global/lib`--ganache-cli@6.4.4You可以尝试像deployer.deploy(Election,{gas:155000})那样手动设置gas问题看起来不错,我会检查并让你知道。谢谢,@Div!!请让我知道。我被困在这个问题上很长时间了,无法继续。当我运行“ganache cli”时,它会显示-command not found。当我运行“npm install-g ganache cli”时我得到这个错误-/home/neha/.npm global/bin/ganache cli->/home/neha/.npm global/lib/node\u modules/ganache cli/cli.js/home/neha/.npm global/lib`--ganache-cli@6.4.4You可以尝试像deployer.deploy(Election,{gas:155000})那样手动设置gas