Learn Solidity: Abstract Contracts in Solidity

In this post, we will learn what are abstract contracts & how to use them in Solidity Language.

Notice: This is one of the multi-post series of Learn Solidity - Build Decentralized Application in Ethereum. This is an attempt to teach you all about Solidity - A Programming Language for Ethereum Based Smart Contracts. If you want to take this as a video course please signup using below button.

[pastacode lang=”javascript” manual=”pragma%20solidity%200.4.8%3B%0A%0A%2F%2F%20These%20abstract%20contracts%20are%20only%20provided%20to%20make%20the%0A%2F%2F%20interface%20known%20to%20the%20compiler.%20Note%20the%20function%0A%2F%2F%20without%20body.%20If%20a%20contract%20does%20not%20implement%20all%0A%2F%2F%20functions%20it%20can%20only%20be%20used%20as%20an%20interface.%0A%0A%2F%2F%20Let%20me%20write%20an%20abstract%20contract%20with%20a%20single%20function%20and%20then%20extend%20it%20%0A%2F%2F%20in%20the%20new%20contract%20and%20then%20override%20it%20there.%0Acontract%20Feline%20%7B%0A%09%2F%2F%20This%20is%20how%20we%20write%20the%20abstract%20contract%20%0A%20%20%20%20function%20utterance()%20returns%20(bytes32)%3B%0A%7D%0A%0A%2F%2F%20inherit%20the%20contract%20in%20cat%20and%20then%20override%20the%20function%20utterance%20with%20some%20full%20definition%0Acontract%20Cat%20is%20Feline%20%7B%0A%20%20%20%20function%20utterance()%20returns%20(bytes32)%20%7B%20return%20%22miaow%22%3B%20%7D%0A%7D%0A%0A%0A” message=”” highlight=”” provider=”manual”/]



[otw_shortcode_button href=”https://www.toshblocks.com/solidity/fallback-function-solidity/” size=”large” icon_type=”general foundicon-left-arrow” icon_position=”left” shape=”radius” color_class=”otw-blue”]Previous: Fallback Function in Solidity [/otw_shortcode_button][otw_shortcode_button href=”https://www.toshblocks.com/solidity/creating-contracts-via-new-operator/” size=”large” icon_type=”general foundicon-right-arrow” icon_position=”right” shape=”radius” color_class=”otw-green”]Next: Creating a Contract with new Operator in Solidity[/otw_shortcode_button]