I'm getting the error:

Contract "StarNotary" should be marked as abstract.

pragma solidity >=0.4.24;

import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract StarNotary is ERC721 {
    struct Star {
        string name;

    mapping(uint256 => Star) public tokenIdToStarInfo;
    mapping(uint256 => uint256) public starsForSale;

    // Create Star using the Struct
    function createStar(string memory _name, uint256 _tokenId) public {
        Star memory newStar = Star(_name);
        tokenIdToStarInfo[_tokenId] = newStar;
        _mint(msg.sender, _tokenId);

    // Putting an Star for sale (Adding the star tokenid into the mapping starsForSale, first verify that the sender is the owner)
    function putStarUpForSale(uint256 _tokenId, uint256 _price) public {
            ownerOf(_tokenId) == msg.sender,
            "You can't sale the Star you don't owned"
        starsForSale[_tokenId] = _price;

    function _make_payable(address x) internal pure returns (address payable) {
        return address(uint160(x));

    function buyStar(uint256 _tokenId) public payable {
        require(starsForSale[_tokenId] > 0, "The Star should be up for sale");
        uint256 starCost = starsForSale[_tokenId];
        address ownerAddress = ownerOf(_tokenId);
        require(msg.value > starCost, "You need to have enough Ether");
        transferFrom(ownerAddress, msg.sender, _tokenId);
        address payable ownerAddressPayable = _make_payable(ownerAddress);
        if (msg.value > starCost) {
            msg.sender.transfer(msg.value - starCost);

What I know of abstract contracts is that they have to do with interfaces. I have a suspicion that it has to do with the inheritance from ERC721 of the Open Zeppelin library.

ERC721 has three interfaces it's inheriting from: IERC721, IERC721Metadata, IERC721Enumerable. Do I have to go through the entire list of functions from those three interfaces and fill in what's missing in either the StarNotary contract or ERC721?


Overview of the issue

You get this error whenever there are functions you need to implement in your contract from an inherited contract. For example, if you have a contract that inherits an interface that has a callMe function declared, you'll need to make sure your contract has a callMe function somewhere.

What happened here

In this specific case, you are missing the constructor call. Even if you don't want to change the original ERC721 constructor, you still need one in your contract. Therefore you get the error of declaring it 'an abstract' contract. Abstract contracts cannot be instantiated.

constructor() ERC721("GameItem", "ITM") public { }

is already enough. You can always check the docs to see how to use a contract: https://docs.openzeppelin.com/contracts/3.x/erc721

Another example

Another example would be if you have a contract that looked like this:

pragma solidity ^0.8.9;

interface inheritMe {
    function interitedFunction() external;

contract mainContract is inheritMe {

in this example, you'll also run into this error. This is because our contract mainContract is intheriting inheritMe, which has a interitedFunction, but that function is not defined. So without defining interitedFunction, this means our mainContract also has this undefined function. If we have a contract that has both defined and undefined functions, this is known as an abstract contract.

interface: All undefined functions abstract: Mixed defined and undefined functions contract: All functions defined

  • wow that worked. Thank you so much
    – Kevvv
    May 11 '20 at 14:14

@Markus's answer is correct. But you should also be sure that there isn't a

Missing implementation: function ...

line hiding just beneath the error message. In my case I was inheriting from an Interface, but forgetting to implement one of the necessary functions.

  • 2
    nice suggestion to add
    – Jeevanjot
    Feb 10 at 16:15

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.