1

I'm totally newbie in blockchain programming and I have a situation:

I have to continue the project written on truffle framework with solidity version 0.4.17, the problem is that I couldn't manage to compile the project because it was showing with the following(there were many like these) warnings:

Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.5.0;"
SyntaxError: Functions are not allowed to have the same name as the contract. If you intend this to be a constructor, use "constructor(...) { ... }" to define it.
Warning: This declaration shadows an existing declaration.
TypeError: Data location must be "memory" for parameter in function, but none was given.

I changed all contracts version with "pragma solidity ^0.5.0;" as it was suggested. but the other warnings were showing for every contract and I have to manually correct them. Whenever I'm correcting them in one contract then another contract shows the same warnings, and they are too many.

So my question is can I avoid manually correcting them? Is there any other way? (maybe continuing development on solidity ^0.4.17 somehow)

PS. project was written one and half year ago and was compiling and working.

Any help will be apprecited

  • Keep your Truffle version on 4.1.15 at most, then you'll have very few changes (compiler version is 0.4.25 in this case). – goodvibration Mar 17 at 20:34
0

Well, yes, nothing prevents you from using an old compiler version. I guess you should also use an old Truffle version - I'm not sure how backwards compatible they are.

Even if you changed your contracts into version 0.5.x you would get compatibility issues. Especially since version 0.5.0 there are a few major breaking changes in the compiler so you would have to go fixing the actual code as well.

You can get older truffle (for example with npm at https://www.npmjs.com/package/truffle ) and if needed, older solc compiler with instructions from here for example: https://www.npmjs.com/package/solc . I'm not very npm-knowledgeable so I'm not sure how you can get an older version but I'm sure it's not difficult to find out how exactly you can get an older version of both with npm if needed.

For the needed versions, at least according to Contracts will not compile using truffle with the "emit" keyword included in front of events truffle version 4.1.3 is quite close to what you need.

  • If the combination of Truffle 4.x and Solc 0.4.x is chosen, then it's probably best to go with Truffle 4.1.15 which relies on Solc 0.4.25. That would require very few changes from Solc 0.4.17. – goodvibration Mar 17 at 20:38

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.