Blockchain For Business
On Hyperledger
Anna Derbakova
Software Engineer (IBM Blockchain)
What is blockchain?
Bitcoin
=
Two Innovations
An Economic Innovation
A topic for another day…
A Technological Innovation
How is it possible that strangers on
the internet can agree on the
accounting of over $5,000,000,000
with no central authority?
A Technological Innovation
How is it possible that strangers on
the internet can agree on the
accounting of over $5,000,000,000
with no central authority?
Answer: Blockchain
More Than Bitcoin…
“Consumers today want more
transparency about where and
how a product came to be.”
Frank Yiannas, vice president of food
safety at Walmart
[Link]
[Link]
[Link]
Blockchain
• Database
• Consensus Algorithms
• Peer-to-peer Communication
• Cryptography
Block—chain
• Hash — Fingerprint of data
699dcaa3389
af4a4a248e89
All Things Open Hash Function 9a168132277
2016! SHA-256 c28f2cee8d99
4f69815c9047
d6bcdc
Block—chain
• Block — Collection of transactions +
hash of previous block
bbf465d0c7b8
Tx_1 01a933714c4
Tx_2 Hash Function a5200f0d74af
Tx_3 SHA-256 c80492f1b4ac
… b3b48d51b94
3ef1e7
Block—chain
• Block — Collection of transactions +
hash of previous block
Tx_1 Tx_1 Tx_1
Tx_2 Tx_2 Tx_2
Tx_3 Tx_3 Tx_3
… … … …
Block—chain
• Block — Collection of transactions +
hash of previous block
Tx_1 Tx_1 Tx_1
Tx_2 Tx_2 Tx_2
Tx_3 Tx_3 Tx_3
… … … …
Blockchain
• Database
• Consensus Algorithms
• Peer-to-peer Communication
• Cryptography
The Really Hard Stuff
Consensus
Consensus
$75
Bob
$75 Which check
Chuck $75 will bounce?
$100
Dave
Alice
Blockchain
• Database
• Consensus Algorithms
• Peer-to-peer Communication
• Cryptography
Business Use Cases
Asset Transfer
• Anything that is capable of being owned or
controlled to produce value, is an asset
• Two fundamental types of assets
– Tangible, e.g. a house
– Intangible e.g. a mortgage
• Intangible assets subdivide
– Financial, e.g. bond
– Intellectual e.g. patents
– Digital e.g. music
• Cash is also an asset
Transferring An Asset
• Asset is codified within a (smart) contract
• Asset is exchanged by updating contract state
through an available action
vehicleState:
var vin
vehicleContract:
var manufacturer
createVehicle
var make
scrapVehicle
var model
updateOwner
var year
var owner
Pork Supply Chain
Hyperledger Project
Hyperledger Project
• Cross-industry collaborative effort to support
blockchain-based distributed ledgers
• Focused on ledgers designed to support global
business transactions
• Develop open protocols and standards for supporting
blockchain
• [Link]
How Is Hyperledger Different?
• Permissioned blockchain
• No miners or coins
• Provides a modular framework that supports different
components for different uses
• Other consensus schemes, like PBFT (Practical
Byzantine Fault Tolerance) may be used
Let’s Build an app!
Blockchain Application
End User Browser, mobile, etc.
HTTP Request
REST
Blockchain Application Web Application
Transaction
Chaincode (contract)
Peer Membership
Service
Blockchain Network
Chaincode
Ledger
Blockchain Network
End User Browser, mobile, etc.
HTTP Request
REST
Blockchain Application Web Application
Transaction
Chaincode (contract)
Peer Membership
Service
Blockchain Network
Chaincode
Ledger
Blockchain Network
• Docker images provided
• Single peer + membership service
• Four peers + membership service
Membership
Peer
Service
Ledger
Chaincode (Smart Contract)
End User Browser, mobile, etc.
HTTP Request
REST
Blockchain Application Web Application
Transaction
Chaincode (contract)
Peer Membership
Service
Blockchain Network
Chaincode
Ledger
Chaincode (Smart Contract)
• Implemented in Go
• Packaged together with dependencies
• Docker container running on the validating peer
Peer Init
Chaincode Invoke
Ledger
Query
Crowd Funding Chaincode
• Stores the “account” state variable
• Invoke action adds value to “account”
• Query action retrieves the value of “account”
Init accountState:
var amount
Chaincode Invoke
accountContract:
addValue
Query
Web Application
End User Browser, mobile, etc.
HTTP Request
REST
Blockchain Application Web Application
Transaction
Chaincode (contract)
Peer Membership
Service
Blockchain Network
Chaincode
Ledger
Web Application
• Implemented with [Link] (uses the “hfc” NPM module)
• Registers and enrolls users
• Deploys, invokes, and queries the chaincode
REST
Blockchain Application Web Application
Transaction
Peer Membership
Service
Blockchain Network
Chaincode
Ledger
Front End Application
End User Browser, mobile, etc.
HTTP Request
REST
Blockchain Application Web Application
Transaction
Chaincode (contract)
Peer Membership
Service
Blockchain Network
Chaincode
Ledger
Questions?
Getting Started Tutorial: [Link]
Anna Derbakova: adderbak@[Link]
[Link]
Backup
Proof of Work*
Our Simple
Bank has four
account holders
and no central
Alice Bob Chuck Dave authority. How
$100 $100 $100 $100 can we reach
Honest Honest Dishonest Honest
consensus on
our account
values?
*This simplistic example leaves out details for the purpose of explaining PoW in 5 minutes.
Proof of Work
Everyone starts
trying to solve a
very difficult (but
easily verifiable)
problem. It’s so
Alice Bob Chuck Dave
difficult, with four
$100 $100 $100 $100 people working, it
Honest Honest Dishonest Honest will only be solved
once every 10
minutes.
Proof of Work
While attempting
to solve the
problem, our
Alice Bob Chuck Dave actors also
$100 $100 $100 $100 announce
Honest Honest Dishonest Honest transactions.
Alice - send $50 to Dave
Bob - send $20 to Alice
Chuck - send $1,000 to Dave
Proof of Work
Alice solves
the problem
first. She
Alice Bob Chuck Dave announces
$100 $100 $100 $100 the solution.
Valid transactions Alice heard
Alice’s = hash solution + Alice - send $50 to Dave
block
Bob - send $20 to Alice
Proof of Work
After verifying
Alice’s solution,
everyone starts
working on a
Alice Bob Chuck Dave new problem
that includes
$70 $80 $100 $150
the hash of
Honest Honest Dishonest Honest Alice’s block.
Alice’s
block
Proof of Work
Bob finds
the next
Alice Bob Chuck Dave solution.
$70 $80 $100 $150
Honest Honest Dishonest Honest
New transactions
Alice’s Bob’s = hash (solution + )
Dave - send $10 to Bob
block block
Dave - send $20 to Alice
Proof of Work
Chuck finds the next
solution, but includes
fake transactions his
block.
Alice Bob Chuck Dave Alice, Bob, and Dave
ignore his block and
$90 $90 $100 $120 keep looking for
another solution.
Honest Honest Dishonest Honest
Alice’s Bob’s Chuck’s
block block block
Proof of Work
Chuck finds the
solution again, but
he doesn’t include
previous blocks in
Alice Bob Chuck Dave an attempt to erase
old transactions.
$90 $90 $100 $120
Again, he is
Honest Honest Dishonest Honest
ignored because
it’s not the longest
Alice’s Bob’s chain.
block block
Chuck’s
block
Proof of Work
Chuck can’t
fake a longer
chain because
solving these
problems
Alice Bob Chuck Dave requires too
$90 $90 $100 $120 much work.
Chuck gives
Honest Honest Dishonest Honest
up!
Alice’s Bob’s
block block