Inheritance – ‘is’ keyword
In the context of Solidity, Inheritance refers to the property of once smart contract to acquire properties of another smart contract. The ‘is’ keyword is used for two purposes:
- For inheriting smart contract.
- For implementing interfaces.
- Below is an example for implementing interface (Same can be done for another contract).
Example:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.25;
interface GeekToken {
// Function Declarations
function transfer(address _from, address _to) external returns (bool);
function balanceOf(address account) external returns (uint256);
}
// GeekContract implements the GeekToken interface
contract GeekContract is GeekToken {
uint256 public balance;
function transfer(address _from, address _to) external override returns (bool) {
// * Transfer logic
return true;
}
function balanceOf(address _account) external override returns (uint256) {
// BalanceOf Logic
balance = _account.balance;
return balance;
}
}
Explanation:
- You might encounter some warning as for simplicity we haven’t implemented the logic
- ‘GeekToken’ is an interface, implemented by ‘GeekContract’ named contract and its overriding the functions present in the interface, by utilising function type keywords such as – ‘override’
Output:
Unlock the Power of Solidity: Exploring the Essential Keywords for Smart Contract Development
Solidity is a smart contract programming language built solely to develop smart contracts that can be deployed on blockchains. C++ and JavaScript inspired it, an Object Oriented and High-Level language (HLL), that helps developers define the behaviour and rules for a Decentralized Application (Dapp). Smart contract facilitates autonomous, secure, and efficient transaction execution on the blockchain without needing any intermediary (self-executable) and solidity provides the base framework for achieving the same.
It is essential to understand the common keywords used in solidity to solidify your core understanding of the language so in this article, we’ll pin down some prominent keywords that help us develop these smart contracts by embracing the true power of solidity language.
Table of Content
- Contract
- Constructor
- Data Types
- Delete
- Enum
- Function
- Interface
- Import
- Struct
- Visiblity Specifiers
- Exception Handling
- Pragma Directive
- License Defintion
- Modifier
- Data Location
- Global Variables
- Fallback Function
- SelfDestruct
- ‘assembly’ and ‘inline assembly’