DeFi
DeFi

Reputation: 97

TypeError: in Solidity Contract ("should be marked as abstract")

I get the following error message.

TypeError: Contract "InterfaceB" should be marked as abstract.

The error goes away once I change contract InterfaceB to interface InterfaceB.

The code is as follows.

pragma solidity ^0.8.0;

contract InterfaceB {
    function getMessage() external pure returns(string memory);
}

contract ContractB {    
    function getMessage() pure external returns(string memory){
            return "Hellow World.";
    }
}

How can I solve this?

Upvotes: 0

Views: 136

Answers (1)

Yilmaz
Yilmaz

Reputation: 49182

If you want to define an interface, you have to use interface keyword.

interface InterfaceB {
    function getMessage() external pure  returns(string memory);
}

Any contract that has at least one unimplemented function is treated as abstract in Solidity. In your case you have contract InterfaceB which has one unimplemented function:

  function getMessage() external pure returns(string memory);

so Remix detects that this is an abstract contract

Upvotes: 3

Related Questions