Wednesday, 25 July, 2018 UTC

Summary

Solidity, a smart contracts programming language, has been a buzzword for quite some time now. This tutorial is meant for beginners ready to explore Solidity and code smart contracts. Before we begin, we'll get the basics clear. We will begin by exploring smart contracts and their effectiveness, gradually moving on to Solidity itself. Let's get started!

What You’ll Learn

By the end of this tutorial, you’ll learn;

The basics of smart contracts

The basics of Solidity

Basic coding in Solidity

The Applications of Solidity

What Are Smart Contracts?

The term smart contracts has created a lot of hype, and it still remains in the spotlight right next to terms like artificial intelligence, blockchain, Machine Learning, and so on. Smart contracts, or crypto-contracts, are nothing but self-executing computer programs that enable digital transactions, business, currency exchanges, asset transfers, and more according to a predefined set of conditions called a smart contract protocol. Smart contracts not only ensure that both the parties are following the rules and conditions of the contract, but also enforce the contract obligations automatically.

How do smart contracts function?

Smart contracts function over a given blockchain network. A smart contract takes the information as an input, assigns a value to that input according to the coded contract rules and conditions, then executes those actions according to the clauses. For example, during an ICO, a smart contract may decide whether the cryptocoin will go to the buyer or the token generator.

All smart contracts run atop a blockchain layer, where all the data is stored with Proof of Work or Proof of Stake algorithms.

The execution of transactions related to trading, financial derivatives, and simple asset exchange and transfers.

Smart contracts hold potential to disrupt industries which call for expertise and repetitive processes — for example, legal procedures. They also possess a potential for real-time auditing operations (which take many working hours if done manually!) and risk assessment, thereby enforcing compliance with the set norms.

Can smart contracts do anything?

The proposition offered by this unique blockchain tool is tempting. Theoretically, smart contracts can be used to solve complex issues of trust, transparency, and execution between the contract parties while ensuring compliance and risk management. However, the majority of smart contract applications are just theoretical. There are projects currently under development that are exploring uses for smart contracts, but the truth is we have found limited current practical applications.

Smart contracts may not be able to do everything they promise theoretically, at least currently. Here are the primary reasons;

Smart contracts are not actually ‘smart’. Smart coded contracts are not inherently smart or intelligent. They are called ‘smart’ because of the automation and condition enforcement that is coded into them, and because there is no need for a third-party intervention. But in reality, they cannot judge circumstances and play by the ‘code is law’ principle. While this can be useful, it can be harmful as well. For example, conditions cannot be changed or tampered with in the contract, even if both the parties mutually agree to a condition outside the agreement. Smart contracts just execute mutually agreed-upon conditions and follow the code in any state.

Creating smart contracts is highly complicated and tedious. Another reason why practical applications for smart contracts are scarce is the sophisticated engineering involved in coding them. Smart contracts are supposed to be Turing complete, i.e. the smart contract can simulate any Turing machine. For that, it has to be highly complicated, which in turns makes them difficult to analyze. The catch is security. If a smart contract has bugs, it can be breached and there is no point in using it. Analyzing a Turing-complete smart contract becomes a herculean task. Even ordinary contracts take years of expertise and consistent builds and fixes to meet user requirements.

What is Solidity?

Solidity is a rather simple language deliberately created for a simplistic approach to tackle real world solutions. Gavin Wood initially proposed it in the August of 2014. Several developers of the Ethereum chain such as Christian Reitwiessner, Alex Beregszaszi, Liana Husikyan, Yoichi Hirai and many more contributed to creating the language. The Solidity language can be executed on the Ethereum platform, that is a primary Virtual Machine implementing the blockchain network to develop decentralized public ledgers to create smart contract systems.

The language has the same functionalities as C and JavaScript. Additionally, the language supports state variables (similar to objects in Object Oriented Programming), data types, and programming functions. However, the language faces consistent upgrades and rapid changes throughout the platform. Hence as a programmer, you need to pay attention to the updates through Ethereum platform forums, blogs, and chat rooms.

Both Solidity and Ethereum are under proactive development.

How do I learn Solidity?

The syntactical symmetry of Solidity with ECMAScript (JavaScript) has considerably enhanced the usability of the system. The Ethereum design documentation brings out the stack and memory model with a 32-byte instruction word size. This Ethereum Virtual Machine creates the program stack that keeps track of program counter and data storage registers. The program counter loops or jumps to maintain a sequential flow to control the program.

The post Solidity for Beginners: A Guide to Getting Started appeared first on SitePoint.