All Projects → nomic-io → Lotion

nomic-io / Lotion

✨ Smooth, easy blockchain apps ✨

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Lotion

Chainkit
ChainKit is a toolkit for blockchain development. It includes primitives for creating, building and running decentralized applications.
Stars: ✭ 121 (-86.28%)
Mutual labels:  blockchain, tendermint
Starport
The easiest way to build a blockchain.
Stars: ✭ 204 (-76.87%)
Mutual labels:  blockchain, tendermint
Tendermint code analysis
通用区块链平台tendermint源码分析
Stars: ✭ 134 (-84.81%)
Mutual labels:  blockchain, tendermint
Weave
Easy-to-use SDK to build Tendermint ABCI applications
Stars: ✭ 1,122 (+27.21%)
Mutual labels:  blockchain, tendermint
Ethermint Archive
Ethereum on Tendermint using Cosmos-SDK!
Stars: ✭ 667 (-24.38%)
Mutual labels:  blockchain, tendermint
Cosmosjs
⭐️ CosmosJS - Cosmos JavaScript Library
Stars: ✭ 91 (-89.68%)
Mutual labels:  blockchain, tendermint
Mint
Mint Blockchain — Build blockchain powered social apps
Stars: ✭ 148 (-83.22%)
Mutual labels:  blockchain, tendermint
Dawn
global hosting, financial automation, server-less web components
Stars: ✭ 40 (-95.46%)
Mutual labels:  blockchain, tendermint
Go Cyber
Your 🔵 Superintelligence
Stars: ✭ 270 (-69.39%)
Mutual labels:  blockchain, tendermint
Akash
a secure, transparent, and peer-to-peer cloud computing network
Stars: ✭ 229 (-74.04%)
Mutual labels:  blockchain, tendermint
Jabci
Java implementation of the Tendermint ABCI
Stars: ✭ 48 (-94.56%)
Mutual labels:  blockchain, tendermint
Etgate
Ethereum-Tendermint token sending gateway
Stars: ✭ 23 (-97.39%)
Mutual labels:  blockchain, tendermint
Py Abci
Python based ABCI Server for Tendermint
Stars: ✭ 48 (-94.56%)
Mutual labels:  blockchain, tendermint
Rust Abci
A rust implementation of the ABCI protocol for tendermint core
Stars: ✭ 115 (-86.96%)
Mutual labels:  blockchain, tendermint
Clearchain
Cosmos app for clearing and settlements
Stars: ✭ 42 (-95.24%)
Mutual labels:  blockchain, tendermint
Secretnetwork
𝕊 The Secret Network
Stars: ✭ 138 (-84.35%)
Mutual labels:  blockchain, tendermint
Ethermint
Ethermint is a scalable and interoperable Ethereum, built on Proof-of-Stake with fast-finality using the Cosmos SDK.
Stars: ✭ 207 (-76.53%)
Mutual labels:  blockchain, tendermint
Abci Host
Clojure host/server for Tendermint's ABCI protocol.
Stars: ✭ 18 (-97.96%)
Mutual labels:  blockchain, tendermint
Cosmos
Internet of Blockchains ⚛
Stars: ✭ 938 (+6.35%)
Mutual labels:  blockchain, tendermint
Multy Back
Back-end of the Multy - mobile multy-blockchain wallet.
Stars: ✭ 26 (-97.05%)
Mutual labels:  blockchain


Lotion
✨ Lotion ✨

Smooth, easy blockchain apps. Powered by Tendermint consensus.

Travis Build NPM Downloads NPM Version chat on slack test coverage


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.

Lotion itself is a tiny framework; its true power comes from the network of small, focused modules built upon it. Adding a fully-featured cryptocurrency to your blockchain, for example, takes only a few lines of code.

Note: the security of this code has not yet been evaluated. If you expect your app to secure real value, please use Cosmos SDK instead.

Installation

Lotion requires node v7.6.0 or higher, and a mac or linux machine.

$ npm install lotion

Usage

app.js:

let lotion = require('lotion')

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

app.use(function(state, tx) {
  if (state.count === tx.nonce) {
    state.count++
  }
})

app.start()

Introduction

Lotion lets you build blockchains. At any moment in time, the whole state of your blockchain is represented by a single JavaScript object called the state.

Users will create transactions: JavaScript objects that tell the application how to mutate the blockchain's state.

Every user who runs your Lotion app will interact with the same blockchain. Anyone can create a transaction, and it will automagically find its way to everyone else running the app and mutate their state. Everyone's state objects will constantly be kept in sync with each other.

A Lotion application is often a single function of signature (state, tx) which mutates your blockchain's state in response to a transaction tx. Both are just objects.

This cosmic wizardry is made possible by a magic piece of software named Tendermint which exists specifically for synchronizing state machines across networks.

Blockchains and Tendermint

The goal of a blockchain is to represent a single state being concurrently edited. In order to avoid conflicts between concurrent edits, it represents the state as a ledger: a series of transformations (transactions) applied to an initial state. The blockchain must allow all connected nodes to agree about which transformations are valid, and their ordering within the ledger.

To accomplish this, a blockchain is composed of three protocols: the network protocol, consensus protocol, and transaction protocol.

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.

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.

Modules

name description
coins fully-featured cryptocurrency middleware
htlc hashed timelock contracts on coins
shea on-chain client code management
merk merkle AVL trees in javascript

Contributors

Lotion is a cosmic journey for the mind brought to you by:

🤔 ⚠️ 🤔 🔌 🎨 📝
Jackson Roberts

💻
💡 📹 🎨
📝 📋 💡
Lola Dam

🐛 💻

Djenad Razic

💻

Admir Sabanovic

💻
💬 🤔
Props.love

💻
🎨 💡 🤔

Contributions of any kind welcome!

API

let app = require('lotion')(opts)

Create a new Lotion app.

Here are the available options for opts which you can override:

{
  initialState: {},            // initial blockchain state
  keyPath: 'keys.json',        // path to keys.json. generates own keys if not specified.
  genesisPath: 'genesis.json', // path to genesis.json. generates new one if not specified.
  peers: [],                   // array of '<host>:<p2pport>' of initial tendermint nodes to connect to. does automatic peer discovery if not specified.
  logTendermint: false,        // if true, shows all output from the underlying tendermint process
  p2pPort: 26658,              // port to use for tendermint peer connections
  rpcPort: 26657               // port to use for tendermint rpc
}

app.use(function(state, tx, chainInfo) { ... })

Register a transaction handler. Given a state and tx object, mutate state accordingly.

Transaction handlers will be called for every transaction, in the same order you passed them to app.use().

Transaction handlers must be deterministic: for a given set of state/tx/chainInfo inputs, you must mutate state in the same way.

chainInfo is an object like:

{
  time: 1541415248, // timestamp of the latest block. (unix seconds)
  validators: {
    '<base64-encoded pubkey>' : 20, // voting power distribution for validators. requires understanding tendermint.
    '<other pubkey>': 147 // it's ok if you're not sure what this means, this is usually hidden from you.
  }
}

If you'd like to change how much voting power a validator should have, simply mutate chainInfo.validators[pubKey] at any point!

app.useBlock(function(state, chainInfo) { ... })

Add middleware to be called once per block, even if there haven't been any transactions. Should mutate state, see above to read more about chainInfo.

Most things that you'd use a block handler for can and should be done as transactions.

app.start()

Starts your app.

Global Chain Identifiers and Light Clients

Lotion apps each have a unique global chain identifier (GCI). You can light client verify any running Lotion app from any computer in the world as long as you know its GCI.

let { connect } = require('lotion')
let GCI = '6c94c1f9d653cf7e124b3ec57ded2589223a96416921199bbf3ef3ca610ffceb'

let { state, send } = await connect(GCI)

let count = await state.count
console.log(count) // 0

let result = await send({ nonce: 0 })
console.log(result) // { height: 42, ok: true }

count = await state.count
console.log(count) // 1

Under the hood, the GCI is used to discover and torrent the app's genesis.json.

It's also used as the rendezvous point with peers on the bittorrent dht and through multicast DNS to find a full node light client verify.

You can get the GCI of an app being run by a full node like this:

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

let { GCI } = await app.start()
console.log(GCI) // '6c94c1f9d653cf7e124b3ec57ded2589223a96416921199bbf3ef3ca610ffceb'

Links

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].