I've seen similar questions, but none answer why people use abstract contracts. I come from a non-OOP JavaScript background, so I have some trouble understanding these things.

From the docs:

pragma solidity ^0.4.0;
contract Feline {
    function utterance() public returns (bytes32);
contract Cat is Feline {
    function utterance() public returns (bytes32) { return "miaow"; }

What is the benefit of defining Feline here in the first place? The only benefit I can think of is if you have many different kind of feline contracts and you want to make sure they all include utterance() I guess? But I really cannot think of any such situations...

Are there benefits I'm not seeing? Coming from my background you'd want to avoid things like this, where you just want a Banana but get a Gorilla holding it, along with the entire Jungle...

PS: The question is not the difference between interfaces and abstract contracts.

2 Answers 2


You are not forced to create and abstract contract to do an implementation. Solidity is not a strongly OOP language, even if something is derived from OOP (interface, inheritance, abstract contracts).

So said abstract contracts will give you another level of abstraction and the main reason to use it is to be sure that who implements the contract will follow its definition (as you described in your post) and provide common functionalities to the child contracts.

You can find plenty post on stackoverflow that will describe the benefits. Here and here for example.

From one of those posts:

Abstract Classes are a good fit if you want to provide implementation details to your children but don't want to allow an instance of your class to be directly instantiated (which allows you to partially define a class).
Abstract methods are useful in the same way that defining methods in an Interface is useful. It's a way for the designer of the Abstract class to say "any child of mine MUST implement this method".

  • Cool! I didn't check stackoverflow! What do you mean with "to be sure that who implements the contract" How/why would someone try to implement my contract?
    – mesqueeb
    Commented May 9, 2018 at 10:02
  • Is not someone else but you. If you have different Felines you want them to follow the same structure. Then you define the abstract contract and all your child contracts will follow it. There are cases when the an abstract contract can be a standard de-facto (look at the ERC20 token) but that's another story ( theethereum.wiki/w/index.php/ERC20_Token_Standard )
    – qbsp
    Commented May 9, 2018 at 10:15
  • 2020 update: there's a new abstract keyword that can be placed in front of the contract definition when defining an abstract. Commented Jun 6, 2020 at 19:57

"If a contract inherits from an abstract contract and does not implement all non-implemented functions by overriding" from solidity docs. So an abstract contract make sure your child contract implement functions of the base contract. https://docs.soliditylang.org/en/v0.6.2/contracts.html#abstract-contracts

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.