Skip to content

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

Open
@crypblizz8

Description

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions