Building dApp on Cosmos SDK, Tendermint

in #blockchain6 years ago (edited)

Many Chains, Many Coins, One Ecosystem

image.png

  • Cosmos - Internet of Blockchains
  • CosmosHub - Internet Service Provider (ISP)
  • Tendermint - Blockchain Consensus
  • ABCI - TCP/IP

Simplified Architecture of blockchain including Bitcoin

image.png

  • The network protocol is how nodes in the network tell each other about new transactions, blocks, and other nodes; usually a p2p gossip network.
  • The consensus protocol is the set of rules that nodes should follow to determine which particular ordered set of transformations should be in the ledger at a given moment. In Bitcoin, the chain with the highest difficulty seen by a node is treated as authoritatively correct.
  • The transaction protocol describes what makes transactions valid, and how they should mutate the blockchain's state.

Extended Architecture - Ethereum

image.png

  • Focus only on Application (EVM) as a state machine
  • Not able to change any deeper level of stacks
  • Poor performance - scalability issue

Can Tendermint Core resolve those issues?

image.png

  • Proof of Stake (PoS) BFT Consensus algorithm is faster (1-3 sec) than Bitcoin’s synchronous consensus (>10 mins)
  • Interoperable for both Public & Private Chains
  • Instant Finality
  • Highly Scalable
  • Guarantees safety in asynchronous & liveness in weakly synchronous environments
  • Basis for other PoW systems like Casper

Cosmos Ecosystem

image.png

OK, now what?

Let’s build something on this cool ecosystem.

Lotion

Lotion is a new way to create blockchain apps in JavaScript, which aims to make writing new blockchains fast and fun. It builds on top of Tendermint using the ABCI protocol. Lotion lets you write secure, scalable applications that can easily interoperate with other blockchains on the Cosmos Network using IBC.

Github https://github.com/keppel/lotion

When you're writing a Lotion app, you're only responsible for writing the transaction protocol. Under the hood, Tendermint is handling the consensus and network protocols. When you start your lotion app, a Tendermint node is also started which will handle all of the communication with other nodes running your lotion app.

  1. $ npm install lotion
  2. Create a javascript file called my-lotion-app.js and run it by
  3. $ node my-lotion-app.js

code for my-lotion-app.js

let app = require('lotion')({
  initialState: { count: 0 }
})

app.use((state, tx) => {
  state.count++
})

app.listen(3000)

How to test it? By using curl

$ curl http://localhost:3000/state

{"count":0}

$ curl http://localhost:3000/txs -d '{}'

{"result":{"check_tx":{"code":0,"data":"","log":"","gas":"0","fee":"0"},"deliver_tx":{"code":0,"data":"","log":"","tags":[]},"hash":"60A4191756CDAE902D6DF6341F0E31458DB856BB","height":105}}

$ curl http://localhost:3000/state

{"count":1}

You can make a working blockchain app with javascript and really easy!

For more information about Cosmos:

Sort:  

Great post! I'm just wondering, may I use the image from the top of the page for a video presentation?

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 62904.98
ETH 3359.08
USDT 1.00
SBD 2.46