Blockchain
Deploying your first
smart contract to Azure
Ethereum blockchain
Rishabh Sharma
Net Solutions
Transactions
“Transactions are
fundamental to
world economy”
Ledger
“Different parties involved in a
transaction maintain their own
ledger for their compliance,
analytics and logging purposes”
Contracts
“I trust the broker [ 3rd party ] so I’m
willing to make the deal happen at 3%
brokerage”
Decentralization
Imagine buying a sunglasses
20 years back . . . .
Only 1 shop in the area [
centralized ]
High price
Hard to trust the quality as
there’s no way to measure
Today . . . .
Multiple websites / apps with all
time access [ decentralized ]
Competitive price with
comparison
Trust relatively high because of
huge competition / reputation
issue
Decentralization
Imagine buying a sunglasses
~10 years from now with
blockchain . . . .
Contents
Phase-1
1. Transactions
2. Ledger
3. Contracts
4. Decentralization
Phase-2
1. What is blockchain?
2. What is Ethereum?
3. Smart Contracts
4. EVM
5. Remix IDE
6. Solidity
Phase-3
1. Create Resource
2. Setup Ethereum
Consortium
Blockchain
3. Deploy network
4. Deploy smart
contract
#1
genesis
#2 #3 #4
What is Blockchain?
“A digitally distributed ledger which stores cryptographically linked blocks of data [ transactions ] in a
way which makes the data immutable , final and tamper-proof”
Block“
A digitally distributed ledger stores
transactions in a structure called blocks
of data or transactions” ,
“a block is a container / storage-unit for
storing transactions , it also contains
metadata like block-number, timestamp,
txns, nonce, hash etc”
#1110
Number: #1110
Data: {
“1110 -> 4343”: “$23”,
“2212-> 3232”: “#0010101010”
}
Timestamp
Prev hash
nonce
Hash
“A hash is a cryptographic function with
3 properties”
1. Uniqueness
2. Fixed Length
3. Irreversible
Welcome to Blockchain demo!
0xa078c6a041f57bbb8d369132164f58fb54c67fddc3179d4a5887bec48a0722b3
#1
Data: { . . . }
Time: xyz
Nonce: 1235
Prev_hash: 0x0000
Hash: 0x223a
#2
Data: { . . . }
Time: mno
Nonce: 4674
Prev_hash: 0x223a
Hash: 0x9ad3
“Hash of previous block is considered as one of the input parameters when calculating the
hash of current block making a chain of cryptographically linked blocks”
But who adds the block to the
blockchain ?
Miners and
Mining
Mining is the process of calculating a
valid hash for a given block which
satisfies all the preconditions
Mining =
Calculating the
Valid hash
Nonce is constantly updated to reach a
value where the hash signature become
valid to reflect the POW
#1, data = { . . . }, timestamp = xxx, nonce=1
Hash = 0xa453. . . . .
iteration-1
#1, data = { . . . }, timestamp = xxx, nonce=1
Hash = 0xa453. . . . .
#1, data = { . . . }, timestamp = xxx, nonce=1
Hash = 0xa453. . . . .
#1, data = { . . . }, timestamp = xxx, nonce=n
Hash = 0x0000ab89. . . . .
iteration-2
iteration-3
iteration-n
Chain
A chain of blocks is cryptographically
connected in such a way that tampering
with one of the blocks invalidates all the
blocks ahead of that block.
What is this
blocks is
tampered
with ?
D
I
S
T
R
I
B
U
T
E
D
Ethereum
Ethereum is a distributed peer to peer
network which consists of a distributed
ledger and blockchain capable of
running smart contracts.
Smart Contracts
“Digital contracts deployed on
blockchain network with the ability to
enforce terms of a contract”
A B
address A;
address B;
Contract HouseRent {
. . . . .
. . .
if ( timeToPayRent ) {
pay(A,B,45);
}
}
Why Ethereum ?
1. Ethereum network is created for
DAPPS
2. Developer tools
3. Ease of Learning
4. Support
Can I write smart
contracts on top of
Bitcoin blockchain
as well ?
EVM
Ethereum Virtual Machine is designed
around the ethereum client
specification. This is where all the
Ethereum bytecode runs.
Ethereum Bytecode
Ethereum Virtual Machine
Executed by
EVM execution involves iterating over some
bytecode, executing each opcode until execution is
complete
Opcodes
How codes execute on EVM?
The Ethereum yellow paper
defines approximately 130
opcodes.
Examples >>
● ADD: 0x01 { Addition operation }
● PUSH32: 0x7f { Place 32-byte (full word) item
on stack }
● CREATE: 0xf0 { 0xf0 CREATE Create a new
account with associated code }
Cost of
Computing
To run code on ethereum
blockchain , you’ve to pay for
each instruction that executes
Examples >>
● ADD: 0x01; 3 GAS
● PUSH32: 0x7f; 3 GAS
● CREATE: 0xf0; 32000 GAS
Gas Price
To run code on ethereum
blockchain , you’ve to pay for
each instruction that executes
During normal times:
● 40 GWEI Gas Price will almost always get you into the next
block.
● 20 GWEI will usually get you within the next few blocks.
● 2 GWEI will usually get you within the next few minutes.
The total cost of a transaction (the "TX fee") is the
Gas Limit * Gas Price.
Solidity
The programming language for DAPPS
Solidity is a high level language which
compiles to ethereum bytecode
Ethereum Bytecode
Ethereum Virtual Machine
Solidity code
Solidity
Hello World
pragma solidity ^0.4.11;
contract helloWorld {
function renderHelloWorld () returns (string) {
return 'helloWorld';
}
}
Result:
“0x0000000000000000000000000000000000000000000
0000000000000000000200000000000000000000000000
00000000000000000000000000000000000000a68656c6
c6f576f726c64000000000000000000000000000000000
00000000000”
Transaction cost: 21828 gas.
Execution cost: 556 gas.
Remix IDE
https://remix.ethereum.org
Writing a
contract
Hello World in Solidity
Compiling the
contract
A contract written in solidity compiles to
bytecode
Testing locally
“Don’t forget to select the relevant
environment when running a smart
contract locally”
Viewing output in Remix IDE
Every contract has a unique address on the
blockchain
Azure Toolset
How Azure provides a backbone if you
want to set up your ethereum network.
Creating a
Resource
How to create a resource in Azure?
Basic Settings
“Configure basic settings!”
Network size &
performance
Keep the defaults to begin with!
Ethereum
Settings
Select strong passwords for >>
1. Ethereum Account
2. Private key
Summary
A summary of what we’re about to
create is shown. Just click ok!
Accept terms &
create network
You always have to!
Deployment
submission
Once submitted for deployment ,
you can sit back and relax!
Successful
deployment
It may take several minutes for
deployment
Deployments
Go to your deployments
Credentials
Note down credentials and links for further processing
Supply chain use
case
Supply chain may prove to be a very
good use-case for application of
blockchain
The contract
code
This a highly simplified version of how a
supply chain contract may look like
Funding your
account
Metamask is a chrome extension which
allows to interact with blockchain
without downloading all of the data of
the blockchain.
Metamask is a thin client.
Sending ether
from your own
blockchain
You rule your world , you create ethers
and you own them here.
Deploying to
Azure
Use the RPC url in the REMIX IDE to
deploy to azure
Paying for the
transaction
We need to pay for the gas consumed
for every transaction which happens on
ethereum network
Quick Recap and Summary!
Transactions Ledger Contracts Decentralization
Blockchain Ethereum EVM Smart Contracts
Solidity
Azure
Ethereum Consortium BlockchainRemix
Setting up Azure Blockchain N / W Sending Funds
Writing a Smart Contract Deploying to Azure
Further
exploration!
https://remix.ethereum.org
https://metamask.io/
https://www.ethereum.org/
https://en.wikipedia.org/wiki/Blockchain
http://solidity.readthedocs.io/en/v0.4.21/
This is definitely not the end
A BIG thank you to the 2018 Global
Sponsors!
Another BIG thank you to local sponsors!
Thank You
It’s been wonderful

Blockchain