π Webb's Solidity Smart Contract Implementation π
Table of Contents
This repository contains the Solidity smart contracts for Webb's Anchor System and single asset shielded pool protocols. The Anchor System is a bridging protocol for connecting cryptographic accumulators between chains and can be used, as is implemented in this repo, to build interoperable shielded pool protocols. These shielded pool protocols enable cross-chain private asset transfers and liquidity pools.
For additional information, please refer to 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 π¬.
Install dependencies:
yarn install
Update submodules:
git submodule update --init --recursive
To populate fixtures from the submodules, you'll need to install DVC: https://dvc.org/doc/install. Then run:
yarn fetch:fixtures
To compile contracts and build typescript interfaces
yarn build
To run the test suite:
yarn test
To fix the formatting:
yarn format
To run TypeScript checks:
yarn ts-check
Note: If you push new fixtures to remote storage
cd solidity-fixtures
dvc add solidity-fixtures
dvc push --remote aws
- Install Nix
- Enable Flakes (if you are not already see here: Flakes)
- If you have
direnv
installed, everything should work out of the box. - Alternatively, you can run
nix develop
in the root of this repo to get a shell with all the dependencies installed. - Happy hacking!
If you need to generate fixtures you will need 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
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
.
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
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!
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.