Intro to Blockchain Development with Solidity
As cryptocurrencies such as Bitcoin and Ethereum have skyrocketed in value in recent months, I wanted to know more about the technology behind blockchain. Interestingly, as I researched more, I found that there are actually a myriad of ways in which web development can be used with blockchain to create powerful, decentralized applications.
In fact, the implications of blockchain technology go way beyond the simple buying and selling of digital currency. Blockchain technology, in conjunction with web development, can be used to monitor supply chains, store complex data, create reliable digital IDs, establish a safe digital voting system, among many others.

The possibilities are endless, and I would contend that any web developer would do well to gain at least a cursory understanding of how to interact with blockchain using objected-oriented programming languages. Indeed, while the demand for blockchain engineers has increased gradually over the last five years, it increased by more than 517% within the last 12 months alone according to the reports from several job sites.
Luckily, if you already have some familiarity with objected-oriented programming, learning blockchain development is not prohibitively difficult. With a little practice, you can fairly easily learn the basics, and start building your very own decentralized apps!
What are decentralized applications?
Decentralized applications (dApps) are digital applications or programs that exist and run on a blockchain or P2P network of computers instead of a single computer, and are outside the purview and control of a single authority.
A standard web app, such as Uber or Twitter, runs on a computer system which is owned and operated by an organization, giving it full authority over the app and its workings. There may be multiple users on one side, but the backend is controlled by a single organization.
DApps can run on a P2P network or a blockchain network. For example, BitTorrent, Tor and Popcorn Time are applications that run on computers that are part of a P2P network, whereby multiple participants are consuming content, feeding or seeding content, or simultaneously performing both functions.
In the context of cryptocurrencies, dApps run on a blockchain network in a public, open source, decentralized environment and are free from control and interference by any single authority.
For example, a developer can create a Twitter-like dApp and put it on a blockchain where any user can publish messages. Once posted, no one — including the app creators — can delete the messages.
Solidity
In this article, I’ll be discussing one the most common development environments for blockchain coding. Solidity is an object-oriented, high-level language for implementing smart contracts, used on the Ethereum blockchain network. Smart contracts are programs which govern the behavior of accounts within the ethereum state. To write in solidity, you can download the solidity compiler easily via npm or docker. You can also use an in-browser solidity IDE called Remix, which allows you to quickly create small contracts and actually deploy them to a local, fake ethereum network.
Below is a basic implementation of a solidity smart contract.

A smart contract is a collection of code and data that resides at a specific address on the Ethereum blockchain. The line uint storedData;
declares a state variable called storedData
of type uint
(unsigned integer of 256 bits). You can think of it as a single slot in a database that you can query and alter by calling functions of the code that manages the database. In this example, the contract defines the functions set
and get
that can be used to modify or retrieve the value of the variable.
In the get
function, the keyword public allows this function to be externally available and can interact with other smart contracts. Additionally, the view keyword signifies that this function will return some data but not modify the contract in any way. Below is a list of a few of the most common function types used in Solidity programming.

As a whole, the simple contract we built does not do much apart from allowing anyone to store a single number that is accessible by anyone in the world without a way to prevent you from publishing this number. Anyone could call set
again with a different value and overwrite your number, but the number is still stored in the history of the blockchain.
The code below is an implementation of the simplest form of cryptocurrency. The smart contract defines a Coin with multiple functions, each corresponding to different features of the currency.
The line address public minter
declares a state variable of type address. The address
type is a 160-bit value that does not allow any arithmetic operations. It is suitable for storing addresses of contracts, or a hash of the public half of a keypair belonging to external accounts. This address is necessary for the currency to be uploaded to the ethereum network.

The Coin contract also includes a constructor function, which initializes the contract upon creation, as well as mint and send functions. The mint function is responsible for creating new coins, whereas the send function allows the contract to create a transaction of coins between to account holders.
The nitty gritty details of exactly how this contract operates under the hood are beyond the scope of this article. However, hopefully this brief overview of Solidity has shown you that getting started with blockchain development is actually fairly easy. Achieving a basic understanding of the code powering blockchain applications unlocks different options for web developers, provides new kinds of functionality, and provides stronger security.
In future articles, I’ll do a deeper dive into the world of Solidity, and provide more tutorials on how to turn your smart contracts into a full-blown web application.
Happy Coding!
Sources: