Skip to content

webb-tools/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 🎉

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 💬.

Installation & Compile 💻

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

Using Nix with Flakes ❄️

  1. Install Nix
  2. Enable Flakes (if you are not already see here: Flakes)
  3. If you have direnv installed, everything should work out of the box.
  4. Alternatively, you can run nix develop in the root of this repo to get a shell with all the dependencies installed.
  5. Happy hacking!

Generating Fixtures

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

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

Contributing

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.