Creation and Deployment of Smart Contracts on Ethereum Blockchain

 

 

 

By

Dr. Hidaia Mahmood Alassouli

 

 

Hidaia_alassouli@hotmail.com

 

 

 

1. Overview:

 

This work explains briefly the creation and deployment Of Smart Contract on Ethereum Blockchain. The work consists from the following sections

 

 

2. Blockchain:

 

A blockchain is a digital record of transactions. The name comes from its structure, in which individual records, called blocks, are linked together in single list, called a chain. Blockchains are used for recording transactions made with cryptocurrencies, such as Bitcoin, and have many other applications.

Each transaction added to a blockchain is validated by multiple computers on the Internet. These systems, which are configured to monitor specific types of blockchain transactions, form a peer-to-peer network. They work together to ensure each transaction is valid before it is added to the blockchain. This decentralized network of computers ensures a single system cannot add invalid blocks to the chain.

When a new block is added to a blockchain, it is linked to the previous block using a cryptographic hash generated from the contents of the previous block. This ensures the chain is never broken and that each block is permanently recorded. It is also intentionally difficult to alter past transactions in blockchain since all the subsequent blocks must be altered first.

 

3. Solidity variables and types

 

 

Image

 

pragma solidity ^0.4.18;

 

contract Coursetro {

}

The very first line defines the version of solidity you're going to use.

Next, you define the contract and its name and open it up like a JavaScript class.

Image

What other types are there?

  1. bool
    This is a Boolean, which returns true or false.
  2. int / uint
    Both int and uint represent integers, or number values. The primary difference between int and uint (Unsigned Integer), is that int can hold negative numbers as values.
  3. address
    The address type represents a 20 byte value, which is meant to store an Ethereum address. Variables that are typed as address also have members, including balance and transfer.
  4. bytes1 through 32
    This is a fixed-size byte array.
  5. bytes
    A dynamically-sized byte array.
  6. string
    A dynamically signed string.
  7. mapping
    Hash tables with key types and value types. We will look at mappings more in depth later on in the course.
  8. struct
    Structs allow you to define new types. We will also cover this more in depth shortly.

pragma solidity ^0.4.18;

 

contract Coursetro {

string fName = 'Gary';

uint age = 34;

}

  1. Public
    This allows you to define functions or variables that can be called internally or through messages.
  2. Private
    Private variables and functions are only available to the current contract and not derived contracts.
  3. Internal
    Fuctions and variables that can only be accessed internally (current contract or derived).
  4. External
    Functions that can be called from other contracts and transactions. They cannot be called internally, except with "this.functionName()".