Solidity

A “solid” choice for programmers interested in blockchain

Zach Parker
4 min readAug 6, 2019
Photo by Hitesh Choudhary on Unsplash

One of the hottest fields in technology right now is that of the blockchain. Largely popularized by its use in cryptocurrencies, such as Bitcoin and Ethereum, this technology has potential uses far exceeding just the currency sector. The concept of having a distributed, decentralized, public ledger to streamline processes, cut overhead, and minimize room for error or tampering is very attractive. As such, there are new projects trying to apply blockchain in different ways all of the time. New languages have been created to more readily and efficiently handle the development of these new blockchain-based programs that are on the rise. One of the newest and hottest languages to work with has been Solidity.

As with any good language, a good place to start in familiarizing yourself with it is the language documentation.

From https://solidity.readthedocs.io/en/v0.5.10/

There is a decent bit packed into that screenshot there, but the takeaway is that this is a high-level, object-oriented language that revolves around the efficient implementation of “smart contracts” and specifically within the Ethereum Virtual Machine (EVM), though a few other platforms have reportedly adopted it’s use as well. “Smart contracts” are a subject for another blog (or series of blogs), but at their most simple they are just blocks of code that digitally facilitate, verify, or enforce the negotiation/performance of a contract. They allow for transactions to be taken place credibly without the need for third parties, thanks to their use within a blockchain system. Cryptocurrencies can and do use “smart contracts’, but these contracts can be used for things far beyond just crypto (just like blockchain).

Solidity is based on ECMAScript syntax, which Javascript is also based off of, and this was a purposeful move. Like any new technology, the faster it is picked up and the scale of use increases, the more likely that it will stick around and develop into a robust system. Given the popularity and wide-spread use of Javascript (as well as C++ and Python which the docs also mention) the decision to model the language in this way make Solidity more user-friendly to a large amount of people, withstand the test of time more effectively, and more likely to develop more fully.

A contract in the sense of Solidity is a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain.

Above is a sample of Solidity code from their documentation that outlines a simple smart contract. While some of this may look a little crazy, some of it will hopefully look a little familiar, especially to someone who has worked with Javascript. While not necessarily useful in this simplified form, this particular code would allow you to store a single number in the EVM that is accessible by anyone without a feasible way to prevent you from doing so thanks the the infrastructure Ethereum has built. The setter method of this SimpleStorage contract (“function set( )”) can be called upon by anyone to change the value of storedData, but a record of all of the changes would be available in the history of the blockchain. Greater controls can be built in to do things like limit who has access to data, what data can be viewed publicly, and what data can be inherited by any children (oh yeah, Solidity allows for inheritance) among many other things.

As you can see in the above example, which outlines the creation and transfer of some “coins”, the code can get a little more complicated. However, it shouldn’t be terribly frightening to someone accustomed to object-oriented programming and ECMAScript syntax.

Explore the documentation to get a better understanding of what all Solidity is optimized for, but the bottom line is that this code is one of the most streamlined languages for dealing with “smart contracts”, which are becoming an increasingly popular application of blockchain technology. And while the warnings and notes on the documentation itself make it abundantly clear that this is a new and rapidly evolving language, its popularity, potential, and ease of use may make it a top choice for object-oriented developers to explore if they are interested in entering the blockchain space.

--

--