SlideShare a Scribd company logo
1 of 37
Download to read offline
Cosmos-SDK
Talkshop
Before we begin...
Talkshop: Talk + Workshop
(Interactive presentation)
Download the tutorial
github.com/cosmos/sdk-application-tutorial
goes in $GO_PATH/src/github.com/cosmos/
make get_tools && make get_vendor_deps && make install
Welcome!
Let’s use the Cosmos-SDK
To make a
Blockchain
Replicated State Machine
Hi, I’m Jack ✌
Replicated State Machine
What is the initial state?
What are the possible state transitions?
Is it Byzantine Fault Tolerant?
Cosmos Developer Kit
Golang toolset for building Replicated State Machines
Ruby-on-Rails for Blockchain
Focus on the Application
Proof-of-Stake 🍃 is better than Proof-of-Work ☠🔥
Tendermint for Consensus & Networking
Our Application!
Distributed Name Service
No one should be able to limit access to a public utility
Distribute the access and responsibility
● Ethereum Name Service
● Handshake
● Namecoin/Blockstack
Our Application!
● github.com/cosmos/sdk-application-tutorial
● Download the tutorial to follow along with code
● At the end I’ll spin up a node and give everyone money
● You can create and buy names from each other
The SDK is a Modular Framework
● Aggregates a collection of interoperable modules
● Each Module has its own Message/Transaction processor
● The SDK routes each message to the respective module
Modules in this Tutorial
● Auth
○ Access Control List (ACL) with Asymmetric Encryption
● Bank
○ Money Money Money
● NameService
○ Whois???
Modules NOT in this Tutorial
● Staking
○ Used for updating the set of validators
○ We use a fixed set from genesis
○ Private => Permissioned => Public
● Governance
○ Let’s Vote!
Modules are States & Messages
Modules: State
● All state goes in one store called multistore
● Contains multiple key/value stores called KVStores
● Our State
○ Accounts (auth)
○ Balances (bank)
○ Domain Names (nameservice)
Domain Names: nameStore
● Name => Value
○ What does the name resolve to (the zonefile)?
● Name => Owner
○ Who owns the name?
● Name => Price
○ How much to buy it?
Modules: Messages
● Messages Trigger State Transitions
● The Module Routes the Messages to Handlers
● The Handlers Hand them to Keepers
● The Keepers update the State
Domain Names: Messages
● MsgSetName
○ This message allows an owner to set the value of a name
● MsgBuyName
○ This message allows anyone to buy a name for some price
General Flow
● A Transaction contains a Message
● Tendermint nodes receive Transactions in Blocks
● They’re passed to the application via ABCI
○ Application Blockchain Interface
○ Socket Protocol between Tendermint and the application
● Decoded as Messages by baseapp & routed to correct Module
● Each Module has Handlers that decides what to do with them
● Each Handler calls Keepers to update the State
Let’s begin in ./app.go
● Imports
○ Log - for logs
○ Auth - for accounts and signing
○ Dbm - tendermint database
○ Codec - serialization
○ Baseapp - boilerplate
● Makes a new Type called nameservice
○ That’s our app!
Let’s begin in ./app.go
● Imports
○ Log - for logs
○ Auth - for accounts and signing
○ Dbm - tendermint database
○ Codec - serialization
○ Bam - Baseapp boilerplate
● Makes a new Type called nameservice
○ That’s our app!
Our nameservice module
● All modules go in the directory called ./x/
● Our module goes in the directory called ./x/nameservice/
● Inside ./x/nameservice/ we’ll have:
○ Handler.go
○ Keeper.go
○ Querier.go
○ Msgs.go
○ Codec.go
○ Client/ => for REST & CLI
● Keepers manage the state
○ Like reducers/redux or mutations/vuex
● Handlers call the Keepers
○ Like actions in redux/vuex
The Keeper
● nameStoreKey
○ map[name]value - like a Zonefile w traditional DNS
● ownerStoreKey
○ map[sdk_address]name - who owns what
● priceStoreKey
○ map[name]price - how much a name costs
Our Keeper has 3 New Keys
● Getters
○ ResolveName
○ HasOwner
○ GetOwner
○ GetPrice
● Setters
○ SetName
○ SetOwner
○ SetPrice
Our Keeper has Getters & Setters
Our Keeper has Getters & Setters
Msgs & Handlers
● Msgs trigger Handlers
○ Like user initiated events
● Handlers call the Keepers
○ Like actions in redux/vuex
● Keepers manage the state
○ Like reducers/redux or mutations/vuex
Msgs go in ./x/nameservice/msgs.go
Two Msg Types Needed For Our App
● MsgSetName
○ Owners can set the name
● MsgBuyName
○ Names can be bought
MsgSetName
● Set all the Interfaces
● Example: ValidateBasic
handleMsgSetName
● Goes in ./x/nameservice/handler.go
● Utilizes the Keeper we made earlier
Queriers
● Queriers : Getters
● Handlers : Setters
● Goes inside ./x/nameservice/querier.go
● Uses the Keeper to access the KVStore
Our Queriers
● Resolve
○ Accepts name returns value
● Whois
○ Accepts name returns value, price, owner
Our Queriers: Whois
Codec
● Register new msg types for serialization (not whois?)
● Amino is an extension of protobuf
● Goes in ./x/nameservice/codec.go
Building Clients!
● From the Command Line
○ Utilizes the cobra library
○ Goes in ./x/nameservice/client/cli/query.go
○ Goes in ./x/nameservice/client/cli/tx.go
● From a REST server
○ Goes in ./x/nameservice/client/rest/rest.go
● Export both from Module Client
○ Goes in ./x/nameservice/client/module_client.go
Pull it all back into app.go
● Import and Initialize all our new pieces
● AddRoute for Handlers and Queriers
● Register the Codecs
● InitChainer for initial application state
○ Takes a genesis.json file that can be generated by the CLI
○ This is where I’ll add everyone’s public key and some
balance of token for buying names $ )
Build our Binaries!
● Wrap our app with commands we can use
● Wrap our client with commands we can use
● ./cmd/nsd/main.go
○ Name Service Daemon runs our node
● ./cmd/nscli/main.go
○ Name Service CLI
One last step
● Makefile
○ Installs and builds
● Gopkg
○ keeps our versions constrained
● Build!
○ dep ensure -update -v
○ make install
Claim Your Name!
Go to talkshop.name/

More Related Content

What's hot

Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATSDeep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATSNATS
 
Distributed Ledger PowerPoint Presentation Slides
Distributed Ledger PowerPoint Presentation SlidesDistributed Ledger PowerPoint Presentation Slides
Distributed Ledger PowerPoint Presentation SlidesSlideTeam
 
Service Discovery In Kubernetes
Service Discovery In KubernetesService Discovery In Kubernetes
Service Discovery In KubernetesKnoldus Inc.
 
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare NelsonZero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare NelsonSSIMeetup
 
Smart Contracts - The Blockchain Beyond Bitcoin
Smart Contracts - The Blockchain Beyond BitcoinSmart Contracts - The Blockchain Beyond Bitcoin
Smart Contracts - The Blockchain Beyond BitcoinJim McKeeth
 
Terraform GitOps on Codefresh
Terraform GitOps on CodefreshTerraform GitOps on Codefresh
Terraform GitOps on CodefreshCodefresh
 
An Introduction to Blockchain Technology
An Introduction to Blockchain Technology An Introduction to Blockchain Technology
An Introduction to Blockchain Technology Niuversity
 
Write Smart Contract with Solidity on Ethereum
Write Smart Contract with Solidity on EthereumWrite Smart Contract with Solidity on Ethereum
Write Smart Contract with Solidity on Ethereum劉 維仁
 
The Blockchain - The Technology behind Bitcoin
The Blockchain - The Technology behind Bitcoin The Blockchain - The Technology behind Bitcoin
The Blockchain - The Technology behind Bitcoin Jérôme Kehrli
 
Container based CI/CD on GitHub Actions
Container based CI/CD on GitHub ActionsContainer based CI/CD on GitHub Actions
Container based CI/CD on GitHub ActionsCasey Lee
 
The Polygon Blockchain by the Numbers
The Polygon Blockchain by the NumbersThe Polygon Blockchain by the Numbers
The Polygon Blockchain by the NumbersJesus Rodriguez
 
Many Chains, Many Tokens, One Ecosystem
Many Chains, Many Tokens, One EcosystemMany Chains, Many Tokens, One Ecosystem
Many Chains, Many Tokens, One EcosystemTendermint Inc
 
Smart contracts using web3.js
Smart contracts using web3.jsSmart contracts using web3.js
Smart contracts using web3.jsFelix Crisan
 
블록체인 기술 적용 사례
블록체인 기술 적용 사례블록체인 기술 적용 사례
블록체인 기술 적용 사례ICON Foundation
 
Bitcoin and Blockchain Technology Explained: Not just Cryptocurrencies, Econo...
Bitcoin and Blockchain Technology Explained: Not just Cryptocurrencies, Econo...Bitcoin and Blockchain Technology Explained: Not just Cryptocurrencies, Econo...
Bitcoin and Blockchain Technology Explained: Not just Cryptocurrencies, Econo...Melanie Swan
 
Post quantum cryptography - thesis
Post quantum cryptography - thesisPost quantum cryptography - thesis
Post quantum cryptography - thesisSamy Shehata
 
Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesSreenivas Makam
 
WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?Weaveworks
 
Infrastructure & System Monitoring using Prometheus
Infrastructure & System Monitoring using PrometheusInfrastructure & System Monitoring using Prometheus
Infrastructure & System Monitoring using PrometheusMarco Pas
 

What's hot (20)

Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATSDeep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
Deep Dive into Building a Secure & Multi-tenant SaaS Solution with NATS
 
Distributed Ledger PowerPoint Presentation Slides
Distributed Ledger PowerPoint Presentation SlidesDistributed Ledger PowerPoint Presentation Slides
Distributed Ledger PowerPoint Presentation Slides
 
Service Discovery In Kubernetes
Service Discovery In KubernetesService Discovery In Kubernetes
Service Discovery In Kubernetes
 
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare NelsonZero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
 
Smart Contracts - The Blockchain Beyond Bitcoin
Smart Contracts - The Blockchain Beyond BitcoinSmart Contracts - The Blockchain Beyond Bitcoin
Smart Contracts - The Blockchain Beyond Bitcoin
 
Terraform GitOps on Codefresh
Terraform GitOps on CodefreshTerraform GitOps on Codefresh
Terraform GitOps on Codefresh
 
An Introduction to Blockchain Technology
An Introduction to Blockchain Technology An Introduction to Blockchain Technology
An Introduction to Blockchain Technology
 
Write Smart Contract with Solidity on Ethereum
Write Smart Contract with Solidity on EthereumWrite Smart Contract with Solidity on Ethereum
Write Smart Contract with Solidity on Ethereum
 
The Blockchain - The Technology behind Bitcoin
The Blockchain - The Technology behind Bitcoin The Blockchain - The Technology behind Bitcoin
The Blockchain - The Technology behind Bitcoin
 
Container based CI/CD on GitHub Actions
Container based CI/CD on GitHub ActionsContainer based CI/CD on GitHub Actions
Container based CI/CD on GitHub Actions
 
The Polygon Blockchain by the Numbers
The Polygon Blockchain by the NumbersThe Polygon Blockchain by the Numbers
The Polygon Blockchain by the Numbers
 
Many Chains, Many Tokens, One Ecosystem
Many Chains, Many Tokens, One EcosystemMany Chains, Many Tokens, One Ecosystem
Many Chains, Many Tokens, One Ecosystem
 
Smart contracts using web3.js
Smart contracts using web3.jsSmart contracts using web3.js
Smart contracts using web3.js
 
Blockchain
BlockchainBlockchain
Blockchain
 
블록체인 기술 적용 사례
블록체인 기술 적용 사례블록체인 기술 적용 사례
블록체인 기술 적용 사례
 
Bitcoin and Blockchain Technology Explained: Not just Cryptocurrencies, Econo...
Bitcoin and Blockchain Technology Explained: Not just Cryptocurrencies, Econo...Bitcoin and Blockchain Technology Explained: Not just Cryptocurrencies, Econo...
Bitcoin and Blockchain Technology Explained: Not just Cryptocurrencies, Econo...
 
Post quantum cryptography - thesis
Post quantum cryptography - thesisPost quantum cryptography - thesis
Post quantum cryptography - thesis
 
Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and Kubernetes
 
WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?
 
Infrastructure & System Monitoring using Prometheus
Infrastructure & System Monitoring using PrometheusInfrastructure & System Monitoring using Prometheus
Infrastructure & System Monitoring using Prometheus
 

Similar to Cosmos SDK Workshop: How to Build a Blockchain from Scratch

Secure Developer Access at Decisiv
Secure Developer Access at DecisivSecure Developer Access at Decisiv
Secure Developer Access at DecisivTeleport
 
Idempotency of commands in distributed systems
Idempotency of commands in distributed systemsIdempotency of commands in distributed systems
Idempotency of commands in distributed systemsMax Małecki
 
Guvnor presentation jervis liu
Guvnor presentation jervis liuGuvnor presentation jervis liu
Guvnor presentation jervis liujbossug
 
Future of Cloud Computing with Containers
Future of Cloud Computing with ContainersFuture of Cloud Computing with Containers
Future of Cloud Computing with ContainersLakmal Warusawithana
 
Crikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopCrikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopVelocidex Enterprises
 
Introduction to Jhipster
Introduction to JhipsterIntroduction to Jhipster
Introduction to JhipsterKnoldus Inc.
 
Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Velocidex Enterprises
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kuberneteskloia
 
Microservices development at scale
Microservices development at scaleMicroservices development at scale
Microservices development at scaleVishal Banthia
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAndrei Sebastian Cîmpean
 
Truemotion Adventures in Containerization
Truemotion Adventures in ContainerizationTruemotion Adventures in Containerization
Truemotion Adventures in ContainerizationRyan Hunter
 
Swarm: Native Docker Clustering
Swarm: Native Docker ClusteringSwarm: Native Docker Clustering
Swarm: Native Docker ClusteringRoyee Tager
 
WebSDK - Switching between service providers
WebSDK - Switching between service providersWebSDK - Switching between service providers
WebSDK - Switching between service providersHotstar
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and HerokuTapio Rautonen
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUPRonald Hsu
 
Heroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyHeroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyJérémy Wimsingues
 
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarDocker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarApplitools
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendVlad Fedosov
 

Similar to Cosmos SDK Workshop: How to Build a Blockchain from Scratch (20)

Secure Developer Access at Decisiv
Secure Developer Access at DecisivSecure Developer Access at Decisiv
Secure Developer Access at Decisiv
 
Chaincode Use Cases
Chaincode Use Cases Chaincode Use Cases
Chaincode Use Cases
 
Idempotency of commands in distributed systems
Idempotency of commands in distributed systemsIdempotency of commands in distributed systems
Idempotency of commands in distributed systems
 
Guvnor presentation jervis liu
Guvnor presentation jervis liuGuvnor presentation jervis liu
Guvnor presentation jervis liu
 
Future of Cloud Computing with Containers
Future of Cloud Computing with ContainersFuture of Cloud Computing with Containers
Future of Cloud Computing with Containers
 
Crikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopCrikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor Workshop
 
Introduction to Jhipster
Introduction to JhipsterIntroduction to Jhipster
Introduction to Jhipster
 
Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Microservices development at scale
Microservices development at scaleMicroservices development at scale
Microservices development at scale
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
 
Truemotion Adventures in Containerization
Truemotion Adventures in ContainerizationTruemotion Adventures in Containerization
Truemotion Adventures in Containerization
 
Swarm: Native Docker Clustering
Swarm: Native Docker ClusteringSwarm: Native Docker Clustering
Swarm: Native Docker Clustering
 
WebSDK - Switching between service providers
WebSDK - Switching between service providersWebSDK - Switching between service providers
WebSDK - Switching between service providers
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and Heroku
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP
 
Heroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyHeroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success story
 
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarDocker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
 

More from Tendermint Inc

Vision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
Vision of Rearchitecting the Blockchain Ecosystem by Chjango UnchainedVision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
Vision of Rearchitecting the Blockchain Ecosystem by Chjango UnchainedTendermint Inc
 
Open Finance & the Decentralization Movement
Open Finance & the Decentralization MovementOpen Finance & the Decentralization Movement
Open Finance & the Decentralization MovementTendermint Inc
 
Introduction to Blockchain & Building the 3rd Generation with Golang
Introduction to Blockchain & Building the 3rd Generation with GolangIntroduction to Blockchain & Building the 3rd Generation with Golang
Introduction to Blockchain & Building the 3rd Generation with GolangTendermint Inc
 
Interblockchain Communication for Blockchain Interoperability
Interblockchain Communication for Blockchain InteroperabilityInterblockchain Communication for Blockchain Interoperability
Interblockchain Communication for Blockchain InteroperabilityTendermint Inc
 
A Brief History of Distributed State
A Brief History of Distributed StateA Brief History of Distributed State
A Brief History of Distributed StateTendermint Inc
 
Code Run of the Cosmos SDK
Code Run of the Cosmos SDKCode Run of the Cosmos SDK
Code Run of the Cosmos SDKTendermint Inc
 
Intro to the Cosmos Network
Intro to the Cosmos NetworkIntro to the Cosmos Network
Intro to the Cosmos NetworkTendermint Inc
 
Four Dimensional Blockchain Scaling
Four Dimensional Blockchain ScalingFour Dimensional Blockchain Scaling
Four Dimensional Blockchain ScalingTendermint Inc
 
Cosmos Proof-of-Stake: An Introduction
Cosmos Proof-of-Stake: An IntroductionCosmos Proof-of-Stake: An Introduction
Cosmos Proof-of-Stake: An IntroductionTendermint Inc
 
Ethermint 2.0: An Ethereum Scaling Solution by Cosmos
Ethermint 2.0: An Ethereum Scaling Solution by CosmosEthermint 2.0: An Ethereum Scaling Solution by Cosmos
Ethermint 2.0: An Ethereum Scaling Solution by CosmosTendermint Inc
 

More from Tendermint Inc (10)

Vision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
Vision of Rearchitecting the Blockchain Ecosystem by Chjango UnchainedVision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
Vision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
 
Open Finance & the Decentralization Movement
Open Finance & the Decentralization MovementOpen Finance & the Decentralization Movement
Open Finance & the Decentralization Movement
 
Introduction to Blockchain & Building the 3rd Generation with Golang
Introduction to Blockchain & Building the 3rd Generation with GolangIntroduction to Blockchain & Building the 3rd Generation with Golang
Introduction to Blockchain & Building the 3rd Generation with Golang
 
Interblockchain Communication for Blockchain Interoperability
Interblockchain Communication for Blockchain InteroperabilityInterblockchain Communication for Blockchain Interoperability
Interblockchain Communication for Blockchain Interoperability
 
A Brief History of Distributed State
A Brief History of Distributed StateA Brief History of Distributed State
A Brief History of Distributed State
 
Code Run of the Cosmos SDK
Code Run of the Cosmos SDKCode Run of the Cosmos SDK
Code Run of the Cosmos SDK
 
Intro to the Cosmos Network
Intro to the Cosmos NetworkIntro to the Cosmos Network
Intro to the Cosmos Network
 
Four Dimensional Blockchain Scaling
Four Dimensional Blockchain ScalingFour Dimensional Blockchain Scaling
Four Dimensional Blockchain Scaling
 
Cosmos Proof-of-Stake: An Introduction
Cosmos Proof-of-Stake: An IntroductionCosmos Proof-of-Stake: An Introduction
Cosmos Proof-of-Stake: An Introduction
 
Ethermint 2.0: An Ethereum Scaling Solution by Cosmos
Ethermint 2.0: An Ethereum Scaling Solution by CosmosEthermint 2.0: An Ethereum Scaling Solution by Cosmos
Ethermint 2.0: An Ethereum Scaling Solution by Cosmos
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Cosmos SDK Workshop: How to Build a Blockchain from Scratch

  • 2. Before we begin... Talkshop: Talk + Workshop (Interactive presentation) Download the tutorial github.com/cosmos/sdk-application-tutorial goes in $GO_PATH/src/github.com/cosmos/ make get_tools && make get_vendor_deps && make install
  • 3. Welcome! Let’s use the Cosmos-SDK To make a Blockchain Replicated State Machine Hi, I’m Jack ✌
  • 4. Replicated State Machine What is the initial state? What are the possible state transitions? Is it Byzantine Fault Tolerant?
  • 5. Cosmos Developer Kit Golang toolset for building Replicated State Machines Ruby-on-Rails for Blockchain Focus on the Application Proof-of-Stake 🍃 is better than Proof-of-Work ☠🔥 Tendermint for Consensus & Networking
  • 6. Our Application! Distributed Name Service No one should be able to limit access to a public utility Distribute the access and responsibility ● Ethereum Name Service ● Handshake ● Namecoin/Blockstack
  • 7. Our Application! ● github.com/cosmos/sdk-application-tutorial ● Download the tutorial to follow along with code ● At the end I’ll spin up a node and give everyone money ● You can create and buy names from each other
  • 8. The SDK is a Modular Framework ● Aggregates a collection of interoperable modules ● Each Module has its own Message/Transaction processor ● The SDK routes each message to the respective module
  • 9. Modules in this Tutorial ● Auth ○ Access Control List (ACL) with Asymmetric Encryption ● Bank ○ Money Money Money ● NameService ○ Whois???
  • 10. Modules NOT in this Tutorial ● Staking ○ Used for updating the set of validators ○ We use a fixed set from genesis ○ Private => Permissioned => Public ● Governance ○ Let’s Vote!
  • 11. Modules are States & Messages
  • 12. Modules: State ● All state goes in one store called multistore ● Contains multiple key/value stores called KVStores ● Our State ○ Accounts (auth) ○ Balances (bank) ○ Domain Names (nameservice)
  • 13. Domain Names: nameStore ● Name => Value ○ What does the name resolve to (the zonefile)? ● Name => Owner ○ Who owns the name? ● Name => Price ○ How much to buy it?
  • 14. Modules: Messages ● Messages Trigger State Transitions ● The Module Routes the Messages to Handlers ● The Handlers Hand them to Keepers ● The Keepers update the State
  • 15. Domain Names: Messages ● MsgSetName ○ This message allows an owner to set the value of a name ● MsgBuyName ○ This message allows anyone to buy a name for some price
  • 16. General Flow ● A Transaction contains a Message ● Tendermint nodes receive Transactions in Blocks ● They’re passed to the application via ABCI ○ Application Blockchain Interface ○ Socket Protocol between Tendermint and the application ● Decoded as Messages by baseapp & routed to correct Module ● Each Module has Handlers that decides what to do with them ● Each Handler calls Keepers to update the State
  • 17. Let’s begin in ./app.go ● Imports ○ Log - for logs ○ Auth - for accounts and signing ○ Dbm - tendermint database ○ Codec - serialization ○ Baseapp - boilerplate ● Makes a new Type called nameservice ○ That’s our app!
  • 18. Let’s begin in ./app.go ● Imports ○ Log - for logs ○ Auth - for accounts and signing ○ Dbm - tendermint database ○ Codec - serialization ○ Bam - Baseapp boilerplate ● Makes a new Type called nameservice ○ That’s our app!
  • 19. Our nameservice module ● All modules go in the directory called ./x/ ● Our module goes in the directory called ./x/nameservice/ ● Inside ./x/nameservice/ we’ll have: ○ Handler.go ○ Keeper.go ○ Querier.go ○ Msgs.go ○ Codec.go ○ Client/ => for REST & CLI
  • 20. ● Keepers manage the state ○ Like reducers/redux or mutations/vuex ● Handlers call the Keepers ○ Like actions in redux/vuex The Keeper
  • 21. ● nameStoreKey ○ map[name]value - like a Zonefile w traditional DNS ● ownerStoreKey ○ map[sdk_address]name - who owns what ● priceStoreKey ○ map[name]price - how much a name costs Our Keeper has 3 New Keys
  • 22. ● Getters ○ ResolveName ○ HasOwner ○ GetOwner ○ GetPrice ● Setters ○ SetName ○ SetOwner ○ SetPrice Our Keeper has Getters & Setters
  • 23. Our Keeper has Getters & Setters
  • 24. Msgs & Handlers ● Msgs trigger Handlers ○ Like user initiated events ● Handlers call the Keepers ○ Like actions in redux/vuex ● Keepers manage the state ○ Like reducers/redux or mutations/vuex
  • 25. Msgs go in ./x/nameservice/msgs.go
  • 26. Two Msg Types Needed For Our App ● MsgSetName ○ Owners can set the name ● MsgBuyName ○ Names can be bought
  • 27. MsgSetName ● Set all the Interfaces ● Example: ValidateBasic
  • 28. handleMsgSetName ● Goes in ./x/nameservice/handler.go ● Utilizes the Keeper we made earlier
  • 29. Queriers ● Queriers : Getters ● Handlers : Setters ● Goes inside ./x/nameservice/querier.go ● Uses the Keeper to access the KVStore
  • 30. Our Queriers ● Resolve ○ Accepts name returns value ● Whois ○ Accepts name returns value, price, owner
  • 32. Codec ● Register new msg types for serialization (not whois?) ● Amino is an extension of protobuf ● Goes in ./x/nameservice/codec.go
  • 33. Building Clients! ● From the Command Line ○ Utilizes the cobra library ○ Goes in ./x/nameservice/client/cli/query.go ○ Goes in ./x/nameservice/client/cli/tx.go ● From a REST server ○ Goes in ./x/nameservice/client/rest/rest.go ● Export both from Module Client ○ Goes in ./x/nameservice/client/module_client.go
  • 34. Pull it all back into app.go ● Import and Initialize all our new pieces ● AddRoute for Handlers and Queriers ● Register the Codecs ● InitChainer for initial application state ○ Takes a genesis.json file that can be generated by the CLI ○ This is where I’ll add everyone’s public key and some balance of token for buying names $ )
  • 35. Build our Binaries! ● Wrap our app with commands we can use ● Wrap our client with commands we can use ● ./cmd/nsd/main.go ○ Name Service Daemon runs our node ● ./cmd/nscli/main.go ○ Name Service CLI
  • 36. One last step ● Makefile ○ Installs and builds ● Gopkg ○ keeps our versions constrained ● Build! ○ dep ensure -update -v ○ make install
  • 37. Claim Your Name! Go to talkshop.name/