0

I have unboxed pet-shop. Then inside the contracts folder, I made a file Election.sol which has the code -

pragma solidity ^0.5.8;


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

    }   
}

Then inside migrations folder, I made 2_deploy_contract.js which has the code -

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

module.exports = function(deployer) {
  deployer.deploy(Election );
};

Truffle-config.js -

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*", // Match any network id
      from:"0xCAEf077F78ce851B21524363753b4A49a4a6D503",
    },
    develop: {
      port: 8545
    }
  }
};

When I do truffle migrate, I get this error. - 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)

Truffle v5.0.22 (core: 5.0.22) Node v8.10.0

  • @shaileshMishra can you please help in this question. I am not being able to comment in the previous one. – neha agarwal Jun 25 at 7:48
  • try to set gas for the transaction using deployer.deploy(Election, {gas: 4612388, from: "0x...."});. The problem seems to be that the gas limit for the transaction is greater then the allowed block limit – Hamza Ahmed Jun 26 at 6:39
1

You can set also the gas amount on your truffle-config.js, try setting the gas like this one below:

...
networks: {
    ropsten: {
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/xxxxxxxx"),
      network_id: 3,
      gas: 4600000
    },
}
...
  • I have tried this but I get the same error @Joenel de Asis – neha agarwal Jun 27 at 13:19
  • When I run "ganache-cli", it says - command not found. And if I write this "npm install -g ganache-cli" This comes- /home/neha/.npm-global/bin/ganache-cli -> /home/neha/.npm-global/lib/node_modules/ganache-cli/cli.js /home/neha/.npm-global/lib `-- ganache-cli@6.4.4 – neha agarwal Jun 27 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.