• This repository has been archived on 27/Dec/2022
  • Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 4 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

↗️ Vector is an ultra-minimal state channel network implementation.

production

↗️ Vector

Vector is an ultra-simple, flexible state channel protocol and implementation.

At Connext, our goal is to build the cross-chain routing and micropayment layer of the decentralized web. Vector sits on top of Ethereum, evm-compatible L2 blockchains, and other turing-complete chains, and enables instant, near free transfers that can be routed across chains and over liquidity in any asset.

Out of the box, it supports the following features:

  • 💸 Conditional transfers with arbitrary generality routed over one (eventually many) intermediary nodes.
  • 🔀 Instant cross-chain and cross-asset transfers/communication. Works with any evm-compatible chain.
  • 🔌 Plug in support for non-evm turing complete chains.
  • 💳 Simplified deposits/withdraw, just send funds directly to the channel address from anywhere and use your channel as a wallet!
  • Native e2e gas abstraction for end-users.
  • 💤 Transfers to offline recipients.

This monorepo contains a number of packages hoisted using lerna. Documentation for each package can be found in their respective readme, with some helpful links in Architecture below.

Contents:

Quick Start - Local Development

Prerequisites:

  • make: Probably already installed, otherwise 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.
  • docker: See the Docker website for installation instructions.

To start, clone & enter the Vector repo:

git clone https://github.com/connext/vector.git
cd vector

To build everything and deploy a Vector node in dev-mode, run the following:

make start-router

# view the node's logs
bash ops/logs.sh node

# view the router's logs
bash ops/logs.sh router

That's all! But beware: the first time make start-node is run, it will take a very long time (maybe 10 minutes, depends on your internet speed) but have no fear: downloads will be cached & most build steps won't ever need to be repeated again so subsequent make start runs will go much more quickly. Get this started asap & browse the rest of the README while the first make start runs.

By default, Vector will launch using two local chains (ganache with chain id 1337 and 1338) but you can also run a local Vector stack against a public chain (or multiple chains!) such as Rinkeby. To do so, edit the chainProviders and chainAddresses fields of config.json according to the chain you want to support.

Note: this will start a local Connext node pointed at a remote chain, so make sure the mnemonic used to start your node is funded in the appropriate native currencies and supported chain assets. By default, the node starts with the account:

mnemonic: "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
privateKey: "0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
address: "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";

To apply updates to config.json, you'll need to restart your vector node with make restart-node.

(make start/make restart are aliases for make start-router/make restart-router)

Four different Vector stacks are supported:

  • messaging: standalone messaging + auth service
  • chains: EVMs in dev-mode
  • node: vector node + database
  • router: vector node + router + database
  • duet: 2x node/db pairs, used to test one-on-one node interactions
  • trio: 2x node/db pairs + 1x node/router/db , used to test node interactions via a routing node.

For any of these stacks, you can manage them with:

  • make ${stack} eg make duet builds everything required by the given stack
  • make start-${stack} eg make start-router will start up the router stack.
  • make stop-${stack} stops the stack
  • make restart-${stack} stops the stack if it's running & starts it again
  • make test-${stack} runs unit tests against some stack. It will build & start the stack if that hasn't been done already.

You can find WIP documentation on integrating and using Vector here.

Architecture and Module Breakdown

Vector uses a layered-approach to compartmentalize risk and delegate tasks throughout protocol usage. In general, lower layers are not context-aware of higher level actions. Information flows downwards through call params and upwards through events. The only exception to this are services, which are set up at the services layer and passed down to the protocol directly.

alt

You can find documentation on each layer in its respective readme:

  • Contracts - holds user funds and disburses them during a dispute based on commitments provided by channel parties.
  • Protocol - creates channels, generates channel updates/commitments, validates them, and then synchronizes channel state with a peer.
  • Engine - implements default business logic for channel updates and wraps the protocol in a JSON RPC interface.
  • Server-Node - sets up services to be consumed by the engine, spins up the engine, and wraps everything in REST and gRPC interfaces.
  • Router - consumes the server-node interface to route transfers across multiple channels (incl across chains/assets)

Note that the engine and protocol are isomorphic. Immediately after the core implementation is done, we plan to build a browser-node implementation which sets up services in a browser-compatible way and exposes a direct JS interface to be consumed by a dApp developer.

Development and Running Tests

You can build the whole stack by running make.

Running tests:

  • Unit tests are run using make test-{{$moduleName}}.
  • Two party integration tests are run using make start-duet and then make test-duet
  • Three party (incl routing node) itests are run using make start-trio and then make test-trio

More Repositories

1

monorepo

Connext is a modular stack for trust-minimized, generalized communication between blockchains.
TypeScript
292
star
2

chaindata

Cross-chain EVM-based token data.
Solidity
154
star
3

indra

[LEGACY] Monorepo containing everything related to the core Connext protocols and network.
TypeScript
84
star
4

xapp-starter

Short and sweet examples of xapps (crosschain applications) built with Connext!
Solidity
57
star
5

spacefold

🌓 A demo of instant cross-chain communication using Connext!
TypeScript
57
star
6

xDonations

A simple contract to accept donations from any chains for Turkey Relief DAO
TypeScript
25
star
7

router-docker-compose

Production-ready docker-compose for Connext routers.
24
star
8

documentation

Docs
JavaScript
17
star
9

brand

Visual identity and branding of Connext
13
star
10

chain-abstraction-integration

A Toolkit to help dApps Chain Abtract their user flows.
Solidity
11
star
11

vector-modal

Instant crosschain transfers in an easy-to-use widget component.
TypeScript
10
star
12

browser-sdk

🌐 💸 A simple drop-in SDK to enable micropayments in any browser page.
TypeScript
9
star
13

interfaces

Minimal interfaces needed for integrations
Solidity
6
star
14

react-native-client

React Native client implementation
Java
4
star
15

connext-analytics

Jupyter Notebook
3
star
16

airdrop-contracts

Holds the contracts to support the Connext airdrop
Solidity
3
star
17

ovm-contracts

Connext contracts modified to be compatible with the OVM
TypeScript
3
star
18

audits

Links to all of the audit reports for Connext
3
star
19

rest-api-client

REST API client implementation
TypeScript
2
star
20

nxtp-router-contracts

Factory contracts for smart-contract based nxtp routers.
TypeScript
2
star
21

nxtp-explorer

TypeScript
2
star
22

vector-router-docker-compose

Production-targeted Vector router.
Shell
2
star
23

chain-abstraction-reference

Solidity
2
star
24

watcher-deploy

HCL
1
star
25

router-helm

Mustache
1
star
26

vector-withdraw-helpers

Implementations of Vector withdrawal helper contracts.
TypeScript
1
star
27

sdk-minimal-example

JavaScript
1
star
28

IRCs

RFCs for the third major iteration of Indra
1
star
29

token-transfer

TypeScript
1
star
30

vector-widget-example

HTML
1
star
31

whiteblock-testing

Shell
1
star
32

bridge-reference

A reference implementation to bridging ERC-20 tokens across EVM chains via Connext
TypeScript
1
star
33

vector-demo

JavaScript
1
star
34

dao-testbed

Testing utilities for creating and validating executable crosschain proposals.
Solidity
1
star
35

connext-example

examples for Connext for Integrations
1
star