Focus mode

Smart Contract Development with Solidity

Inheritance

Code from video: https://solidity-by-example.org/inheritance/ 

You can access the video content in Turkish prepared by İTÜ Blockchain here:  https://www.youtube.com/watch?v=KSrhlrHlti4&list=PLby2HXktGwN4Cof_6a8YwlMrboX8-hs73&index=15&t=2s 

When creating a smart contract, we can take advantage of all the functions of another smart contract by using the inheritance feature. The inclusion of contracts within each other allows writing of clean and understandable code, as in library usage. When a contract inherits from other contracts, only a single contract is created on the blockchain, and the code from all the base contracts is compiled into the created contract. Solidity is a programming language that supports multiple inheritances. 

"is, virtual, override" keywords used for inheritance:

Contracts can inherit other contracts using the ‘is’ keyword. (example: “contract B is A {}”)

virtual: The qualifier that indicates that the function can be overridden by a subcontract.

override: The qualifier that tells us to override and redefine functions marked with virtual in a base contract.

The general inheritance system is very similar to Python’s, especially concerning multiple inheritance, but there are also some differences.

Resources:

You can find detailed further information from Solidity Official documentation (in English): https://docs.soliditylang.org/en/v0.8.15/contracts.html#inheritance 

https://github.com/itublockchain/web3-bootcamp/tree/master/1x12_Inheritance


left-disk

Programs to Accelerate Your Progress in a Software Career

Join our 4-8 month intensive Patika+ bootcamps, start with the fundamentals and gain comprehensive knowledge to kickstart your software career!

right-cube

Comments

You need to enroll in the course to be able to comment!