2

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?

1

1 Answer 1

2

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

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

Your Answer

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

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