Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a simple Blind app with npx create-nillion-app #2

Open
crypblizz8 opened this issue Oct 2, 2024 · 8 comments
Open

Create a simple Blind app with npx create-nillion-app #2

crypblizz8 opened this issue Oct 2, 2024 · 8 comments
Labels

Comments

@crypblizz8
Copy link
Collaborator

crypblizz8 commented Oct 2, 2024

Thank you for taking the time to be a part of the Create Blind App Challenge! 🎉 🥳 🎉

We are looking for contributors for the Examples (Community) Section in Awesome Nillion.

🚨 First things first 🚨

If you ever get stuck, feel free to ask any questions in our Github Discussion.

Quickstart Guide

CNA_quickstart.mp4

CLI

  1. Star this repository
  2. Use the npm package in your terminal - npx @nillion/create-nillion-app and then follow the CLI instructions
  3. Follow the prompts and you should have your boilerplate setup -- ask for help if you ever get stuck: this sets up a Next.js app + Nada
  4. cd into your folder and run npm run dev to start your dev server + your app should appear on localhost:3000
  5. Run nillion-devnet in another terminal window
  6. Reload your Next.js app and you should be able to login, store a value and retrieve a value

Creating a Simple Nada app

Now let's get started with the magic of Nada! 🧙‍♂️ First, let's set it up our environment.

  • In a new terminal window, go into your root, then cd nada to go into your nada folder and run source .venv/bin/activate
  • Run pip install --upgrade nada-dsl to install Nada DSL

Now that our Python environment is ready, we will create a secret_addition Nada Program -- you may also follow along this section.

  1. Create a new file with touch src/secret_addition.py
  2. Copy and paste the Nada Program code:
from nada_dsl import *

def nada_main():

    party1 = Party(name="Party1")

    my_int1 = SecretInteger(Input(name="my_int1", party=party1))

    my_int2 = SecretInteger(Input(name="my_int2", party=party1))

    new_int = my_int1 + my_int2

    return [Output(new_int, "my_output", party1)]
  1. Add your program to nada-project.toml config file
[[programs]]
path = "src/secret_addition.py"
name = "secret_addition"
prime_size = 128

It should end up looking like:

name = "nada"
version = "0.1.0"
authors = [""]

[[programs]]
path = "src/secret_addition.py"
name = "secret_addition"
prime_size = 128
  1. nada build to build your program
  2. nada generate-test --test-name secret_addition_test secret_addition to generate tests
  3. nada run secret_addition_test to run the program
  4. nada test secret_addition_test to run the tests

Connecting the Next.js app <> Nada Program

  1. Upload your program from your nada/src/target/secret_addition.nada.bin
  2. Copy the programID and use it in the Compute section
  3. Copy the computeOutputID and use it in the Compute Output section
  4. Congratulations! You have run the Nada Program via your frontend 🎉

Wrapping up

  1. Host your github on a public repository
  2. Once you are finished, create a PR on this repo (awesome-nillion) to be added to the community page -- see this example + answer the questions from the example
@abu0091
Copy link

abu0091 commented Oct 16, 2024

lets try

@TestNetHunterOfficial
Copy link

I will try it as soon as possible 💪

@HadesGuard
Copy link
Contributor

Thanks, I completed on my local machine

@crypblizz8
Copy link
Collaborator Author

@HadesGuard Would you mind doing a PR like this.

@IkutoJP
Copy link
Contributor

IkutoJP commented Oct 21, 2024

I will try it 💪

sushmitsarmah added a commit to sushmitsarmah/awesome-nillion that referenced this issue Oct 27, 2024
@sushmitsarmah
Copy link

@crypblizz8 I created a PR. #17

@crypblizz8 crypblizz8 changed the title [Hacktoberfest] Create a simple Blind app with npx create-nillion-app Create a simple Blind app with npx create-nillion-app Oct 30, 2024
@bonyairdrop
Copy link

Interesting let's try

@JesseAdjetey
Copy link

Hello. Curios here. Please was there any reason why the nillion bounty was removed for redacted? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants