Celer Network MVP: The Most Advanced State Channel Full-Stack Solution
After the initial release of our technical blog posts, we have received overwhelmingly positive responses. Lots of blockchain engineers are asking us about how and when they can build cApps to scale their blockchain application’s user base to millions.
Today, we are excited to release Celer Network’s full-stack MVP demo on Ethereum as an initial response to that question.
A Trust-free Off-chain Mobile Board Game
To demonstrate a wide range of features, we choose to showcase our first scalable off-chain mobile cApp: cGomoku, a Gomoku duel game.
Gomoku is traditionally played with Go pieces on a Go board. Players alternate turns placing a stone of their color on an empty intersection. The winner is the first player to form an unbroken chain of five stones horizontally, vertically, or diagonally. Gomoku has been played for thousands of years. — Wikipedia
Traditionally, Gomoku duel game was like this: two players meet with a trusted elder (witness) in a village, and each puts down an equal stake escrowed by the witness. Then the two players make their moves in front of the witness who can check the validity of each move. At the end of the game, this witness rewards the winner with all the stake put down by the loser.
Inspired by this thousand-year-old Gomoku duel, we re-invent the model as cGomoku on Celer Network with a few new features:
- There is no need for a trusted witness.
- You can play and bet with anyone in the world.
You may immediately ask: “Wait, these two things can be done using just an on-chain smart contract, how is this unique to Celer?”
Well, it is true that one could trivially build a smart contract that receives deposits and executes game logic for the two parties. But man, that is super expensive and dead slow because every deposit and every move on the game board requires a global consensus among 10000+ nodes. No one would want to play a $0.5-stake Gomoku while spending $150 for transaction fees and 3 hours for transaction confirmations.
Therefore, to make it actually practical and achieve mass adoption, we need to realize the above two features in a user-friendly, highly scalable and low-cost way. Celer Network is here to get that job done.
In Celer Network, end users are connected to a decentralized and trust-free network of Celer Nodes via cChannel that fulfills generalized state channel functionality. Among Celer Nodes, cRoute is used to route generalized states (e.g., conditional payments) optimally and trust-freely between end users. For users, connecting to Celer Network is like connecting to the Internet, where you can interact with Google, Facebook or whatever. Once connected to Celer Network, all cApps built on cOS will become available for users to install and use at large scale and low cost. cGomoku is such a cApp built with cOS API.
Though this is Celer Network’s first demo, we believe it showcases the most advanced full-stack off-chain operating network ever with a coherent set of features:
- Fully generalized state channel dApp logic. cOS not only supports simple off-chain payments like existing solutions but also provides API and design framework to support generalized off-chain application state transitions. When someone places stones on the game board of cGomoku, each move is happening through off-chain logic execution. Don’t worry about the security and finality, because each step is secured by on-chain verifiable generalized state proof.
- Out-of-box conditional payment. Blockchain applications are often associated with value transfer, which is the case in Gomoku duel because the winner gets the loser’s stake. The interesting thing here is to ensure that no one can cheat: the loser has to pay. cChannel enables this semantic by supporting conditional payment. Before the game starts, each player can send conditional payments to its counterparty saying “I will pay you $5 if you win”, which can be enforced to malicious counterparties. Note that the payment logic and Gomoku logic are separate smart contract objects with state dependency, so that cGomoku can share the same payment channels with all other cApps. More broadly, cOS and cChannel support generalized conditional dependency DAG with arbitrary resolution logic beyond this kind of simple logic.
- One-time-setup, long-term-use channel. Connecting to the Celer Network is similar to connecting to the Internet. You can choose one or a few access points to open cChannels and these are the only on-chain operations you ever need to do until you run out of money or encounter special events such as malicious counterparty. Just like you can use the same Internet service providers to access all sorts of Internet applications, you can use the same cChannels to access all sorts of cApps concurrently. The following three features are essential to support this ease of use.
- Multi-hop trust-free state relay via Celer Nodes. In the Celer Network, each end user only needs to connect with one or a few access points. Not only simple payments but also more complex conditional state transitions need to be relayed in a multi-hop fashion. Celer Network’s cOS provides a simple API call for the application to conduct this kind of complex multi-hop conditional state relay without worrying about the interaction with the cChannel network.
- Modular state dispute resolution. Sometimes on-chain state settle cannot be avoided. For example, one of the cGomoku players may drop off-line. In that case, we want to minimize the “blast radius” of such on-chain settlement. You wouldn’t want to close all your channels just because of an offline Gomoku opponent. cChannel’s interface is designed so that each off-chain object is compartmentalized to do just that.
- Pure Off-chain Object. Many people may believe that every off-chain application has to go through an on-chain initialization phase to set up an on-chain bond. This is an inaccurate mental model. The on-chain bond contract is only necessary for payment channel logic because the states of each payment channel (e.g., Alice deposits $X into the channel) should be verifiable by all nodes to prevent double spending, which is essentially preventing “state race conditions”. However, if we look at cGomoku, the game state is valid as long as all involving parties have signed the state, and no state race conditions can ever happen in this context. Therefore, no on-chain state or operation is ever needed for cGomoku until someone wants to dispute. We call this kind of objects Pure Off-chain Objects. But how can we properly reference a pure off-chain object if we want to dispute over this object later on the blockchain? Celer Network provides a way to construct a uniquely identifiable reference (Off-chain Address) for off-chain objects, only deploy objects on chain when necessary, and provides an Off-chain Address Translator (OAT) to establish the mapping from off-chain address to on-chain address.
- Mobile cOS native dev framework and runtime. Celer Network provides the first-ever mobile based off-chain application development framework under cOS specification. cOS lets developers concentrate on the application logic and create the best user experience, without hassling with complicated off-chain states exchange, tracking, or dispute. Whether you want to enable fast and secure transaction in an e-commerce app or add rich gamification features in a viral mobile game app, the user experience will be silky smooth, say goodbye to slow transactions and expensive transaction fees.
Enough words, let’s get to the VIDEO DEMO! 😁 😺
What does it take to build a cAPP?
“Wow, this cGomoku must be super complex to build! Do I have to learn a different language or something?” You might think.
Worry no more! Almost all the complexities are handled for you transparently by cOS. In fact, if you have an on-chain Gomoku smart contract already built, the core “off-chain” portion of the smart contract is minimally incremental. Off-chain logic is also simple to implement with simple APIs. Celer Network brings the true power of abstraction and simplifies the development of off-chain cApps to the level of on-chain decentralized apps.
We will share our project roadmap and open source timeline in a few weeks.
Can’t wait to try it? 😄 We know.
For developers who are eager to get early access, the initial alpha release of cChannel and cOS will be made available soon. More technical deep-dive blogs on how to transform your on-chain dApps to off-chain cApps are coming as well.
To stay updated, follow us via: