SlideShare a Scribd company logo
Tom Davies, Sr. Manager, Cisco DevNet,
Vallard Benincosa, Software Engineer, Cisco
Code on the Chain!
An introduction to writing smart contracts & tooling for
blockchain development
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Extended Leadership Planning Review
4/24/2018
<me>
@TomDavies_UK
</him>
@vallard
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Developer
Advocacy
“Voice of Developer”
DevNet Community, Customer Engagements,
DevNet Express, Partners, WWSE
Learn
CodeInspire
Connect
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
DevNet Data as of April 10, 2018
DevNet Community
72,500+
Learning Labs completed
490,000+
Members
33,000+
Companies
60,000
Avg. Monthly Active Users
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Learning Labs Sandbox Events
Portal &
Microsites Support Code ExchangeCo-Creations
Join us @ developer.cisco.com
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
• Blockchain Fundamentals
• Your First Contract:
• Developer Tooling & Toolchains
• Contracts & Deployments
• Observability
• You’re up! Buy some DevNetCoin!
Agenda
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Blockchain Fundamentals
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Everyone has a full copy | No one entity controls it or the transactions | Cryptographically secure - ‘trustless’
Transactions –> Blocks -> Chain
What is a blockchain?
A transactional database!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Alice
Bitcoin Balance:
3 BTC ~ $30,000
1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt
Coffee Shop
Bitcoin Address:
1KfDuF4g5k8oTbvamp9BYzPLKrYbnpyT3m
Alice has a public and
private key
A transaction to send 0.00025 bitcoins is
signed with Alice’s private key and the
coffee shop’s public key Coffee shop advertises
public key
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Alice
Bitcoin Address:
1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt
Coffee Shop
Bitcoin Address:
1KfDuF4g5k8oTbvamp9BYzPLKrYbnpyT3m
0.00051 BTC
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt TPEMc1Mj77F22YtwtEA HudeW7OoXane3zeeaeyoh3Laayei6Bi
ephahS9GeJohyej1oyeec1He5seam3Quitub1EizoMo7eebieiePohcu7mei0ohGhahsee9EePohb1bohcoa2bi2GIez
ei3sozaiThoo9tod4dahSIazahf3ixei3MaibRoutei9uchahT0juIoch2GahPetie0ahgahiex2VAiph7yohca0Ain6
uquoosh2UUu5Xah0oOhp0ahNaDie8li2vXo2taiquiekeeMa2ohK3eewicoGhe9ieooy5vo7JUyei9airAo8mufohIeg
aib3aeefe4ieXdiuF7EiLUijeiPe9eegh4ohPIog1daihAhf1lu0zgieD2zoowobaeTh4ieH9iecaiuch4Eedeavei3e
NSeihae3vShaefae9ai9uzooNIej7ohyeque9TaifseeFie3nau2EiroueeV0kiChahc7Dahszu4fee0AeiXee0TuAWa
iv5siiqu0Queieasee4XooowoSh6OohngaeH5eexahZ7ijoo3io3Hquaiqu4EfiWoo7neaseuCh1AARoh0weelavaes3
ExeePei9nEeyahp7Jve4yeBaeEeCaF2aeaXiF9feunooN0oshvaK1Cahnthohg1BoaiF4ahG6EiXi6CeinahX6oofxe6
Ti0ovxah5QuaeUo5Thei6Bea8ahshaiQuiG6Areiw5jiYPhahxoo7aiGh0chiDie0iQuaIuk1eiphKiiphe4eeeCa3ka
ereh2Jai6Xuvai1huohz6EeciahDe8oa7shohCor6Pon1roo7Ietho6AeChoa8ou6Chais6ieCe0VuoyeEer6nie3Noo
7seePGeuph2ivAis4xeivjooM5wooteeN3xooov4thaeJOodah3uuob4In1oceiL9QuebohM7Jah1deJoo1WoDun3se8
oKae7eeXahaDu9eiLzuoFi8ohiew8EsopohN3ahquphe1Xaetsu9AthieoubeeS8UAwu0zeejAhvie1lovahNgai8xae
7FieGthu4aTh7Phahkae9sifu9Niprae1Coofmohh1eeSzuNgoh3yEeGh1aj4Choh2iLuEighae2aEij3kohhEezou6E
ieisee3WooD8iuH3xphe9PaecUp4duvieNeera0kout1EipiaJoh3iet7ohd9Bophgoop5EewEechah6lWohpoh5aooT
Blocks are simply a ledger of transactions
0.00025 BTC
A block is a list of transactions that are collected by the peer 2 peer network
Alice’s
Account
Coffee Shop
Account
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
How do you stop abuse & double spend?
• Race to create the next block in
a blockchain
• New bitcoin block is created
every 10 minutes
Miners!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Proof of Work
• A Hash is a one way function
• Nearly impossible to guess
• Easy to verify
• Header Hash must be less than
a specified target value (e.g.:
begins with x amount of 0’s.)
• Nonce is only part that can
change to get value.
• Must iterate to find value
1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt TPEMc1Mj77F22YtwtEA HudeW7OoXane3zeeaeyoh3Laayei6Bi
ephahS9GeJohyej1oyeec1He5seam3Quitub1EizoMo7eebieiePohcu7mei0ohGhahsee9EePohb1bohcoa2b
i2GIezei3sozaiThoo9tod4dahSIazahf3ixei3MaibRoutei9uchahT0juIoch2GahPetie0ahgahiex2VAip
h7yohca0Ain6uquoosh2UUu5Xah0oOhp0ahNaDie8li2vXo2taiquiekeeMa2ohK3eewicoGhe9ieooy5vo7JU
yei9airAo8mufohIegaib3aeefe4ieXdiuF7EiLUijeiPe9eegh4ohPIog1daihAhf1lu0zgieD2zoowobaeTh
4ieH9iecaiuch4Eedeavei3eNSeihae3vShaefae9ai9uzooNIej7ohyeque9TaifseeFie3nau2EiroueeV0k
iChahc7Dahszu4fee0AeiXee0TuAWaiv5siiqu0Queieasee4XooowoSh6OohngaeH5eexahZ7ijoo3io3Hqua
iqu4EfiWoo7neaseuCh1AARoh0weelavaes3ExeePei9nEeyahp7Jve4yeBaeEeCaF2aeaXiF9feunooN0oshv
aK1Cahnthohg1BoaiF4ahG6EiXi6CeinahX6oofxe6Ti0ovxah5QuaeUo5Thei6Bea8ahshaiQuiG6Areiw5ji
YPhahxoo7aiGh0chiDie0iQuaIuk1eiphKiiphe4eeeCa3kaereh2Jai6Xuvai1huohz6EeciahDe8oa7shohC
or6Pon1roo7Ietho6AeChoa8ou6Chais6ieCe0VuoyeEer6nie3Noo7seePGeuph2ivAis4xeivjooM5wootee
N3xooov4thaeJOodah3uuob4In1oceiL9QuebohM7Jah1deJoo1WoDun3se8oKae7eeXahaDu9eiLzuoFi8ohi
ew8EsopohN3ahquphe1Xaetsu9AthieoubeeS8UAwu0zeejAhvie1lovahNgai8xae7FieGthu4aTh7Phahkae
9sifu9Niprae1Coofmohh1eeSzuNgoh3yEeGh1aj4Choh2iLuEighae2aEij3kohhEezou6Eieisee3WooD8iu
H3xphe9PaecUp4duvieNeera0kout1EipiaJoh3iet7ohd9Bophgoop5EewEechah6lWohpoh5aooT
Block Header ( 80 bytes )
Block Body
• 32 bytes of previous block hash
• 32 bytes of Merkle root hash
• Timestamp
• Nonce
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Block is broadcast to Bitcoin P2P network
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Block…chain
Blockchain means that each block header refers back to the previous block.
• Consensus comes by the longest block chain
• Only one winner – encourages hashing pools
• Works as long as 51% of network arrives to consensus
• Encourages compute resources to be honest
• In Bitcoin only 21 million coins will ever be created. 75% of all coins that
will ever be created have already been mined. Last coin estimated in
2140.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
• Bitcoin allows scripting but not
Turing complete
• Ethereum adds ability to run
code in blockchain
• Smart contracts create a state
machine
• Growing ecosystem of tools and
projects
Ethereum
There’s more than just the bitcoin blockchain!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
How do blockchains work?
• Smart Contracts
Triggers
Smart Contracts
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
• Stored Procedures
• Can cause massive problems! DOA lost 3.6 million ether!
• Tooling is rapidly developing
• Many platforms to run on
• How expensive is it to run on Ethereum?
• Anyone can make their own currency!
Smart Contracts
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Distributed Applications (DApps)
Architecture
Application UI
Smart Contracts
(Application Logic)
Database
(Decentralised Compute / Storage)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
A Note On Blockchain Types
Public Private Community
PermissionedNon-Permissioned
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Creating Your First Contract
Standards, Tools, Toolchains
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Let’s create our own token
The DevNet ICO!
(Initial Coin Offering)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Let’s create our own token
ICO Details
Tom Val
20 Million
5 Million 5 Million
You Guys
10 Million
1 ETH = 100 DevCoin
Does this sound like a good ICO? YES…if you’re Tom or Val.
ERC20 Standard – Our Symbol: DEV *
https://theethereum.wiki/w/index.php/ERC20_Token_Standard*
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Tools to use to become millionaires
Ethereum Ecosystem
Deploying Contracts /
Buying & Sending Ether
IDEs for writing our
Smart Contracts
Blockchains for testing
and finally releasing our
contracts
Writing
Deploying
Platform
Contracts
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Toolchains: IDE, Deployment Tool, Test Network
Solidity IDE Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract ID
UI Based
Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract ID
Text Editor
Command
Line
ATOM
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Smart Contract Language - Solidity
http://solidity.readthedocs.io/en/develop/contracts.html
The Ethereum Contract Programming Language
• Used to write Smart Contracts – Contract Orientated
• Used on other blockchains as well as Ethereum
Fun Fact: Contracts can create new contracts!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Show me a Solidity ContractERC20 Compliant, baby!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Toolchain: IDE, Deployment Tool, Test Network
Text Editor Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract IDATOM
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Why use a blockchain test
network?
Ether, used to pay for executing code, is expensive: $392 -> 1ETH
Instead:
– Chose a test network to experiment
• Kovan: https://github.com/kovan-testnet/proposal
• Rinkeby: https://gist.github.com/cryptogoth/10a98e8078cfd69f7ca892ddbdcf26bc
– Create Account / Address
• Use https://www.MyEtherWallet.com or Metamask Browser plugin
• Select correct network
– Visit Faucet addresses to get Ether in your account
• Kovan: https://gitter.im/kovan-testnet/faucet
• Rinkeby: https://faucet.rinkeby.io/
– Get funded with test ether!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Go on…Deploy the DevNetCoin Contract!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Toolchain: IDE, Deployment Tool, Test Network
Text Editor Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract IDATOM
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Contract Observability
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Let me see inside the blockchain!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Toolchain: IDE, Deployment Tool, Test Network
Text Editor Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract IDATOM
DevNet Coin is Live!
Buy here: www.DevNetCoin.com
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
I want some DevNetCoin!
Show me how to get some!
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Get DevNetCoin - Example
• Create account with Metamask / MyEtherWallet on KOVAN network
• Copy address into https://gitter.im/kovan-testnet/faucet
(Don’t be greedy)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Buy DevNetCoin!
DevNetCoin Contract Address ------->
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Continue Your Learning…
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
DevNetCoin
www.DevNetCoin.com
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
DevNet Sandbox
developer.cisco.com/sandbox
Code on the chain! An introduction in writing smart contracts and tooling for Blockchain Development - Tom Davies/Vallard Benincosa - Codemotion Amsterdam 2018

More Related Content

PDF
Learn about the Trust Over IP (ToIP) stack
PDF
TechWiseTV Workshop: Encrypted Traffic Analytics
PDF
Verifiable Credentials 101 for SSI and Decentralized Digital Identity - Tyler...
PPTX
Now you can trust the browser - Ben Gidley, Tim Charman - Codemotion Amsterda...
PPTX
Security in the IoT generation - Guy Rombaut - Codemotion Amsterdam 2017
PDF
Web Apps vs Blockchain dApps (Smart Contracts): tools, vulns and standards
PDF
Exploit Kit Cornucopia - Blackhat USA 2017
PPTX
Internet of Things Security & Privacy
Learn about the Trust Over IP (ToIP) stack
TechWiseTV Workshop: Encrypted Traffic Analytics
Verifiable Credentials 101 for SSI and Decentralized Digital Identity - Tyler...
Now you can trust the browser - Ben Gidley, Tim Charman - Codemotion Amsterda...
Security in the IoT generation - Guy Rombaut - Codemotion Amsterdam 2017
Web Apps vs Blockchain dApps (Smart Contracts): tools, vulns and standards
Exploit Kit Cornucopia - Blackhat USA 2017
Internet of Things Security & Privacy

Similar to Code on the chain! An introduction in writing smart contracts and tooling for Blockchain Development - Tom Davies/Vallard Benincosa - Codemotion Amsterdam 2018 (20)

PPTX
Cisco on Distributed Ledgers & Blockchain
PDF
Cisco connect winnipeg 2018 unlocking business value with network programma...
PDF
cisco networking automation presentation.pdf
PPTX
ACI Hands-on Lab
PPTX
1. How will the IoT help your business - cisco
PDF
Cisco ICON Speaker Series: Blockchain - Technology that is revolutionizing th...
PDF
Cisco Connect Vancouver 2017 - Cisco's Digital Network Architecture - deeper ...
PDF
eIoT-tech-intro-for-paris-hackathon
PPTX
Openstack 101
PDF
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
PDF
Cisco Connect Ottawa 2018 dev net
PDF
Internet of Everything (IoE): Driving Industry Disruption
PPTX
Ccna routing and_switching_chapter-1-2-3_mme
PPTX
Puppet for Production in WebEx - PuppetConf 2013
PDF
DEVNET-1185 Business Transformation with Enterprise IOT
PDF
Lighting IoT
PPTX
Meeting rooms are talking! are you listening?
PPTX
Considerations for Operating an OpenStack Cloud
PDF
GitHub Gone Wrong - Lessons learned from organic open source
PDF
Cisco Connect Toronto 2018 DevNet Overview
Cisco on Distributed Ledgers & Blockchain
Cisco connect winnipeg 2018 unlocking business value with network programma...
cisco networking automation presentation.pdf
ACI Hands-on Lab
1. How will the IoT help your business - cisco
Cisco ICON Speaker Series: Blockchain - Technology that is revolutionizing th...
Cisco Connect Vancouver 2017 - Cisco's Digital Network Architecture - deeper ...
eIoT-tech-intro-for-paris-hackathon
Openstack 101
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
Cisco Connect Ottawa 2018 dev net
Internet of Everything (IoE): Driving Industry Disruption
Ccna routing and_switching_chapter-1-2-3_mme
Puppet for Production in WebEx - PuppetConf 2013
DEVNET-1185 Business Transformation with Enterprise IOT
Lighting IoT
Meeting rooms are talking! are you listening?
Considerations for Operating an OpenStack Cloud
GitHub Gone Wrong - Lessons learned from organic open source
Cisco Connect Toronto 2018 DevNet Overview
Ad

More from Codemotion (20)

PDF
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
PDF
Pompili - From hero to_zero: The FatalNoise neverending story
PPTX
Pastore - Commodore 65 - La storia
PPTX
Pennisi - Essere Richard Altwasser
PPTX
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
PPTX
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
PPTX
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
PPTX
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
PDF
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
PDF
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
PDF
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
PDF
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
PDF
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
PDF
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
PPTX
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
PPTX
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
PDF
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
PDF
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
PDF
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
PDF
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Pompili - From hero to_zero: The FatalNoise neverending story
Pastore - Commodore 65 - La storia
Pennisi - Essere Richard Altwasser
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
MYSQL Presentation for SQL database connectivity
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation theory and applications.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
KodekX | Application Modernization Development
Network Security Unit 5.pdf for BCA BBA.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
sap open course for s4hana steps from ECC to s4
MYSQL Presentation for SQL database connectivity
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Approach and Philosophy of On baking technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
Programs and apps: productivity, graphics, security and other tools
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
Machine learning based COVID-19 study performance prediction
Encapsulation theory and applications.pdf
NewMind AI Weekly Chronicles - August'25 Week I
KodekX | Application Modernization Development

Code on the chain! An introduction in writing smart contracts and tooling for Blockchain Development - Tom Davies/Vallard Benincosa - Codemotion Amsterdam 2018

  • 1. Tom Davies, Sr. Manager, Cisco DevNet, Vallard Benincosa, Software Engineer, Cisco Code on the Chain! An introduction to writing smart contracts & tooling for blockchain development
  • 2. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Extended Leadership Planning Review 4/24/2018 <me> @TomDavies_UK </him> @vallard
  • 3. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Developer Advocacy “Voice of Developer” DevNet Community, Customer Engagements, DevNet Express, Partners, WWSE Learn CodeInspire Connect
  • 4. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential DevNet Data as of April 10, 2018 DevNet Community 72,500+ Learning Labs completed 490,000+ Members 33,000+ Companies 60,000 Avg. Monthly Active Users
  • 5. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Learning Labs Sandbox Events Portal & Microsites Support Code ExchangeCo-Creations Join us @ developer.cisco.com
  • 6. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential • Blockchain Fundamentals • Your First Contract: • Developer Tooling & Toolchains • Contracts & Deployments • Observability • You’re up! Buy some DevNetCoin! Agenda
  • 7. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Blockchain Fundamentals
  • 8. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Everyone has a full copy | No one entity controls it or the transactions | Cryptographically secure - ‘trustless’ Transactions –> Blocks -> Chain What is a blockchain? A transactional database!
  • 9. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Alice Bitcoin Balance: 3 BTC ~ $30,000 1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt Coffee Shop Bitcoin Address: 1KfDuF4g5k8oTbvamp9BYzPLKrYbnpyT3m Alice has a public and private key A transaction to send 0.00025 bitcoins is signed with Alice’s private key and the coffee shop’s public key Coffee shop advertises public key
  • 10. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Alice Bitcoin Address: 1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt Coffee Shop Bitcoin Address: 1KfDuF4g5k8oTbvamp9BYzPLKrYbnpyT3m 0.00051 BTC
  • 11. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt TPEMc1Mj77F22YtwtEA HudeW7OoXane3zeeaeyoh3Laayei6Bi ephahS9GeJohyej1oyeec1He5seam3Quitub1EizoMo7eebieiePohcu7mei0ohGhahsee9EePohb1bohcoa2bi2GIez ei3sozaiThoo9tod4dahSIazahf3ixei3MaibRoutei9uchahT0juIoch2GahPetie0ahgahiex2VAiph7yohca0Ain6 uquoosh2UUu5Xah0oOhp0ahNaDie8li2vXo2taiquiekeeMa2ohK3eewicoGhe9ieooy5vo7JUyei9airAo8mufohIeg aib3aeefe4ieXdiuF7EiLUijeiPe9eegh4ohPIog1daihAhf1lu0zgieD2zoowobaeTh4ieH9iecaiuch4Eedeavei3e NSeihae3vShaefae9ai9uzooNIej7ohyeque9TaifseeFie3nau2EiroueeV0kiChahc7Dahszu4fee0AeiXee0TuAWa iv5siiqu0Queieasee4XooowoSh6OohngaeH5eexahZ7ijoo3io3Hquaiqu4EfiWoo7neaseuCh1AARoh0weelavaes3 ExeePei9nEeyahp7Jve4yeBaeEeCaF2aeaXiF9feunooN0oshvaK1Cahnthohg1BoaiF4ahG6EiXi6CeinahX6oofxe6 Ti0ovxah5QuaeUo5Thei6Bea8ahshaiQuiG6Areiw5jiYPhahxoo7aiGh0chiDie0iQuaIuk1eiphKiiphe4eeeCa3ka ereh2Jai6Xuvai1huohz6EeciahDe8oa7shohCor6Pon1roo7Ietho6AeChoa8ou6Chais6ieCe0VuoyeEer6nie3Noo 7seePGeuph2ivAis4xeivjooM5wooteeN3xooov4thaeJOodah3uuob4In1oceiL9QuebohM7Jah1deJoo1WoDun3se8 oKae7eeXahaDu9eiLzuoFi8ohiew8EsopohN3ahquphe1Xaetsu9AthieoubeeS8UAwu0zeejAhvie1lovahNgai8xae 7FieGthu4aTh7Phahkae9sifu9Niprae1Coofmohh1eeSzuNgoh3yEeGh1aj4Choh2iLuEighae2aEij3kohhEezou6E ieisee3WooD8iuH3xphe9PaecUp4duvieNeera0kout1EipiaJoh3iet7ohd9Bophgoop5EewEechah6lWohpoh5aooT Blocks are simply a ledger of transactions 0.00025 BTC A block is a list of transactions that are collected by the peer 2 peer network Alice’s Account Coffee Shop Account
  • 12. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential How do you stop abuse & double spend? • Race to create the next block in a blockchain • New bitcoin block is created every 10 minutes Miners!
  • 13. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Proof of Work • A Hash is a one way function • Nearly impossible to guess • Easy to verify • Header Hash must be less than a specified target value (e.g.: begins with x amount of 0’s.) • Nonce is only part that can change to get value. • Must iterate to find value 1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt TPEMc1Mj77F22YtwtEA HudeW7OoXane3zeeaeyoh3Laayei6Bi ephahS9GeJohyej1oyeec1He5seam3Quitub1EizoMo7eebieiePohcu7mei0ohGhahsee9EePohb1bohcoa2b i2GIezei3sozaiThoo9tod4dahSIazahf3ixei3MaibRoutei9uchahT0juIoch2GahPetie0ahgahiex2VAip h7yohca0Ain6uquoosh2UUu5Xah0oOhp0ahNaDie8li2vXo2taiquiekeeMa2ohK3eewicoGhe9ieooy5vo7JU yei9airAo8mufohIegaib3aeefe4ieXdiuF7EiLUijeiPe9eegh4ohPIog1daihAhf1lu0zgieD2zoowobaeTh 4ieH9iecaiuch4Eedeavei3eNSeihae3vShaefae9ai9uzooNIej7ohyeque9TaifseeFie3nau2EiroueeV0k iChahc7Dahszu4fee0AeiXee0TuAWaiv5siiqu0Queieasee4XooowoSh6OohngaeH5eexahZ7ijoo3io3Hqua iqu4EfiWoo7neaseuCh1AARoh0weelavaes3ExeePei9nEeyahp7Jve4yeBaeEeCaF2aeaXiF9feunooN0oshv aK1Cahnthohg1BoaiF4ahG6EiXi6CeinahX6oofxe6Ti0ovxah5QuaeUo5Thei6Bea8ahshaiQuiG6Areiw5ji YPhahxoo7aiGh0chiDie0iQuaIuk1eiphKiiphe4eeeCa3kaereh2Jai6Xuvai1huohz6EeciahDe8oa7shohC or6Pon1roo7Ietho6AeChoa8ou6Chais6ieCe0VuoyeEer6nie3Noo7seePGeuph2ivAis4xeivjooM5wootee N3xooov4thaeJOodah3uuob4In1oceiL9QuebohM7Jah1deJoo1WoDun3se8oKae7eeXahaDu9eiLzuoFi8ohi ew8EsopohN3ahquphe1Xaetsu9AthieoubeeS8UAwu0zeejAhvie1lovahNgai8xae7FieGthu4aTh7Phahkae 9sifu9Niprae1Coofmohh1eeSzuNgoh3yEeGh1aj4Choh2iLuEighae2aEij3kohhEezou6Eieisee3WooD8iu H3xphe9PaecUp4duvieNeera0kout1EipiaJoh3iet7ohd9Bophgoop5EewEechah6lWohpoh5aooT Block Header ( 80 bytes ) Block Body • 32 bytes of previous block hash • 32 bytes of Merkle root hash • Timestamp • Nonce
  • 14. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Block is broadcast to Bitcoin P2P network
  • 15. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Block…chain Blockchain means that each block header refers back to the previous block. • Consensus comes by the longest block chain • Only one winner – encourages hashing pools • Works as long as 51% of network arrives to consensus • Encourages compute resources to be honest • In Bitcoin only 21 million coins will ever be created. 75% of all coins that will ever be created have already been mined. Last coin estimated in 2140.
  • 16. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential • Bitcoin allows scripting but not Turing complete • Ethereum adds ability to run code in blockchain • Smart contracts create a state machine • Growing ecosystem of tools and projects Ethereum There’s more than just the bitcoin blockchain!
  • 17. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential How do blockchains work? • Smart Contracts Triggers Smart Contracts
  • 18. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential • Stored Procedures • Can cause massive problems! DOA lost 3.6 million ether! • Tooling is rapidly developing • Many platforms to run on • How expensive is it to run on Ethereum? • Anyone can make their own currency! Smart Contracts
  • 19. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Distributed Applications (DApps) Architecture Application UI Smart Contracts (Application Logic) Database (Decentralised Compute / Storage)
  • 20. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential A Note On Blockchain Types Public Private Community PermissionedNon-Permissioned
  • 21. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Creating Your First Contract Standards, Tools, Toolchains
  • 22. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Let’s create our own token The DevNet ICO! (Initial Coin Offering)
  • 23. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Let’s create our own token ICO Details Tom Val 20 Million 5 Million 5 Million You Guys 10 Million 1 ETH = 100 DevCoin Does this sound like a good ICO? YES…if you’re Tom or Val. ERC20 Standard – Our Symbol: DEV * https://theethereum.wiki/w/index.php/ERC20_Token_Standard*
  • 24. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Tools to use to become millionaires Ethereum Ecosystem Deploying Contracts / Buying & Sending Ether IDEs for writing our Smart Contracts Blockchains for testing and finally releasing our contracts Writing Deploying Platform Contracts
  • 25. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Toolchains: IDE, Deployment Tool, Test Network Solidity IDE Test Network (Ethereum Based) contract Contract Deployment Inspect Funds / Deployment Contract ID UI Based Test Network (Ethereum Based) contract Contract Deployment Inspect Funds / Deployment Contract ID Text Editor Command Line ATOM
  • 26. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Smart Contract Language - Solidity http://solidity.readthedocs.io/en/develop/contracts.html The Ethereum Contract Programming Language • Used to write Smart Contracts – Contract Orientated • Used on other blockchains as well as Ethereum Fun Fact: Contracts can create new contracts!
  • 27. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Show me a Solidity ContractERC20 Compliant, baby!
  • 28. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Toolchain: IDE, Deployment Tool, Test Network Text Editor Test Network (Ethereum Based) contract Contract Deployment Inspect Funds / Deployment Contract IDATOM
  • 29. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Why use a blockchain test network? Ether, used to pay for executing code, is expensive: $392 -> 1ETH Instead: – Chose a test network to experiment • Kovan: https://github.com/kovan-testnet/proposal • Rinkeby: https://gist.github.com/cryptogoth/10a98e8078cfd69f7ca892ddbdcf26bc – Create Account / Address • Use https://www.MyEtherWallet.com or Metamask Browser plugin • Select correct network – Visit Faucet addresses to get Ether in your account • Kovan: https://gitter.im/kovan-testnet/faucet • Rinkeby: https://faucet.rinkeby.io/ – Get funded with test ether!
  • 30. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Go on…Deploy the DevNetCoin Contract!
  • 31. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Toolchain: IDE, Deployment Tool, Test Network Text Editor Test Network (Ethereum Based) contract Contract Deployment Inspect Funds / Deployment Contract IDATOM
  • 32. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Contract Observability
  • 33. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Let me see inside the blockchain!
  • 34. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Toolchain: IDE, Deployment Tool, Test Network Text Editor Test Network (Ethereum Based) contract Contract Deployment Inspect Funds / Deployment Contract IDATOM DevNet Coin is Live! Buy here: www.DevNetCoin.com
  • 35. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential I want some DevNetCoin! Show me how to get some!
  • 36. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Get DevNetCoin - Example • Create account with Metamask / MyEtherWallet on KOVAN network • Copy address into https://gitter.im/kovan-testnet/faucet (Don’t be greedy)
  • 37. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Buy DevNetCoin! DevNetCoin Contract Address ------->
  • 38. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Continue Your Learning…
  • 39. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential DevNetCoin www.DevNetCoin.com
  • 40. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential DevNet Sandbox developer.cisco.com/sandbox

Editor's Notes

  • #2: Tom
  • #3: Both
  • #4: Tom Infra Developer, Enterprise App Dev, App Dev, Solution Architecture
  • #5: Tom
  • #6: Tom
  • #7: Val
  • #9: Tom
  • #10: Tom
  • #11: Tom
  • #12: Tom
  • #13: Val In this peer 2 peer network an actor on the network can be what is called a miner. A miner is a participant who tries to create the next block in the blockchain. The miners are incentivized in two ways: As part of creating a block they create new tokens that they own They get commissions or a percentage of the transactions Mining on some networks can be done with commodity hardware. Monero for example I’ve managed to run on a few UCS servers. But the more famous blockchains require special hardware due to competition. One example is Bitcoin which requires special ASICs. Even GPUs aren’t good enough for Bitcoin anymore and ASICs such as the Antminer S9 have been popular. You can buy some of these on eBay or other aftermarket sites. I have an S9 that I bought with Bitcoin cash that runs and at one point was making 20 euro a day.
  • #14: Val Essentially each miner is trying to come up with the next block, but its not as easy as just putting together a bunch of transactions. They need to also do what is called ”Proof of Work”. Some blockchains have other consensus protocols such as ”Proof of Stake” but the original Bitcoin and many others are derived from “Proof of work”. Essentially, we’re trying to take all the transactions, hash them together and then come up with a hash that starts with a certain amount of zeros. This idea of a hash is a “One way function”. From algebra, you are familiar with simple functions like y = x^2. If I give you x = 2, you know y = 4. If you’re advanced enough in your algebra, if I give you a number like 144 and say that is y, you can tell me that x was 12 or -12. This is a two way function, we can simply find x if we know the value of y and the function. A one-way function is more complex in that if I give you y it is nearly impossible for you to tell me what x was. The only way you can do it is by brute force. In bitcoin we use the eliptical curve function which would take a computer thousands of years to figure out x given y. The beauty, however of a one-way function is that if I give you y and then give you x, then you can verify that x does indeed give you y in a super fast O(1) computation. In blockchain, we take a hash of the transactions, the timestamp, and the previous block and something called a nonce and run it through this one-way function each time trying to come up with some number that begins with a certain amount of zeros. The only thing we can change is the nonce, and we just brute force it until something comes up. Because this is an all or nothing game, many miners “pool” there servers together so that if one lucky miner finds the magic nonce, the miners all share the reward based on their percentage of hashing power contributed towards the search.
  • #15: Val Once the right nonce is found, the block is broadcast to the network. The other servers can validate the correctness of the block. If it checks out that block becomes the next block on the chain. Several miners may come up with a different block they think should be the next block and that is actually valid. The network holds on to both of those blocks. Then as subsequent miners mine blocks they base it on one of the previous blocks. The block with the longest history becomes the “real block” and eventual consensus is made.
  • #16: Val This eventual consensus is one of the beauties of the chain. In the original paper by Satoshi Nakamoto, the word “block chain” is not even mentioned. The word comes from the fact that each header of a new block must refer back to a previous block. This enjoys the property that altering even one transaction way back in the chain would change the entire chain and so the chain is tamper and censor resistent. In bitcoin this works and encourages would be hackers to instead contribute resources towards keeping the block fare. In bitcoin only 21 million coins will be created. After that point in 2140 miners will be incentivized only by collecting fees for including transactions in their blocks.
  • #17: Tom
  • #18: Tom
  • #19: Tom
  • #20: Tom
  • #21: Tom
  • #23: Tom
  • #24: Tom
  • #25: Tom
  • #26: Tom
  • #27: Val
  • #29: Tom
  • #30: Tom
  • #32: Tom
  • #33: Tom
  • #35: Tom
  • #37: Val
  • #38: Val
  • #40: Tom
  • #41: Tom