for example:

contract A {
    uint constant public START_TIME = 10;

import "./A.sol"

contract B {
    function test() public {
        uint startTime = A.START_TIME;

If I only need the value of constants, I do not need the actual instance, right?


The constant is defined and stored in the contract. Therefore, you do need the instance of the contract the constant is defined in.

  • Solidity should provide this feature, but they didn't. – Boyuan Wang Aug 28 '18 at 21:30
  • I disagree. It's good to define constants in places where they make sense. – Henk Aug 29 '18 at 5:58

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.