Thanks to visit codestin.com
Credit goes to github.com

Skip to content

tangle-network/protocol-solidity

Repository files navigation

πŸš€ Webb's Solidity Smart Contract Implementation πŸš€

GitHub Workflow Status License Apache 2.0 Twitter Telegram Discord

πŸ“– Table of Contents

Table of Contents

Getting Started πŸŽ‰

For additional information, please refer to the Webb protocol-solidity implementation docs and the official Webb docs site πŸ“. Have feedback on how to improve protocol-solidity? Or have a specific question to ask? Checkout the Anchor System Feedback Discussion πŸ’¬.

Prerequisites

Your development environment will need to include nodejs, and Rust setups. If you need to generate fixtures you will also require Circom 2.0 and snarkjs installations. You can find installation instructions below.

This repository makes use of node.js, yarn, Rust, and requires version 16. To install node.js binaries, installers, and source tarballs, please visit https://nodejs.org/en/download/. Once node.js is installed you may proceed to install yarn:

npm install --global yarn

Great! Now your Node environment is ready! πŸš€πŸš€

You must also have Rust installed. This guide uses https://rustup.rs installer and the rustup tool to manage the Rust toolchain.

First install and configure rustup:

# Install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Configure
source ~/.cargo/env

Configure the Rust toolchain to default to the latest nightly version, and add the nightly wasm target:

rustup default nightly
rustup update
rustup update nightly
rustup target add wasm32-unknown-unknown

Great! Now your Rust environment is ready! πŸš€πŸš€

Lastly, install

  • DVC is used for fetching large ZK files and managing them alongside git
  • substrate.io may require additional dependencies

πŸš€πŸš€ Your environment is complete! πŸš€πŸš€

Generating Fixtures Prerequisites

NOTE: This is only required for testing / dev purposes and not required to compile or interact with smart contracts.

To generate fixtures you will need Circom 2.0 and snarkjs installed. To install from source, clone the circom repository:

git clone https://github.com/iden3/circom.git

Enter the circom directory and use the cargo build to compile:

cargo build --release

The installation takes around 3 minutes to be completed. When the command successfully finishes, it generates the circom binary in the directory target/release. You can install this binary as follows:

cargo install --path circom

The previous command will install the circom binary in the directory $HOME/.cargo/bin.

Installing snarkjs

snarkjs is a npm package that contains code to generate and validate ZK proofs from the artifacts produced by circom.

You can install snarkjs with the following command:

npm install -g snarkjs

Installation & Compile πŸ’»

Install dependencies:

yarn install 

Update submodules:

git submodule update --init --recursive

Populate fixtures from the submodules:

yarn fetch:fixtures

To compile contracts and build typescript interfaces

yarn build

Note: If you push new fixtures to remote storage

cd solidity-fixtures
dvc add solidity-fixtures
dvc push --remote aws

Testing πŸ§ͺ

To run the test suite, update the submodules:

git submodule update --init --recursive

Fetch the fixtures:

yarn fetch:fixtures

Install the dependencies:

yarn install

Compile the contracts:

yarn compile

Run test suite:

yarn test

It is also possible to output a gas report of the contracts by running:

yarn test:gas-reporter

To fix the formatting, please run:

yarn format

To run TypeScript checks:

yarn ts-check

Interacting

This repository contains a variety of scripts to deploy and interact with the smart contracts in the scripts folder. To use these scripts, one will need to setup an .env file in the root directory:

# Setup an endpoint
ENDPOINT=https://rinkeby.infura.io/v3/fff68ca474dd4764a8d54dd14fa5519e

# Add private key
PRIVATE_KEY=XXX-XXX-XXX

After adding the .env, scripts can be executed using ts-node

 npx ts-node ./scripts/evm/deployments/LocalEvmVBridge.ts

Contributing

Interested in contributing to the Webb Relayer Network? Thank you so much for your interest! We are always appreciative for contributions from the open-source community!

If you have a contribution in mind, please check out our Contribution Guide for information on how to do so. We are excited for your first contribution!

License

Licensed under Apache 2.0 / MIT license.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the MIT OR Apache 2.0 license, shall be licensed as above, without any additional terms or conditions.

Packages

 
 
 

Contributors 14