From the solidity docs I have read that:

The version pragma is used as follows: pragma solidity ^0.5.2;

A source file with the line above does not compile with a compiler earlier than version 0.5.2, and it also does not work on a compiler starting from version 0.6.0 (this second condition is added by using ^). Because there will be no breaking changes until version 0.6.0, you can be sure that your code compiles the way you intended. The exact version of the compiler is not fixed, so that bugfix releases are still possible.

In npm it seems to be a bit different. From this blog post it says:

So if you see ~1.0.2 it means to install version 1.0.2 or the latest patch version such as 1.0.4. If you see ^1.0.2 it means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.

Is semantic versioning in solidity different from that in npm or am I missing something?

1 Answer 1


I have found an answer to my question. Thanks to this question and its comments.

Before the major versioning gets to 1 i.e 0.x.x the caret ^ and the tilde ~ act in the same way. Visit this site, npm semver calculator, to experiment and learn more.

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.