This is an introduction to Nillion's Nada language with examples of all built-in operations.
Open nada-by-example in Gitpod, then run any example
nada run [test-name]
-
Add your Nilchain private key in the .streamlit/secrets.toml file
-
Run a demo
streamlit run streamlit_app.py [test-name]
Install nilup
curl https://nilup.nilogy.xyz/install.sh | bash
Install the latest
version of the Nillion SDK and tools
nilup install latest
nilup use latest
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
nilup instrumentation enable --wallet <your-eth-wallet-address>
nada build --mir-json
This creates one compiled binary (.nada.bin) file and one json file (.nada.json) per program listed in the nada-project.toml
file in the target/ directory. The json file is needed to get inputs, outputs, types, and parties for any Streamlit demo apps.
nada test [test_name]
For example to test the src/addition.py
program with the test value inputs from tests/addition_test.yaml
, run:
nada test addition_test
Create a new file in src/
with the name of the program.
Write the program in the new file
For the nada tool to know about the new program, you need to add the following to the to the nada-project.toml
config file. Change this code so the path
and name
match the name of your program.
[[programs]]
path = "src/your_program_name.py"
name = "your_program_name"
prime_size = 128
Use the nada tool to generate a set of test values for your program, that will be stored in tests/
.
nada generate-test --test-name {your_program_name}_test {your_program_name}
nada test {your_program_name}_test
Test the program. If you run the above command without altering the default values (3s) in the test file (tests/{your_program_name}_test.yaml), the test will fail because the expected test output doesn't match the resulting output. Modify the values in the test file and re-test the program.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .streamlit/secrets.toml.example .streamlit/secrets.toml
streamlit run streamlit_app.py addition_test
streamlit run streamlit_app.py [test-name]