Solidity is incorporated with lots of applications, and each one of them is equally important. Today we will discuss the applications of solidity and how they are being used.
All the applications of the Solidity are based on contracts as I have discussed earlier that it is a contract-oriented language. Now I will discuss few applications to let you understand their usage and how they work in detail. It is not possible to address all in detail, but I will give brief information about every topic.
Solidity applications and their uses are
Real world scenario of voting comprises of various fraudulent techniques like manipulation of data, booth capturing, fake voters, and manipulation in voting machines, etc. But to solve few of these problems, we could make use of contracts in doing envoy voting so that everything will work smoothly, transparently and automatically. Given below is the code for voting.
Fig.1. Contract named as Ballot
A contract named as Ballot is defined in which two structures named as Voter and Proposal are defined. Inside these two, many integers, boolean and address are defined such as weight, vote, voteCount, delegate and voted.
One contract per ballot will be created, and the creator will have the power to serve as the Head. Head will have the authority to provide the right to vote to each address separately.
A person associated with the address can select himself, or to any other person, he wants to give his vote. In the end, a proposal with the most significant number of votes will be displayed using winningProposal() function.
Fig.2. Functions defined in Ballot Contract.
Mapping of the address is done following a proposal is made. Functions named as Ballot_, giveRightToVote, delegate are defined, and the logic is written on how these functions will work or what each task will do separately. You can go thru it and will be able to understand the simple logic of the workflow.
Fig.3. Functions winningProposal() and vote()
Function vote() check if the vote given is valid or not and calculates votecount using voteCount and winningProposal() will provide the final output showing who wins the proposal.
Crowdfunding can also be done using contracts and can solve various problems associated with it like a commission of third party, issues related to managing data, etc.
Crowdfunding doesn’t require any centralized system to manage things as smart contracts can workout far away better than non-trusted centralized systems.
Implementation of Blind Auction in solidity is straightforward on ethereum. In this, an open auction will be created in which everyone can make each other’s bid. After that, a blind auction will be designed where it will not be possible for anyone to see the bid until it ends.
Everyone involved in the bid can send bids for the bidding period. Bidders will be bound by the bidding as some money or ether will be included.
There are many other applications also which are a part of Solidity language. I would try to cover them in future blogs.
Solidity has various advantages and disadvantages and today’s blog is to discuss those merits and demerits to reach one more milestone near to the learning of solidity.
Pros of Solidity
- Solidity provides Inheritance properties in contracts including multiple level inheritance properties.
- Smart contracts provide a secure, easy and reliable medium for various sources which have involvement of two parties to do an agreement on something.
- Contracts support complex member variables in hierarchical mapping and structures.
- Multiple type-safe functions are also supported in Solidity through facilitating ABI(Application Binary Interface).
Cons of Solidity
- Once a contract is made it cannot be upgraded. We cannot add additional features to it.
- Concerning bugs, other languages have a definite edge over this because different languages have a large number of developers to resolve them.
- Arrays and Strings structure and usage are very complicated due to the unavailability of Standard Library(Every language have its library to perform functions).
- In smart contracts, it’s not an easy task to tell any language everything about the real world problems because languages work on the commands given by us.
- Data is only available only from transactions. There is no other source for the information which in terms creates a problem for the machine to work efficiently.
I have described many limitations of solidity, but the best part about this language is that these limitations can be resolved through various strategies. For example, data insufficient problem can be addressed using Oracle systems. We will discuss everything in details about how we can solve these problems in further blogs about solidity.
What is Solidity?
Solidity is a language developed to provide a platform to develop and implement smart contracts. It is a statically-typed programming and contract-oriented language developed by Ethereum(a secure decentralized transaction ledger) developers. The idea of solidity was originally proposed by Gavin Wood, who developed Ethereum in August 2014. After this, a team of Ethereum Developers led by Christian Reitwiessner developed this language.
There are various integration platforms(compiler to compile, execute and run code) available to implement Solidity and one of the most famous among them is ‘Remix’. As remix is browser-based IDE, it is easily available and accessible from anywhere. There are various other integration platforms which will be discussed in later blogs.
It acts as a tool used to generate machine level code and have a compiler which reads the high-level language and breaks it into smaller and simpler instructions to execute on EVM.
Simple Example of Solidity
There are various examples of solidity, but SimpleStorage is one of the easiest example to understand.
An Output of SimpleStorage Contract
In next blog, we will discuss the advantages and disadvantages of solidity language in detail.