generated from nihat99/ng-questplay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
47 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,4 @@ | ||
**/node_modules | ||
.openzeppelin | ||
.DS_Store | ||
.vscode | ||
artifacts | ||
cache | ||
.env | ||
.cache/*.jwt | ||
.settings | ||
|
||
artifacts | ||
cache | ||
|
||
target | ||
|
||
proofs/ | ||
target/ | ||
Prover.toml | ||
Verifier.toml | ||
crs | ||
Verifier.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "if_test" | ||
type = "sol" | ||
authors = [""] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,38 @@ | ||
![Node Guardians: Quests](./media/banner.webp) | ||
<img align="right" width="150" height="150" top="100" src="./assets/readme.png"> | ||
|
||
Welcome guardian. The road out will be treacherous, but remember, fortune favors the brave. | ||
# Solidity Circuits | ||
|
||
`ng-questplay` is a lightweight CLI-based application that helps you manage your quests as you venture out into [the wilderness](https://nodeguardians.io/) to complete quests and fulfill your duty as a _Node Guardian_. | ||
Write zero knowledge proofs in solidity. | ||
|
||
## Getting Started | ||
Creating an alternative frontend for noir / nargo, developers can write, prove and verify zk circuits that are written in solidity. | ||
|
||
We **highly recommend** that you set up Questplay by following [our tutorial](https://nodeguardians.io/dev-hub?s=devhub-campaigns&sc=tutorial). But here are the brief steps anyways. | ||
That's it. | ||
|
||
1. Create a new private repository `ng-questplay` on Github and leave it empty for now. Then, install [our Github application](https://github.com/apps/node-guardians) on it. | ||
## What is in this repo? | ||
|
||
> ⚠ Your repository must be private! | ||
This repo contains a `nargo` workspace where the files are written in solidity. Each example demonstrates a different type of circuit, use the run instructions below to test each of them! | ||
|
||
2. Download this repository onto your local device, and push it to the Github repository you have created. | ||
### How to run? | ||
|
||
- **If Using GitHub HTTPS:** | ||
1. Make sure you have `noirup` installed - instructions below. | ||
2. Go and clone this [branch of noir](https://github.com/noir-lang/noir/tree/md/solidity-circuits) | ||
3. Run `noirup -p .` to replace your local nargo binary with the one with solidity support | ||
4. Run `nargo check` to generate prover toml etc | ||
5. Enter the values you want in your generate your proof with in `Prover.toml` | ||
6. `nargo compile` | ||
7. `nargo prove` | ||
8. `nargo verify` | ||
|
||
``` | ||
git clone https://github.com/Nodeguardians/ng-questplay.git | ||
cd ng-questplay | ||
git remote set-url origin https://github.com/{GITHUB_USERNAME}/ng-questplay.git | ||
git push -u origin main | ||
``` | ||
|
||
- **If Using Github SSH** | ||
### First time with Noir? | ||
|
||
``` | ||
git clone git@github.com:github.com/Nodeguardians/ng-questplay.git | ||
cd ng-questplay | ||
git remote set-url origin git@github.com:{GITHUB_USERNAME}/ng-questplay.git | ||
git push -u origin main | ||
``` | ||
See the official Noir installation [instructions](https://noir-lang.org/getting_started/nargo_installation). | ||
|
||
> 💡 Replace `{GITHUB_USERNAME}` with your Github username! | ||
Then, install the [Noir](https://github.com/noir-lang/noir) toolchain installer (`noirup`) with: | ||
|
||
3. Next, run the following command to install the required dependencies. | ||
``` | ||
npm run start-adventure | ||
``` | ||
4. Create a [Github authentication token](https://nodeguardians.io/?s=home-faq&sf=devhub--why-and-how-do-i-create-a-github-token) with **public repo access**. Then, create a `.env` file in your root folder and add a `GITHUB_TOKEN` variable: | ||
```bash | ||
# In .env file | ||
GITHUB_TOKEN = "ghp_..." # Add token here | ||
``` | ||
> ⚠️ Take care to not share / upload your `.env` file to anyone or anywhere. | ||
## Finding a Quest | ||
Run the following command to find and download a specific quest into your repo. | ||
``` | ||
quest find | ||
``` | ||
Alternatively, you can immediately specify the quest name (hyphenated, no spaces). | ||
``` | ||
quest find using-signatures | ||
``` | ||
## Running a Local Test | ||
To run a local test in a quest, first make sure you are in the quest folder. Then: | ||
``` | ||
# Run local tests in Part 1 | ||
quest test 1 | ||
``` | ||
``` | ||
# Run all local tests | ||
quest test | ||
```bash | ||
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash | ||
``` | ||
|
||
If you have Foundry installed, our quests also support local Foundry tests. To configure your preferred framework to Foundry: | ||
``` | ||
quest set-framework foundry | ||
``` | ||
After which, running `quest test` will trigger Foundry tests to run instead. The native command `forge test` also triggers Foundry tests, albeit in a less readable format. However, using `forge` gives you access to Foundry's many features (e.g., `-vvv` flag). | ||
## Submitting a Quest | ||
To submit a quest for verification, first make sure you are in the quest folder. | ||
Commit all your changes into your local repository. Then run: | ||
``` | ||
quest submit | ||
``` | ||
This command pushes your code to your remote repository in Github for verification. | ||
## Running the Cross-Chain Bridge | ||
Certain quests require you to run a cross-chain bridge from **Avalanche Fuji** to **Ethereum Goerli**. These quests will provide you a way to obtain a 32-byte bridge hash. Then, run the following command. | ||
> 💡 Replace `{BRIDGE_HASH}` with your 32-byte bridge hash! | ||
If the bridge hash is valid, you will be given a signature required to process any cross-chain transaction. | ||
## Updating CLI | ||
To update the CLI, run: | ||
``` | ||
quest update | ||
``` | ||
Now you've installed the `noirup` binary, | ||
Follow the instructions above to install the solidity circuits branch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
contract ForLoopTest { | ||
|
||
// Demonstrate a simple for loop | ||
function main(uint256 x) public pure returns (uint256) { | ||
uint256 ret_val = x; | ||
|
||
// Note, for loops MUST be in this form for support | ||
// Codegen must be able to solve for a static start and end to the loop | ||
// Using this i pattern is the simplest way | ||
for (uint256 i = 0; i < 10; i++){ | ||
ret_val += i; | ||
} | ||
return ret_val; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.