What Can You Do With Solidity?
If you're reading this in 2023, and if you've done even just a bit of personal research on web3 and its underlying technologies – distributed ledgers, digital currencies, smart contracts, and NFTs – then you will surely have come across the word Solidity.
Solidity is, by far, one of the most prominent smart contract programming languages used in the world of web3.
It can be used to write smart contracts for various applications such as governance, staking, crowdfunding, multi signature wallets, and a whole lot more.
Solidity smart contracts have plenty of potentially disruptive use cases across industries. This article will tackle some of the most compelling use cases for Solidity smart contracts, and see how they will, in theory, usher in the web3 era.
What is Solidity?
In a nutshell, Solidity is an object-oriented, high-level programming language used to develop smart contracts and create decentralized applications (dapps). Solidity supports complex user-defined types, libraries, and inheritance, besides being statically typed.
Solidity smart contracts are responsible for implementing agreements between two parties, including business logic. They are high-level program codes that are compiled into the Ethereum Virtual Machine (EVM) before being posted on the Ethereum blockchain to be executed.
What are the main features of Solidity?
Here are some of the main features that Solidity that distinguish it from other programming languages based on the Ethereum Virtual Machine (such as Vyper, Flint, or LLL):
- Solidity supports multiple inheritances with C3 linearization.
- Solidity supports a host of programming functions such as state objects, variables, and data types, among others.
- Solidity provides smart contracts with structs and arbitrary hierarchies with complex member variables.
- Solidity, through its application binary interface, enables type-safe functions within a single smart contract.
Solidity serves as the core language of Ethereum, but it is also supported by a host of other EVM-compatible blockchain platforms. These include BNB Chain, Tendermint, Ethereum Classic, Hedera Hashgraph, and Counterparty, just to name a few.
What data types does Solidity support?
Solidity supports all object oriented programming language data types, such as the following:
- Integers. Solidity supports both signed and unsigned integers. Solidity also supports runtime exceptions.
- Booleans. A boolean datatype returns one of two possible values: "1" as "true," and "0" as "false" based on a condition's accuracy. The output is typically produced as a boolean value when logical operators are used.
- Modifiers. Modifiers are used to determine the consistency of all conditions before the execution of the smart contract code.
- String Literals. String literals contain a sequence of characters or escape sequences represented by single or double quotation marks.
Solidity also supports data structures referred to as "mappings," which are composed of operators, enums, hash values, and arrays. Mappings are used to return values linked to contract storage locations. And since the syntax for mappings is similar to most generic programming languages, Solidity mappings support multi-dimensional and single arrays altogether.
How does Solidity actually work?
We already know that Solidity developers use the programming language to create smart contracts.
But to determine how smart contracts work, we'll need to have a good understanding of how Solidity actually works.
See, the wonder of the Ethereum blockchain is that it supports an entire universe of cryptocurrencies, non-fungible tokens, and dapps thanks to smart contracts. Smart contracts enable all sorts of new, disruptive technologies to be built on Ethereum for all sorts of industries, organizations, and enterprises worldwide.
Billions of dollars are being plowed into developing blockchain-based solutions – and a great majority of these solutions are built using Solidity.
A major component that enables the implementation of Solidity code is the Ethereum Virtual Machine – a virtual computer based on the blockchain that turns ideas into code and implements it on-chain.
Solidity produces machine-level code that is deployed on the EVM. Then, a Solidity compiler is used to break it down to high-level code readable by humans, turning it into a set of specific instructions that the processor reads. Solidity compilers are available on a variety of different online and offline platforms.
Now, let's drill down on the nitty-gritty details of Solidity underneath the hood.
What are public and private functions in Solidity smart contracts?
In Solidity, functions simply refer to self-contained modules of code written to accomplish a particular task. As with other programming languages in web3, Solidity enables Solidity developers to write modular smart contract code using functions to reduce the redundancies in rewriting the same snippet of code over and over again.
In Solidity, we have two main types of functions: public and private.
Public functions are similar to APIs that anyone can access. These functions can be called internally or through EVM message calls. They are designed to be used for shared processes on platforms for the utilization of every user.
For instance, a public function can be made to enable users on a particular platform to check account or token balances.
Private functions, on the other hand, can only be called from within the smart contracts where they are defined. These private functions contain instructions to be performed only after being called on by other pre-existing functions within a single chain, making them harder to be exploited by external threat actors.
What are the existing standards for Solidity/Ethereum smart contracts?
As Solidity smart contract development continues to evolve, different standards are being created. These standards determine exactly how Solidity smart contracts are used to create decentralized applications on Ethereum. They are called Ethereum Request for Comments (ERC) standards, which serve as guidelines on how a particular piece of code should function on the Ethereum blockchain. Here are some of the most prominent ERC standards.
- ERC-20. The ERC-20 token standard is a blueprint for creating fungible or interchangeable tokens, such as governance tokens or digital currencies.
- ERC-721. The standard interface for creating non fungible tokens (NFTs).
- ERC-777. A token standard iterating on ERC-20, with extra functionality for privacy and recovery. ERC-777 tokens remain fully compatible with decentralized exchanges.
- ERC-1155. A token standard that enables efficient transfers of fungible and non-fungible tokens in one transaction for more efficient bundling of transactions and efficient trades.
There is a more comprehensive list of all existing ERC standards on Ethereum, but there's no doubt that the aforementioned ones are the most utilized.
What are gas fees in Solidity?
The unit of measurement used by Ethereum to determine the amount of computational effort needed to perform specific tasks on the blockchain is called gas.
These are the extra fees needed to pay miners for securing the Ethereum network that Solidity smart contract code runs safely on-chain.
Therefore, when Solidity developers write smart contracts, they need to ensure that the contract's use of gas fees is efficient. Gas-efficient smart contracts are part and parcel of good solidity programming. This will ensure the good performance of a smart contract. Smart contracts that are costly to run will not be used over the long term.
One way Solidity developers optimize gas fees when writing smart contracts is by using libraries and only a few functions to save bytecode. That is, rather than adding bloated bytecode to the smart contract, the smart contract logic can be put into libraries to keep the smart contract size compact.
What are the main use cases of Solidity smart contracts?
Solidity smart contracts are being employed across a swathe of industries, ushering a wave of disruption as it heralds the new era of web3. Here are some of the most compelling use cases of Solidity smart contracts.
Banking and financial services
One of the most prominent sectors that smart contracts are disrupting is the banking and financial services sector. Smart contracts can be programmed to stipulate, lay out, and implement the rules governing financial products or services. They can also facilitate blockchain-based payments, settlements, trades, and claims.
Moreover, they can create financial products such as derivatives, mortgages, loans, synthetics, and foreclosures, just to name a few.
The advent of decentralized finance, or DeFi, is showing the way forward as far as breaking down the barriers of the highly-gatekept world of traditional finance, allowing underserved or unbanked individuals to avail of financial services without the need for any intermediaries or KYC procedures.
DeFi dapps are democratizing banking and financial services that were once restricted to them – and these apps achieve it simply by using Solidity smart contracts and open-source blockchain ecosystems. Lastly, since DeFi platforms provide round-the-clock access to financial services and real-time settlement, it offers users hitherto unavailable services at any time they please, with no physical offices, centralized custody, and unnecessary fees typically associated with traditional banking and financial services.
Protection of digital identity and prevention of identity theft
Solidity smart contracts offer proofs of concept and real-world use cases of digital identity. While it isn't yet possible to engage in each and every kind of anonymous financial transaction online – particularly when it comes to environments with strict regulatory presence – smart contracts offer new digital identity solutions that could eventually add additional layers of privacy when needed.
For instance, Solidity smart contracts can store personally identifiable information (PII) such as passport details on the Ethereum network and accessed only by an authorized dapp. Through the disintermediation of identity databases, smart contracts provide an alternative way to manage PII without limiting it strictly to one single point of failure as a centralized database. This reduces the overreliance on such entities, reducing the risk of data breaches.
Decentralized autonomous organizations (DAOs)
Another interesting possibility that smart contracts provide for corporations and organizations is the framework for decentralized governance called DAOs. DAOs can be applied to communities of individuals online, or alternatively, to businesses, non-profit organizations, or corporations.
Solidity smart contracts can be used by today's businesses to enable new, exciting management, governance, compensation, and ownership structures without the need for conventional compliance measures while enforcing incentives and penalties without the need for a centralized management structure.
Smart contracts in the legal setting
Smart contracts seem like a perfect fit for the legal realm. But is there a way for smart contracts to actually, truly automate and enforce the law? The prospects are intriguing when we think about a future wherein law and distributed ledger technologies intersect.
Since smart contracts on Solidity do have the innate potential to be just as legal and binding as traditional contracts on paper, it's all just a matter of time before such physical contracts between two parties are fully automated using smart contract technology.
The benefits are immense: lower administrative costs, faster transaction speeds, and immutability and proof of provenance from the blockchain make smart contracts seem to be a match made in heaven.
Gaming has become one of the main sectors where Solidity smart contracts offer massive potential. The NFT boom, for instance, has made gaming not only entertaining and exciting but also profitable for users.
Moreover, through smart contracts, anyone can mint NFTs and launch NFT marketplaces where gaming avatars, special items, and other virtual assets can be traded for a profit, besides being used for a variety of games.
NFTs enable gamers to take control and ownership and give an identity to their in-game transactions. Through added properties such as rarity, they can monetize virtual content because of their utility and scarcity.
The final word
As we can see, Solidity is so much more than just a smart contract programming language. It forms part of web3's core infrastructure at the forefront of defining the future of blockchain technology.
Web3 is well and truly changing how we interact with the internet, and the myriad use cases of Solidity smart contracts have given us a taste of what the new era of the internet could look like in the near future. There's no question that there are plenty of leaps and bounds for such a nascent, young technology, but there's also no question that the potential is there. We've only barely scratched its surface.