-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contract creation code storage out of gas #255
Comments
It looks like you are using v3 (the current production release), which sets the gas limit to 1,500,000 if not specified. In v4 ( To solve this in v3 though, you should be able to: // Before sending the transaction, increase the gas limit of the transaction
// You should be able to see in remix the gas limit required to deploy it
deployTransaction.gasLimit = 2000000; Let me know if that still doesn't work. |
Hi Ricmoo, So far I've refactored just one feature of the contract, as shown on the code bellow, and it is working. Now I'll load all remaining features and data, to the point it was before, and test again. I'll let you know. ++++++++Interface and Storage Contrac (FutureStorage.sol) +++++++++
} ++++++++Business Logic Contrac (FutureContract.sol)+++++++++
} |
Ah yes, if you are trying to deploy to a real network, the block gas limit will restrict the complexity of your contract. There is also a transaction gas limit, which is not part of the protocol, but often enforced by miners, so exceeding this may also result in your transaction not being mined. There are certainly contracts far more complicated than yours that are on-chain. For example, CryptoKitties. Are you enabling the optimizer for your compiled code? Give the contract above, I would not expect it to exceed the block gas limit. You can also use delegatecall to spread (and share) code logic across contract addresses (at an extra gas cost for making the external call; 800 gas, I believe). |
Hi, Is ethers v4 backward compatible, or would you have some document with the differences? Thank you Ricmoo |
It is not backwards compatible, but all features exist. We are working on the documentation, which includes a short migration guide. Most things stayed the same, but for your purpose: // Version 3
var provider = ethers.providers.getDefaultProvider();
// Version 4
var provider = ethers.getDefaultProvider(); Deploying is a bit different too. In v3, there was a function to create a transaction to deploy, in v4: // An abstract contract is one without an address; obviously calling most methods on it are not
// possible, much like an abstract class in C++ or Java.
var abstractContract = new ethers.Contract(null, abi, signer);
// This deploys it to chain, using the signer; arg1, arg2, etc are just parameters to the
// constructor; if you don't have any the bytecode is sufficient
var contract = abstractContract.deploy(bytecode, arg1, arg2, etc);
// The contract is probably not mined yet, but you have access to useful things...
console.log(contract.address, contract.deployTransaction);
// You can wait for the contract to deploy... This will reject and error if the deployment
// fails, for example, gas limit was too low, or the constructor called `revert`
await contract.deployed(); Most of the other changes are fairly internal. :) |
I think this is resolved now, so I'm going to close it. If this is still an issue though, please feel free to re-open it. Thanks! :) |
Hi,
I'm getting a Tx Receipt fail with the error message: Warning! Error encountered during contract execution [contract creation code storage out of gas], when trying to deploy a contract creation on Rinkeby with the script deploy-ethers.js bellow.
https://rinkeby.etherscan.io/tx/0xb06380de0996e5b90661e8fcf53bf49cf6f76eae4fc3d5cda1431769f37d17cd
But actually if I go directly on Remix, using an account with Injected Web3, the deployment of the Factory works, and also it works the deployment of child contracts using the Factory.
https://rinkeby.etherscan.io/tx/0xb4f73b2a361693159b1a009967a42947c126a48bc23c5d193933c2415a5b1430
Ps. If I change the script to deploy straight a child futureContract (but not the factory), it ideed works.
Should I set manually some override for Gas ?
Thank you for any help
++++++++++deploy-ethers.js+++++++++++
require("../config/config.js");
const ethers = require("ethers");
// ps. build/FutureContractFactory.json was generated with solc in a previous step
const compiledFactory = require("./build/FutureContractFactory.json");
const NETWORK = process.env.NETWORK;
const bytecode = compiledFactory.bytecode;
const abi = JSON.parse(compiledFactory.interface);
const deploy = function() {
var deployTransaction = ethers.Contract.getDeployTransaction(
"0x" + bytecode, abi
);
var provider = ethers.providers.getDefaultProvider(NETWORK);
var pk = "0x797336cf22a6171b4cb179d6a9c08e5848cbd1748563bc44ea66c506fb0aef8c"; // Only on test network
var wallet = new ethers.Wallet(pk, provider);
var sendPromise = wallet.sendTransaction(deployTransaction);
sendPromise.then(function(transaction) {
console.log("DEPLOYED TO: ", transaction);
});
};
deploy();
++++++++++Solidity Contracts Fabric and Child+++++++++++
pragma solidity 0.4.24;
}
contract FutureContract {
enum State { Created, Settled, Closed }
}
The text was updated successfully, but these errors were encountered: