Skip to content

Decentralized cross-chain data bridge powered by Nerif Network

License

Notifications You must be signed in to change notification settings

johanneskern/bridge

 
 

Repository files navigation

Nerif Bridge

Nerif Bridge is the decentralized cross-chain bridge powered by Nerif Network.

structure.png

DO NOT USE FOR PRODUCTION PURPOSES. This bridge setup does not have a proper security mechanisms, billing, and many other things that are needed for production use. The current state of Nerif Bridge shows high level overview of the bridging architecture using Nerif Network and can be used for demo only.

Set up

Bootstrapping the Nerif Bridge requires deploying several smart contracts and creating a special workflow within Nerif Network in order to power the bridge.

Bridge contracts deployment requires having Gateway contract already deployed and registered per Registry on all chains.

Initialize environment

First aff all, run the following command in order to create all required environment files:

$ make init

As a results, the following files will be created: .env, contracts-5.json, contracts-80001.json, contracts-97.json, contracts-10200.json. Replace gateway address for the real one in those .json files. Specify real values in .env file.

Now the bridge contracts can be deployed:

$ VERIFY=true make deploy-bridge

As a result, the bridge contract will be deployed on Goerli (5), Mumbai (80001), BSC Testnet (97), and Gnosis Chiado (10200) chains. Addresses are stored in those .json filed in the root of the repo.

Create Nerif Network workflow

All needed contracts are deployed so those can be automated by Nerif Network. It requires creating a bridging workflow that has the following logic:

  1. Trigger workflow execution when event Send(uint256 chainId, address target, bytes payload, uint256 gasAmount, address sender) event is emitted on the Goerli chain within the bridge contract.
  2. Add conditional step to check the given chain ID and exit the workflow if the value is not 80001.
  3. Otherwise, send a transaction to the bridge contract deployed on Mumbai chain in order to execute rec function within the contract. Pass all required arguments coming from the event.

workflow.png

Note: other steps could be added at the bridge owner's discretion.

Test

There is the test receiver contract that can be deployed on those chains.

The following command deploys this contract on the Mumbai (80001) chain:

$ VERIFY=true make deploy-receiver

Test receiver contract address is stored in the contracts-80001.json file.

Now, the first test message can be sent be executing send function within the bridge contract deployed on goerli. It can be done in many ways, but there is a command for sending a test message:

$ make send-message

About

Decentralized cross-chain data bridge powered by Nerif Network

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 54.8%
  • Solidity 21.2%
  • Go 10.2%
  • Makefile 7.2%
  • Dockerfile 2.6%
  • JavaScript 2.6%
  • Shell 1.4%