Who wants to be a millionaire? A class in creating … · Who wants to be a millionaire? A class in...
Transcript of Who wants to be a millionaire? A class in creating … · Who wants to be a millionaire? A class in...
Who wants to be a millionaire? A class in creating your own cryptocurrency
Tom Davies, Sr. Manager, DevNet Sandbox
Vallard Benincosa, Software Engineer
DEVNET-3626
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Cisco Spark
Questions? Use Cisco Spark to communicate with the speaker after the session
1. Find this session in the Cisco Live Mobile App
2. Click “Join the Discussion”
3. Install Spark or go directly to the space
4. Enter messages/questions in the space
How
cs.co/ciscolivebot#DEVNET-3626
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 4
Disclaimer!
This isn’t just an introductory session.
We’re going to rattle through the fundamentals pretty quickly…
…So we can get on to the code. We love us some code.
DEVNET-3626
• Blockchain - Technical Fundamentals
• Becoming a millionaire – Creating Your Own Currency
• Blockchain@Cisco
Agenda
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 7
What is a blockchain?
Everyone has a full copy | No one entity controls it or the transactions | Cryptographically secure - ‘trustless’
A transactional database!
Transactions –> Blocks -> Chain
DEVNET-3626
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Alice
Bitcoin Balance:
3 BTC ~ $30,0001AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt
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
DEVNET-3626 8© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Transaction is broadcast to bockchain network
Alice
Bitcoin Address: 1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt
Coffee Shop
Bitcoin Address: 1KfDuF4g5k8oTbvamp9BYzPLKrYbnpyT3m
0.00051 BTC
DEVNET-3626 9
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
1AHw1E7L2tNxj29wtEATPEMc1Mj77F22Yt TPEMc1Mj77F22YtwtEA HudeW7OoXane3zeeaeyoh3Laayei6Bi
ephahS9GeJohyej1oyeec1He5seam3Quitub1EizoMo7eebieiePohcu7mei0ohGhahsee9EePohb1bohcoa2bi2GIez
ei3sozaiThoo9tod4dahSIazahf3ixei3MaibRoutei9uchahT0juIoch2GahPetie0ahgahiex2VAiph7yohca0Ain6
uquoosh2UUu5Xah0oOhp0ahNaDie8li2vXo2taiquiekeeMa2ohK3eewicoGhe9ieooy5vo7JUyei9airAo8mufohIeg
aib3aeefe4ieXdiuF7EiLUijeiPe9eegh4ohPIog1daihAhf1lu0zgieD2zoowobaeTh4ieH9iecaiuch4Eedeavei3e
NSeihae3vShaefae9ai9uzooNIej7ohyeque9TaifseeFie3nau2EiroueeV0kiChahc7Dahszu4fee0AeiXee0TuAWa
iv5siiqu0Queieasee4XooowoSh6OohngaeH5eexahZ7ijoo3io3Hquaiqu4EfiWoo7neaseuCh1AARoh0weelavaes3
ExeePei9nEeyahp7Jve4yeBaeEeCaF2aeaXiF9feunooN0oshvaK1Cahnthohg1BoaiF4ahG6EiXi6CeinahX6oofxe6
Ti0ovxah5QuaeUo5Thei6Bea8ahshaiQuiG6Areiw5jiYPhahxoo7aiGh0chiDie0iQuaIuk1eiphKiiphe4eeeCa3ka
ereh2Jai6Xuvai1huohz6EeciahDe8oa7shohCor6Pon1roo7Ietho6AeChoa8ou6Chais6ieCe0VuoyeEer6nie3Noo
7seePGeuph2ivAis4xeivjooM5wooteeN3xooov4thaeJOodah3uuob4In1oceiL9QuebohM7Jah1deJoo1WoDun3se8
oKae7eeXahaDu9eiLzuoFi8ohiew8EsopohN3ahquphe1Xaetsu9AthieoubeeS8UAwu0zeejAhvie1lovahNgai8xae
7FieGthu4aTh7Phahkae9sifu9Niprae1Coofmohh1eeSzuNgoh3yEeGh1aj4Choh2iLuEighae2aEij3kohhEezou6E
ieisee3WooD8iuH3xphe9PaecUp4duvieNeera0kout1EipiaJoh3iet7ohd9Bophgoop5EewEechah6lWohpoh5aooT
Blocks are simply a ledger of transactions
0.00051 BTC
A block is a list of transactions that are collected by the peer 2 peer network
Alice’s Account
Coffee Shop
Account
DEVNET-3626 10
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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!
DEVNET-3626 11
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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
DEVNET-3626 12
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Block is broadcast to Bitcoin P2P network
DEVNET-3626 13
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
BlockchainBlockchain 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.
DEVNET-3626 14
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
• Bitcoin allows scripting but not Turing complete
• Ethereum adds ability to run code in blockchain
• Smart contracts create a state machine
• Large ecosystem of tools and projects
Ethereum
There’s more than just the bitcoin blockchain!
DEVNET-3626 15
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 16DEVNET-3626
How do blockchains work?Smart Contracts
Triggers
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
• 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
DEVNET-3626 17
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 18DEVNET-3626
Distributed Applications (DApps)Architecture
Application UI
Smart Contracts
(Application Logic)
Database
(Decentralised Compute / Storage)
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 19DEVNET-3626
A Note On Blockchain Types
Public Private Community
PermissionedNon-Permissioned
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Lots of
Crypto
currencies!
https://coinmarketcap.com/DEVNET-3626 22
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Let’s create our own token
The DevNet ICO!
(Initial Coin Offering)
DEVNET-3626 23
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Let’s create our own token
ICO Details
Val Tom
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 Val or Tom.
ERC20 Standard – Our Symbol: VXT *
https://theethereum.wiki/w/index.php/ERC20_Token_Standard*DEVNET-3626 24
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Tools to use to become millionairesEthereum Ecosystem
Deploying Contracts /
Buying & Sending Ether
IDEs for writing our Smart Contracts
Blockchains for testing and finally releasing our
contracts
Writing
Deploying
Platform
Contracts
DEVNET-3626 25
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Toolchains: IDE, Deployment Tool, Test Network
Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract ID
Solidity IDE Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract ID
Solidity IDE
Command
Line
UI Based
DEVNET-3626 26
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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!
DEVNET-3626 27
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Toolchain: IDE, Deployment Tool, Test Network
Solidity IDE Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract ID
DEVNET-3626 29
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Why use a blockchain test network?
Ether, used to pay for executing code, is expensive: €878 -> 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!
DEVNET-3626 32
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Toolchain: IDE, Deployment Tool, Test Network
Solidity IDE Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract ID
DEVNET-3626 34
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Contract Observability
DEVNET-3626 35
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Toolchain: IDE, Deployment Tool, Test Network
Solidity IDE Test Network
(Ethereum Based)
contract
Contract
Deployment
Inspect
Funds / Deployment
Contract ID
DevNet Coin is Live!
www.DevNetCoin.comDEVNET-3626 37
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Get Tokens - Example
• Create account with Metamask / MyEtherWallet on KOVAN network
• Copy address into https://gitter.im/kovan-testnet/faucet
Don’t be greedy
DEVNET-3626 39
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Buy DevNetCoin!
DevNetCoin Contract Address ------->
DEVNET-3626 40
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Coins / Tokens – Creating ‘Value’
Exchanges Platform Utility Coin ICO
https://www.icoalert.com/
DEVNET-3626 43
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Cisco@Blockchain
DEVNET-3626 45
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DevNet Sandboxdeveloper.cisco.com/sandbox
DEVNET-3626 47
• Blockchain - Technical Fundamentals
• Becoming a millionaire – Creating Your Own Currency
• Blockchain@Cisco
What did we cover?
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Cisco Spark
Questions? Use Cisco Spark to communicate with the speaker after the session
1. Find this session in the Cisco Live Mobile App
2. Click “Join the Discussion”
3. Install Spark or go directly to the space
4. Enter messages/questions in the space
How
cs.co/ciscolivebot#DEVNET-3626
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
• Please complete your Online Session Evaluations after each session
• Complete 4 Session Evaluations & the Overall Conference Evaluation (available from Thursday) to receive your Cisco Live T-shirt
• All surveys can be completed via the Cisco Live Mobile App or the Communication Stations
Don’t forget: Cisco Live sessions will be available for viewing on-demand after the event at www.ciscolive.com/global/on-demand-library/.
Complete Your Online Session Evaluation
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Continue Your Education
• Demos in the Cisco campus
• Walk-in Self-Paced Labs
• Tech Circle
• Meet the Engineer 1:1 meetings
• Related sessions
DEVNET-3626 51