Connext P2P Micropayment Integration Overview
The goal of this doc is to outline an integration of Connext into a p2p network/platform that relies on conditional micropayments.
What is Connext?
Connext is a transaction batching infrastructure layer that sits on top of Ethereum and other EVM-based blockchains. With Connext, users of a p2p network can instantly and cheaply transfer value between to peers using any currency. It’s important to note that Connext does this without giving up the core properties of blockchains, namely that user’s funds are self-custodied and cannot be double spent. Connext is built using the Counterfactual/framework - a growing standard for this type of technology.
How does it work?
At it’s core, Connext uses a concept called a state channel. Say, for instance, that Alice wants to send $100 to a Connext node (Bob) as $1 payments every minute using a blockchain. It would be very expensive and have very poor UX for Alice to make each $1 onchain. Instead, Alice can lock up all $100 in a multisignature wallet and simply send signed state updates decrementing her balance by $1 each time. If, at any point, Alice or Bob want to stop making payments, they can stop sending messages back and forth and withdraw their remaining funds.
Connext extends this concept in two ways. First, state updates within the channel can be generalized to allow transfers to resolve based on any arbitrary condition that can be resolved onchain (e.g. metered payments based on block number, boolean transfers based on an oracle, etc.).
Second, projects using Connext can run a Connext node, a trust-minimized daemon and liquidity service provider that allows many channels to be linked together into a network. This means users that deposit into state channel wallets with the node can instantly and securely transact with any other users connected to the same node.
The entirety of Connext’s code is available as a monorepo .
A live implementation of Connext can be found The code for this is available as , and you can play with/test using this demo yourself by opening http://localhost:3000 after running indra locally.
You can also see Connext in action in Metamask Mobile here:
Integrating Connext consists of:
- Running a Connext node.
- Integrating the Connext client (a non-routing implementation of Connext’s protocols i.e. a “light node”) into wallet(s).
- Writing one or many State Channel Applications for your usecase.
- Collateralizing and operating the Connext node.
Running a Connext node
Running a Connext node is pretty easy!
Connext runs entirely inside preconfigured docker containers. You can spin up your own Connext node locally and start making test payments with . A production deployment requires , but works out of the box with any cloud infrastructure provider.
What does a Connext node do?
Connext nodes are daemons that automatically respond to received messages to create and take actions on user channels. Connext nodes can be run by wallets, payment processors, platforms, and exchanges.
Connext nodes are comprised of:
- , a low level module that implements the core Connext protocol execution engine
- , a service module that transports Connext protocol messages using
- , a postgres db
- which are all automatically deployed to whatever chain you are on when running Connext and which secure user funds in the event of a dispute
Connext nodes can be configured to support any currency, and to support swapping between currencies while transactions are in-flight (e.g. sender pays in Dai, but receiver gets Eth).
What is the Connext client?
The is effectively a “light node” and implements Connext’s protocols in user-facing code. The client should exist wherever the user’s keys are, which means that platforms should create Ethereum wallets as part of their Connext integration if they haven’t already.
We have 3 client implementations available:
- The written in Typescript which environment-agnostic and is used as the base for the following two implementations.