Integrating Connext and the hosted Dai hub allows you to make instant, trust-minimized, off-chain payments to anyone else connected to the hub. This guide will walk you through how to get a hub up and running locally and some key aspects of integrating the client. If you are unfamiliar with payment channels, or ethereum basics, make sure you have read the introduction.
Make: (probably already installed) Install w brew install make or apt install make or similar.
jq: (probably not installed yet) Install w brew install jq or apt install jq or similar.
You can also skip this step for now if you want to connect to our hosted rinkeby hub instead of running your own locally.
Starting Indra will take a while the first time, but the build gets cached so it will only take this lone the first time. While it's building, configure your metamask to use the rpc localhost:3000/api/eth and import the hub's private key (659CBB0E2411A44DB63778987B1E22153C086A95EB6B18BDF89DE078917ABC63) so you can easily send money to the signing wallet.
Alternatively, point metamask to a Rinkeby rpc url (eg use our hub's eth endpoint: https://rinkeby.hub.connext.network/api/eth) and get some Rinkeby eth from a faucet.
Once all the components are up and running, navigate to http://localhost/ to checkout the sandbox. To implement the client on your own frontend, checkout the implementing the client section.
Warning: This basic example is currently broken due to complexity surrounding the way web3.js signs. We are actively working on fixing this. In the meantime, check out the daicard repo as a slightly more complicated example of an app that utilizes a connext client.
The following is a basic example of how to use the client to make payments. As an implementer, there are some core concepts to be aware of that will impact user experience based on your client implementation.
// Now that the client is started, you can make a deposit into the channel.
// of the deposit transaction.
// in channel exchanges, token payments, and channel withdrawals in wei.
// which ties together all payment channel updates initiated in the array.
// hub is able to deposit more tokens into the channel.
Check out the Dai Card live, and its source for a more detailed implementation example.