7
votes

I am deploying a contract using truffle, and when I specify the gas limit as the gas I want to use for the transaction I always get the exceeds gas limit error. Why does this happen?

edit What I am trying to do is deploy the crypto kitties KittyCore.sol contract to my local devnet. I am using truffle to deploy it.

From another page, How to deploy truffle contract to dev network when using inheritance?, I found that since there is a contract hierarchy, I need to deploy my contracts in order. I used this technique, and I am able to deploy 4 out of 7 contracts, with the fifth, KittyAuction, giving the following error: The contract code couldn't be stored, please check your gas amount

Posted below is my truffle deployer script

var KittyCore = artifacts.require("KittyCore");
var KittyMinting = artifacts.require("KittyMinting");
var KittyAuction = artifacts.require("KittyAuction");
var KittyBreeding = artifacts.require("KittyBreeding");
var KittyOwnership = artifacts.require("KittyOwnership");
var KittyBase = artifacts.require("KittyBase");
var KittyAccessControl = artifacts.require("KittyAccessControl");
var SaleClockAuction = artifacts.require("SaleClockAuction");

module.exports = function (deployer) {
    deployer.deploy(KittyAccessControl).then(function () {
        return deployer.deploy(KittyBase).then(function () {
            return deployer.deploy(KittyOwnership).then(function () {
                return deployer.deploy(KittyBreeding).then(function () {
                    return deployer.deploy(KittyAuction, {
                        gas: 400000
                    }).then(function () {
                        return deployer.deploy(KittyMinting).then(function () {
                            return deployer.deploy(KittyCore);
                        })
                    })
                })
            })
        })
    });
};

My gas limit is set to 18000000000. This gas number is produced by running the following function on the actual contract that fails to deploy

var gasPrice;
KittyAuction.web3.eth.getGasPrice(function (error, result) {
    gasPrice = Number(result);
    console.log(gasPrice);
})

I have been fiddling with this number and nothing seems to work.

1
What's the smallest gas limit you can set and still have the transaction succeed?carver
Also, edit your question to include your contract code, the gas limit you're specifying, and how you came up with that number.Adam Kipnis
I'm trying to deploy the cryptokitties main contract to my local devnet. It's a lot of quote to post but it is freely available and I have not made any changes except adding the payable keyword to the Constructoryemista

1 Answers

3
votes

So I was able to deploy it. What I did was reset my blockchain, and set gasLimit to 0x8000000 and gave each contract that was troublesome a gas value of 0x7000000, and it deployed. Funny thing though, it wouldnt deploy again. I guess the gasLimit adjusted after a few blocks were mined because I got an error saying I was over the limit