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

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

Open
crypblizz8 opened this issue Oct 2, 2024 · 1 comment
Labels

Comments

@crypblizz8
Copy link
Collaborator

crypblizz8 commented Oct 2, 2024

Thank you for taking the time to be a part of Hacktoberfest 2024! 🎉 🥳 🎉

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

🚨 First things first 🚨

Make sure you are registered at Hacktoberfest.

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
  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
  3. Congratulations on completing your Nillion Hacktoberfest Challenge 🥳 🙌 🎉

Other

Add other issues here.

@abu0091
Copy link

abu0091 commented Oct 16, 2024

lets try

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

2 participants