0

I am attempting to deploy a simple ERC998ERC721TopDown token, forked from this repository, using truffle. However, during deployment, the contract ComposableTopDown is failing with this out of gas error:

Error:  *** Deployment Failed ***

"ComposableTopDown" ran out of gas. Something in the constructor (ex: infinite loop) caused gas estimation to fail.

The constructor in this code has been commented out - it doesn't exist.

//constructor(string _name, string _symbol) public ERC721Token(_name, _symbol) {}

I have added all these suggestions to optimise gas and EVM version, but it makes no difference to the error.

Is the deployment failing becuase there is no valid constructor? Or is there some other reason?

EDIT:

If I uncomment the constructor, the deployment still fails - but if I change the constructor to constructor() public {}, then the contract deploys. I want the contract to inherit ERC721, so what is wrong with the commented out constructor?

1 Answer 1

0

There are two relevant limits here and you are falling afoul of one of them.

  • A hard contract size limit. There is only so much code that can fit into one contract saved on the blockchain. (The constructor is exempt from this part because the constructor does not endure on the blockchain.)

  • The gas limit you set when signing the transaction.

As a test, try deploying with Remix on VM using a gas limit of 99000000 (99 million). Does that work? And what is the transaction gas cost?


It is also possible the constructor is causing an error.

Can you please perform the above transaction you are debugging on a live network (like Ropsten), and verify the source code?

The dependencies on this project are ancient, using known-broken versions of Solidity, Open Zeppelin Contracts, and Truffle.

I'm going to guess the problem is something dumb that is fixed with later dependencies, such as Truffle calling the contract constructor incorrectly, resulting in the initializer parameters not being passed, and then this being interpreted as a string at location 0, and then that string having 4 billion length because it is the same as the function selector. // All this can only be properly diagnose with a full trace (like Etherscan is able to show).

1
  • The github mentioned in the question is an example project with the purpose of being forked and redeployed. I'm almost certain that the contract size isn't the issue, unless the github owner is deliberately pushing broken code. I edited the question after adding a blank constructor and it seems to compile and deploy just fine. So there's some other weird issue behind this. Dec 17, 2021 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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