0

I made 2 contracts in 2 different solidity files. Lets for simplicity assume the contracts are called A and B. A contains data and some simple function calls, B contains more complex function calls. What I try to achieve now is for the functions in B to call the functions in A. In order to do so, I tried to define an interface in the file where contract B is defined. I do this as follows

B.sol
contract B
{
  function b1()
  {
     #implementation
  }
}
contract A
{
  function f1;
  function f2;
}

In A.sol I have the implementation of contract A:

A.sol
contract A
{
  #implementation
}

However, my compiler returns an error. It says that the contract A defined B.sol should be called abstract. According to the courses I followed, I shouldn't get this error. According to the courses this was the correct way to defined the interface of contract A inside B.sol in order for contract B to be able to use the functions defined in contract A. Anyone else knows what is the problem here and how to fix it ?

1 Answer 1

0

The course should had been base on an old solidity version. Since solc v0.6 it is mandatory to declare classes without implementation as abstract. Currently solc is at v0.8.

As suggested by the compiler declaring A inside B as abstract should work. Another option is to directly "import" A.sol from B.sol.

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.