• This repository has been archived on 13/Jul/2022
  • Stars
    star
    463
  • Rank 91,418 (Top 2 %)
  • Language
    Go
  • License
    GNU Lesser Genera...
  • Created over 4 years ago
  • Updated 12 months ago

Reviews

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

Repository Details

🌉 Modular Multi-Directional Blockchain Bridge to interact with Multiple Networks; Ethereum, Ethereum Classic, Substrate, based chains. Stay tuned for ChainBridge Hub!

Archiving notice:

This library is no longer in use and maintenance. All further development related to chainbridge will happen in the new repo. More detailed information about chainbridge-core you can find in its readme or Discussions.

If you already running an old ChainBridge version please consider checking chainbridge-migration scripts that allow migrating to a newer version of chainbridge.

ChainBridge

discord build status

Contents

Getting Started

Installation

Dependencies

  • Subkey: Used for substrate key management. Only required if connecting to a substrate chain.

Building

make build: Builds chainbridge in ./build.

or

make install: Uses go install to add chainbridge to your GOBIN.

Docker

The official ChainBridge Docker image can be found here.

To build the Docker image locally run:

docker build -t chainsafe/chainbridge .

To start ChainBridge:

  • docker run -v uses an absolute path rather than a relative one.
docker run -v $(pwd)/config.json:/config.json chainsafe/chainbridge

Configuration

Note: TOML configs have been deprecated in favour of JSON

A chain configurations take this form:

{
    "name": "eth",                      // Human-readable name
    "type": "ethereum",                 // Chain type (eg. "ethereum" or "substrate")
    "id": "0",                          // Chain ID
    "endpoint": "ws://<host>:<port>",   // Node endpoint
    "from": "0xff93...",                // On-chain address of relayer
    "opts": {},                         // Chain-specific configuration options (see below)
}

See config.json.example for an example configuration.

Ethereum Options

Ethereum chains support the following additional options:

{
    "bridge": "0x12345...",          // Address of the bridge contract (required)
    "erc20Handler": "0x1234...",     // Address of erc20 handler (required)
    "erc721Handler": "0x1234...",    // Address of erc721 handler (required)
    "genericHandler": "0x1234...",   // Address of generic handler (required)
    "maxGasPrice": "0x1234",         // Gas price for transactions (default: 20000000000)
    "minGasPrice": "0x1234",         // Minimum gas price for transactions (default: 0)
    "gasLimit": "0x1234",            // Gas limit for transactions (default: 6721975)
    "gasMultiplier": "1.25",         // Multiplies the gas price by the supplied value (default: 1)
    "http": "true",                  // Whether the chain connection is ws or http (default: false)
    "startBlock": "1234",            // The block to start processing events from (default: 0)
    "blockConfirmations": "10"       // Number of blocks to wait before processing a block
    "useExtendedCall": "true"        // Extend extrinsic calls to substrate with ResourceID. Used for backward compatibility with example pallet. *Default: false*
    "egsApiKey": "xxx..."            // API key for Eth Gas Station (https://www.ethgasstation.info/)
    "egsSpeed": "fast"               // Desired speed for gas price selection, the options are: "average", "fast", "fastest"
}

Substrate Options

Substrate supports the following additonal options:

{
    "startBlock": "1234" // The block to start processing events from (default: 0)
}

Blockstore

The blockstore is used to record the last block the relayer processed, so it can pick up where it left off.

If a startBlock option is provided (see Configuration), then the greater of startBlock and the latest block in the blockstore is used at startup.

To disable loading from the blockstore specify the --fresh flag. A custom path for the blockstore can be provided with --blockstore <path>. For development, the --latest flag can be used to start from the current block and override any other configuration.

Keystore

ChainBridge requires keys to sign and submit transactions, and to identify each bridge node on chain.

To use secure keys, see chainbridge accounts --help. The keystore password can be supplied with the KEYSTORE_PASSWORD environment variable.

To import external ethereum keys, such as those generated with geth, use chainbridge accounts import --ethereum /path/to/key.

To import private keys as keystores, use chainbridge accounts import --privateKey key.

For testing purposes, chainbridge provides 5 test keys. The can be used with --testkey <name>, where name is one of Alice, Bob, Charlie, Dave, or Eve.

Metrics

See metrics.md.

Chain Implementations

  • Ethereum (Solidity): chainbridge-solidity

    The Solidity contracts required for chainbridge. Includes deployment and interaction CLI.

    The bindings for the contracts live in bindings/. To update the bindings modify scripts/setup-contracts.sh and then run make clean && make setup-contracts

  • Substrate: chainbridge-substrate

    A substrate pallet that can be integrated into a chain, as well as an example pallet to demonstrate chain integration.

Docs

MKdocs will generate static HTML files for Chainsafe markdown files located in Chainbridge/docs/

make install-mkdocs: Pull the docker image MkDocs

make mkdocs: Run MkDoc's docker image, building and hosting the html files on localhost:8000

Testing

Unit tests require an ethereum node running on localhost:8545 and a substrate node running on localhost:9944. E2E tests require an additional ethereum node on localhost:8546.

A docker-compose file is provided to run two Geth nodes and a chainbridge-substrate-chain node in isolated environments:

$ docker-compose -f ./docker-compose-e2e.yml up

See chainbridge-solidity and chainbridge-substrate-chain for more information on testing facilities.

All Go tests can be run with:

$ make test

Go tests specifically for ethereum, substrate and E2E can be run with

$ make test-eth
$ make test-sub
$ make test-e2e

ChainSafe Security Policy

Reporting a Security Bug

We take all security issues seriously, if you believe you have found a security issue within a ChainSafe project please notify us immediately. If an issue is confirmed, we will take all necessary precautions to ensure a statement and patch release is made in a timely manner.

Please email us a description of the flaw and any related information (e.g. reproduction steps, version) to security at chainsafe dot io.

More Repositories

1

lodestar

🌟 TypeScript Implementation of Ethereum Consensus
TypeScript
1,012
star
2

web3.unity

🕹 Unity SDK for building games that interact with blockchains.
C#
817
star
3

forest

🌲 Rust Filecoin Node Implementation
Rust
553
star
4

dappeteer

[DEPRECATED]🏌🏼‍E2E testing for dApps using Puppeteer + MetaMask
TypeScript
486
star
5

gossamer

🕸️ Go Implementation of the Polkadot Host
Go
392
star
6

mina-rs

Rust implementation of the Mina protocol, targeting Wasm and ARM architectures.
Rust
159
star
7

js-libp2p-gossipsub

TypeScript implementation of Gossipsub
TypeScript
127
star
8

chainbridge-solidity

⚙️ Solidity contracts for Sygma (ChainBridge)
JavaScript
119
star
9

filsnap

MetaMask snap for interacting with Filecoin dapps.
HTML
107
star
10

bls

💻 Javascript Implementation of Boneh-Lynn-Shacham Signatures
TypeScript
92
star
11

chainbridge-core

🌁 Sygma core library (ChainBridge)
Go
91
star
12

go-schnorrkel

🍵 Schnorr Signatures over Ristretto255 in pure Go
Go
80
star
13

metamask-snap-polkadot

Metamask plugin for interacting with Polkadot dapps and other Substrate based chains.
TypeScript
77
star
14

chainbridge-substrate

Rust
55
star
15

Spectre

ZK coprocessor for verifying Beacon chain headers via Altair lightclient protocol
Rust
55
star
16

nodewatch-api

A devp2p crawler targeted at Eth2 nodes
Go
54
star
17

ui-monorepo

ChainSafe Files & Storage UI Monorepo
TypeScript
52
star
18

WeiPay

WeiPay is an open source cryptocurrency wallet available for both iOS and Android mobile devices. WeiPay will support Ethereum out of the box with added support for ERC-20 & ERC-223 tokens.
JavaScript
46
star
19

ChainGuardian

Eth2.0 desktop validator client
TypeScript
44
star
20

ssz

Typescript implementation of Simple Serialize (SSZ)
TypeScript
40
star
21

js-libp2p-noise

Noise libp2p handshake for js-libp2p
TypeScript
37
star
22

chainbridge-deploy

Deploy tooling for ChainBridge
JavaScript
35
star
23

Zipline-lightclient

Hackathon for EthBogota - An Eth2 light client using Cannon verifyable computation
C
30
star
24

discv5

A Typescript implementation of the Discv5 protocol
TypeScript
28
star
25

nodewatch-ui

TypeScript
27
star
26

chainbridge-ui

TypeScript
26
star
27

web3js-example-react-app

TypeScript
25
star
28

filecoindot

Filecoin to substrate bridge
Rust
24
star
29

Multix

Use a Multisig to do anything, on Polkadot
TypeScript
24
star
30

denode

a mechanism for incentivizing full nodes
24
star
31

chainbridge-substrate-chain

Simple Substrate chain for testing purposes
Rust
22
star
32

PINT

A Polkadot ecosystem index for investors. A self sustaining auction treasury for parachains.
Rust
21
star
33

eth-local

The purpose of eth-local is to offer a standardized way to store your keystore files on your local machine. While also allowing you to use them in browser.
JavaScript
21
star
34

chaindb

go key-value store using badgerDB
Go
20
star
35

as-sha256

AssemblyScript implementation of SHA256
WebAssembly
19
star
36

rust-libp2p-nym

implementation of a libp2p transport using the Nym mixnet
Rust
19
star
37

bls-keygen

Key management for BLS curves written in TypeScript and browser compatible
TypeScript
17
star
38

chainlink-cosmos

Chainlink on Cosmos: Cosmos SDK module for Chainlink data feeds
Go
17
star
39

bls-keystore

Implementation of bls keystore - EIP 2335
TypeScript
16
star
40

blst-ts

Typescript wrapper for https://github.com/supranational/blst native bindings, a highly performant BLS12-381 signature library
C++
16
star
41

bls-js

BLS signature implementation
TypeScript
15
star
42

das-prototype

Research prototypes of Data Availability Sampling for Ethereum (WIP)
Rust
14
star
43

truffle-plugin-abigen

Truffle plugin to post-process contracts for go-ethereum's abigen
Solidity
14
star
44

Anemone

A testing tool that broadcasts batches of transactions and tests opcodes
TypeScript
12
star
45

web3-context

A React context implementation of Onboard.js & general utilities
TypeScript
12
star
46

chainbridge-core-example

Go
11
star
47

ethermint-deploy

JavaScript
11
star
48

audits

This is public repository that holds ChainSafe audit reports
11
star
49

persistent-merkle-tree

TypeScript
11
star
50

ssz-js

Simple Serialize in TypeScript
TypeScript
9
star
51

chainbridge-utils

Go
9
star
52

dapp-boilerplate

A shared boilerplate for Dapp development
TypeScript
9
star
53

forest-iac

Infrastructure as Code to support the Forest Filecoin project
HCL
9
star
54

ens-aztec-privacy

[BETA] Sending private transactions to ENS domains using Aztec and custom ENS Resolver contract.
Solidity
9
star
55

js-libp2p-yamux

Typescript implementation of Yamux
TypeScript
9
star
56

go-signature-adaptor

A pure Go implementation of ECDSA signature adaptors
Go
9
star
57

dotcon-0.5

Decentralized Networking with Libp2p
Go
8
star
58

lodestar-quickstart

Scripts to quick start Lodestar and execution clients pre and post-merge Ethereum.
Shell
8
star
59

api3-rust

Rewrite API3 Solidity contracts in Rust (for Solana, Near, Oasis)
Rust
8
star
60

W-OTS

Winternitz OTS+ implementation
Rust
7
star
61

hobbits-ts

A TypeScript implementation of the Hobbits Ethereum Wire Protocol
TypeScript
7
star
62

simpleserialize.com

TypeScript
7
star
63

hardhat-plugin-multichain-deploy

Solidity
7
star
64

go-cumulus

Go implementation of cumulus. for creating parachains with gossamer
Makefile
6
star
65

ChainSafe-Demo-WebGLProject-Files

Project Files For The ChainSafe Demo
C#
6
star
66

lazy-minting-server

Sample implementation of a lazy minting server
TypeScript
6
star
67

game-web3wallet

JavaScript
6
star
68

bls-hd-key

BLS key derivation and hd key utilities
TypeScript
6
star
69

ethersjs-genaddress

a simple script to generate an eth address utilizing ethers.js
JavaScript
6
star
70

eth-drive

eth-drive is the first disk utility tool designed for ethereum addresses
HTML
6
star
71

mina-snap

Metamask snap for interacting with mina procotol
HTML
6
star
72

enr-app

TypeScript
5
star
73

eth2-light-client-demo

TypeScript
5
star
74

fil-secondary-retrieval-markets

Client and Provider implementations to enable secondary retrieval markets on Filecoin
Go
5
star
75

engineering-handbook

ChainSafe Engineering Handbook
JavaScript
5
star
76

serde-bin-prot

A Rust crate that adds serde support for the bin_prot serialization format
Rust
5
star
77

game-web3gl

JavaScript
5
star
78

files-cli

A cli tool to download and decrypt any file uploaded using ChainSafe Files
TypeScript
5
star
79

chainbridge-docs

HTML
5
star
80

TypeScript-Cli-Generator

A TypeScript CLI Template
TypeScript
5
star
81

beacon-state-upload

TypeScript
4
star
82

AGP-Report

Report for the Aragon Chain
4
star
83

rust-bls-derivation

Rust
4
star
84

sha256-rust-wasm

A wrapper around rust implementation of sha256
Rust
4
star
85

EthIndia2019

JavaScript
4
star
86

marketplace-landing

This is the marketplace landing page, currently a waitlist.
TypeScript
4
star
87

Zipline-Casper

A prototype implementation of the Zipline block root oracle using Casper finality
Solidity
4
star
88

aleo-snap

JavaScript
4
star
89

subgraph-arweave-example

Example subgraph for Arweave
TypeScript
4
star
90

near-snap

TypeScript
4
star
91

persistent-ts

TypeScript
3
star
92

ECOHacks

JavaScript
3
star
93

web3.js-plugin-chainlink

TypeScript
3
star
94

discv5-cli

Discv5 CLI
TypeScript
3
star
95

chainbridge-celo

Go
3
star
96

chainbridge-celo-solidity

JavaScript
3
star
97

metamask-eth2

Metamask snap plugin for eth2
HTML
3
star
98

chainbridge-substrate-events

Event definitions for GSRPC from the ChainBridge substrate pallet
Go
3
star
99

sha256-benchmarks

Benchmarks suite for various sha256 implementations
JavaScript
3
star
100

EthereumRPCSharp

Another .Net implementation of the Ethereum RPC
C#
3
star