nigsdev / state-channel-app

A State Channel Application

Home Page:https://streamer-channel-nigsdev.surge.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A State Channel Application

🐌 The Ethereum blockchain has great decentralization & security properties. These properties come at a price: transaction throughput is low, and transactions can be expensive (search term: blockchain trilemma). This makes many traditional web applications infeasible on a blockchain... or does it?

🍰 A number of approaches to scaling have been developed, collectively referred to as layer-2s (L2s). Among them is the concept of payment channels, state channels, and state channel networks. This project walks through the creation of a simple state channel application, where users seeking a service lock collateral on-chain with a single transaction, interact with their service provider entirely off-chain, and finalize the interaction with a second on-chain transaction.

πŸ§‘β€πŸ€β€πŸ§‘ State channels really excel as a scaling solution in cases where a fixed set of participants want to exchange value-for-service at high frequency. The canonical example is in file sharing or media streaming: the server exchanges chunks of a file in exchange for micropayments.

πŸ§™ In this case, the service provider is a Guru who provides off-the-cuff wisdom to each client Rube through a one-way chat box. Each character of text that is delivered is expected to be compensated with a payment of 0.001 ETH.

πŸ“– Read more about state channels in the Ethereum Docs.

❗ OpenZepplin's ECDSA Library provides an easy way to verify signed messages, but for this project have written the code ourselves.

  • πŸ›£οΈ Built a Streamer.sol contract that collects ETH from numerous client addresses using a payable fundChannel() function and keeps track of balances.
  • πŸ’΅ Exchange paid services off-chain between the Streamer.sol contract owner (the Guru) and rube clients with funded channels. The Guru provides the service in exchange for signed vouchers which can later be redeemed on-chain.
  • ⏱ Created a mechanism with a timeout, so that rubes are protected from a Guru who goes offline while funds are locked on-chain (either by accident, or as a theft attempt)

About

A State Channel Application

https://streamer-channel-nigsdev.surge.sh/

License:MIT License


Languages

Language:CSS 85.1%Language:JavaScript 13.5%Language:Shell 0.6%Language:Solidity 0.3%Language:Dockerfile 0.2%Language:HTML 0.1%Language:TypeScript 0.1%Language:Less 0.1%