## Solidity Data Types

Solidity is a statically typed programming language, which means that the type of each variable needs to be specified at compile-time. Solidity provides several categories of data types, as listed below:

• Value types
• Reference types
• Mappings

### Value Types

These types of data are called value types because variables of these types will always be passed by value. There are several value types in solidity, as listed below:

• Boolean
• Integer
• Fixed Point Number
• String
• Array
• Literal
• Enum

We shall focus on boolean, integer and string data types first and discuss other data types in future articles.

### Boolean

Boolean is a data type that only produces two possible values, true or false. They can be used together with some common operators, as follows:

 Operator Meaning ! Logical negation && Logical conjunction  “and” || Logical disjunction “or’ == Equality != Inequality

We declare a Boolean variable using the keyword bool

### Integer

There are two types of integer, the signed integers, and the unsigned integers. The keyword to declare signed integers is int and the keyword to declare unsigned integers is uint. In addition, we can assign the number of bits a signed integer can hold using int8, int16 until int256. Similarly, we can use uint8 until uint256 for unsigned integers.

We declare an integer variable using the keyword int or uint

We can use various operators to deal with operations that involve integers. The operators are listed as follows:

 Comparison Operators <=  < ==  != >=  > Bit Operators &  |  ^ and   ~ Arithmetic Operators –  * /   % **  << >>

### String

The string is a data type that cannot be operated arithmetically. String literals are written with either double or single-quotes, for example, “Abraham”, “007”, “abc%&\$” and more.

We declare a string variable using the keyword string .

Example: This example The string two types of variables, unsigned integer and boolean. We also use the keyword if and the operator > to check whether the outcome is true or false.

The code

```pragma solidity ^0.4.24;

contract myContract2 {
uint private a;
uint private b;
bool ans;

function getValue1(uint num1) public{
a = num1;
}

function getValue2(uint num2) public{
b = num2;
}

function checkAns() public view returns (bool){
if (a>b)
ans=true;
else
ans=false;

return ans;
}

}

```

After we compiled and deployed the contract, we get the following output. We can test the results by entering different values in getValue1 and getValue2. The results will be either true or false.

## Introduction to Solidity

### What is Solidity?

Solidity is a high-level programming language that is used to create and implement smart contracts in Ethereum. The smart contracts created using Solidity can be used for financial transactions, crowdfunding, voting, intelligent supply chain management, improvement of  IoT workflow, ride sharing automation, smart city administration and more.

It has Python, C++ and JavaScript influences and is used for Ethereum Virtual Machine ( EVM ). As a result, it is fairly convenient and easy to grasp for those that are already familiar with the Python, C++ or JavaScript.

### The IDE for Developing Smart Contracts

The best tool to write, compile, test and deploy smart contracts is  Remix.  Remix is a browser-based IDE that provides an inbuilt compiler as a well as runtime environment without server-side components.

We can also use other code editors for Solidity. I suggest we use Visual Studio Code or Solidity Plugin for Visual Studio. For the Solidity plugin, you need to download it from https://marketplace.visualstudio.com/items?itemName=ConsenSys.Solidity
Besides that, you need to install Visual Studio 2015.

### Writing Your First Smart Contract in Solidity

A smart contract is a data, that can be referred to as its state, and code, which can be referred to as its functions, collection, that resides on a specific address in the Ethereum blockchain.

The first line of the smart contract is always

pragma solidity ^0.4.24;

pragma is a keyword which is used to instruct the compiler how the source code should be treated. In this example, the pragma specified that the source code is written for the Solidity Library version 0.4.24

To define a contract, we use the statement

```contract contractName {

}
```

You can use any name for the contract, but any meaningful name will be better. For example

```Contract  NewCoin{

}
```

indicates that you intend to create a contract for a new cryptocurrency.

### Assigning variables

Next, we would like to introduce some variables into the contract. First of all, let’s assign some string variables and some integer variables.

To assign a string variable, the syntax is

string myName;

In Solidity, there are two types of integers, the signed integer and the unsigned integer.

A signed integer means it can store positive or negative values while an unsigned integer can only store positive values.

To specify that it will be an unsigned integer, we use the keyword uint before the name of the new variable.

To assign an unsigned integer, the syntax is as follows;

uint MyAge;

### Access Modifier

You may want to add the access modifier(or visibility modifier) private or public to the variable. Most programming languages put access modifier in front of the datatype  specifier like private string name but in Solidity, we put access modifier between datatype specifier and the variable name, as follows:

```string private myName;
String public myName
uint private MyAge;
uint public  MyAge;

```

### Writing the Smart Contract Code

Now launch Remix IDE. Create your first smart contract by clicking on the little + button on the far left corner of the Remix IDE.  A new dialog will appear and you can create a new Solidity file.

After creating the new file, a new window will appear on a new tab displaying your new file. The file will also be show on the left pane of the IDE under the browser.

Now, let’s create a new contract by entering the following code into the Remix IDE.

```pragma solidity ^0.4.24;

contract myContract {
string private name;
uint private age;
}

```

The first line inside the contract itself declares a string name and an unsigned integer variable called age.

We have already created a simple smart contract though it does not do anything yet. You can compile and deploy it if you want to.

Now let’s add some functions to the smart contract

```pragma solidity ^0.4.24;

contract myContract {
string private name;
uint private age;

function setName(string newName) public{
name = newName;
}

function getName() public view returns (string){
return name;
}

function setAge(uint newAge) public{
age=newAge;
}
function getAge() public view returns (uint){
return age;
}
}

```

We create the function setName to allow the user inputs a string value. Set the modifier to public as we want to permit everyone to see it. Otherwise, when you deploy the contract you will not be able to view the function on the Remix IDE.

To return the value of name entered by a user, we create the function getName

The view keyword in public view returns is  the replacement for constant. It indicates that the function will not alter the storage state in any way.

Next, we create the function setAge by declaring  a parameter newAge as an unsigned integer. The setAge function will allow the user input an integer value when you deploy the contract.

To return the value of age entered by the user,  we create the function getAge

Now compile and deploy the Remix IDE, the output is shown in the following figure:

When you deploy the contract, a transaction is executed from your wallet address to the contract. A gas fee is charged in the process. You can view the transaction on Etherscan, as shown below:

When you click on the setName function, a transaction will also occur. You need to wait for the transaction to complete before you click on the getName function. You can see that whatever you entered in the setName box will appear on the getName box. You can do the same for the setAge and getAge functions.

## Introduction to Corda

### A Brief History

Corda is another enterprise-ready blockchain platform other than Hyperledger.  It was developed and launched by R3 in 2016. R3 is an enterprise software firm which focuses on distributed ledger technology.  It collaborates with more than 200 members and partners across multiple industries from both the private and public sectors to work on the Corda project.

Besides that, R3 has assembled a global team of over 180 professionals in 13 countries and over 2,000 technology, financial, and legal experts drawn from its global member base. (www.r3.com)

### Key Concepts of Corda

Corda is an open source blockchain project, designed for business from the start.  It allows businesses to build interoperable blockchain networks that transact in strict privacy. Similar to Ethereum, Corda also features smart contracts that facilitate direct transactions among the businesses. However, its smart contracts are written in Java and other JVM languages instead of Solidity.  Also, it enables the development and deployment of distributed apps called CorDapps.

In addition, the Corda platform implements the flow framework to manage communication and negotiation between participants in the network. The Corda network is made up of a peer-to-peer network of nodes. One of the key concepts of Corda’s is its network service known as the notary.   The notary service provides uniqueness consensus for verification of transactions. I shall discuss uniqueness consensus in future articles.

### The Corda Architecture

Although we often refer to Corda as a blockchain platform, strictly speaking, it is not a blockchain-based ecosystem. It is a kind of decentralized ledger technology network system that is not built by blocks. Instead, it looks a bit similar to the Tangle system in IOTA.

#### The Corda Network

The Corda network is an authenticated peer-to-peer network of nodes. Each node is a JVM run-time environment hosting Corda services and executing applications known as CorDapps. We can visualize the Corda network as a fully-connected graph. The nodes on the graph  can communicate with other nodes, as shown in the diagram below:

### How does Corda differ from other DLT Platforms?

The Corda platform is different from other DLT platforms because
the structure is block-less. Also, the way it propagates data is also different.  Other DLT  platforms use global broadcast and gossip networks to propagate data. However, Corda does not employ the global broadcast method. Instead, It uses point to point messaging to transmit data.

According to the Corda white paper, all communication between nodes is direct, with TLS-encrypted messages sent over the AMQP. This means that data is shared only on a need-to-know basis. (*TLS stands for Transport Layer Security.  AMQP stands for Advanced Message Queuing Protocol,  an open standard application layer protocol for message-oriented middleware)

Corda nodes discover each other via the Network Map Service. The network map service publishes the IP addresses through which every node on the network can be reached. Also, it broadcasts the identity certificates of those nodes and the services they provide. You can imagine the service as a phone book, which publishes a list of peer nodes containing some information.

#### The Doorman

Corda networks are semi-private,  which means it needs to impose a kind of gateway control before a node can join a network. This control is called doorman. Each network has a doorman service that enforces rules regarding the information that nodes must provide. These nodes need to go through the know-your-customer (KYC)process before being admitted to the network.

To join the network, a node must contact the doorman and provide the required information. If the doorman is satisfied, the node will receive a root-authority-signed TLS certificate from the network’s permissioning service. This certificate certifies the node’s identity when communicating with other participants on the network.

That’s all for now. I shall discuss more about Corda in future articles.

## Hyperledger- A Brief Introduction

### Background

In previous articles, we have learned about the bitcoin blockchain, the flagship of cryptocurrency.  Subsequently, we learned about Ethereum that features smart contracts on top of its cryptocurrency Ether. Smart contracts allow developers to create decentralized applications (dapps) on the Ethereum ecosystem.

Both bitcoin and Ethereum are amazing blockchain platforms. However,  both are facing some very challenging issues, one of them is scalability.  According to Wikipedia,  the transaction processing capacity of the bitcoin network is limited by the average block creation time of 10 minutes and the block size limit.  The transaction rate for bitcoin is between 3.3 and 7 transactions per second.

Ethereum does not fare better, its transaction rate is 15 transactions per second. Comparatively, VISA’s transaction rate is 45,000 transactions per second. Therefore, both platforms fall short in developing practical enterprise applications at the moment.

To overcome the limitations of the blockchain technologies for enterprise usage, Hyperledger was created with the vision to provide viable blockchain solutions for industries and businesses. Hyperledger is an open source effort created to advance cross-industry blockchain technologies hosted by The Linux Foundation.

### The Mission of Hyperledger

The philosophy of Hyperledger is

“Only an Open Source, collaborative software development approach can ensure the transparency, longevity, interoperability, and support required to bring blockchain technologies forward to mainstream commercial adoption.” –hyperledger.org

Indeed, the Hyperledger project has been a collaboration of players from various industries and organizations in technology, finance, banking, supply chain management, manufacturing, IoT and more. Since its inception in December 2015, it has managed to enlist many prominent members that include IBM, Intel, NEC, Cisco, J.P Morgan, AMN AMRO, ANZ Bank, Wells Fargo, Accenture, SAP and more. For the complete list, please refer to Wikipedia.

The mission of Hyperledger comprises some ambitious goals, as  illustrated in the following figure,

### The Hyperledger Greenhouse

Hyperledger itself is not a platform, but it is an umbrella body that incubates and promotes a range of business blockchain technologies. The technologies include distributed ledger frameworks, smart contract engines, client libraries, graphical interfaces, utility libraries, and sample applications. The umbrella strategy was able to accelerate innovation of DLT components by encouraging the re-use of common building blocks and components(hyperledger.org, 2018).

The Hyperlegder projects known as The Hyperledger Greenhouse consists of five projects and five tools, as shown in the figure below:

Each of the frameworks operates differently but they also allow certain interoperability among themselves. Hyperledger frameworks are generally permissioned (private)blockchains. It means that the parties need authentication and authorization to participate on the blockchain networks.

I will try to explain some of the frameworks and tools in simple language in a series of future articles. I am not an expert on Hyperledger but I have a decent understanding of the technologies via theories and practice. Recently I have enrolled in a Hyperledger course hosted by the Linux Foundation and managed to obtain a certificate of achievement. I am willing to share my knowledge with you.

### Open Source and Open Governance

The success of Hyperledger is based on the concepts of open source and open governance.  The concept of open source means that an open source software is a software that is made freely available and may be redistributed and modified. In other words, anyone has the ability to view the code, use the code, copy the code, modify the code, and, depending on the open source license, contribute back changes. (hyperledger.org, 2018)

On the other hand, open governance means that technical decisions for an open source project are made by a group of community-elected developers voted in from a pool of active participants. These decisions include things such as which features to add, how, and when to add them.  (hyperledger.org, 2018).  Hyperledger has formed a  Technical Steering Committee(TSC) to implement open governance pertaining to the Hyperledger projects. You can read about Hyperledger’s open governance by following this link

https://www.hyperledger.org/blog/2017/09/06/abcs-of-open-governance

That’s all for now. I will discuss why Hyperledger blockchain frameworks are better designed for enterprises than the public permissionless blockchains in coming articles.

Meanwhile, you may want to register for the Hyperledger Global Forum in Basel, Switzerland in December. I have registered but not sure of going yet as there is an issue with the credit card payment. By the way, there are no free tickets. It is a four days workshop with hands-on practices.