I have two contracts with variables and functions that each should need to reference/call. I would prefer to separate the contracts, as different user groups would be accessing each. Can two contracts import each other? Or is there an order of operations -so to speak- wherein only one contract can be dependent on another?

  • As far as I understand there can't be circular imports. Commented Nov 14, 2016 at 12:25

1 Answer 1


Yes, you can compile two contracts that call each other. For example,

contract InterfaceOfA {
        function f(uint) returns (uint);

contract InterfaceOfB {
        function g(bool) returns (bool);

contract A is InterfaceOfA {
        InterfaceOfB b;
        function f(uint _input) returns (uint) {
                return 3;

contract B is InterfaceOfB {
        InterfaceOfA a;
        function g(bool _input) returns (bool) {
                return false;
  • 1
    Functionally, is there any difference if the two contracts modify each other in the same .sol file vs. importing and modifying each other from separate .sol files? Commented Nov 15, 2016 at 16:30

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.