π οΈ Build and deploy your first iApp β
Reading time π 10 mins
Time to build!
Let's build an iApp that can process protected data in a secure environment.
An iApp runs in a Trusted Execution Environment (TEE), it can process data in a secure environment.
This guide will help you set up, test, deploy and run your iApp using the iapp-cli
tool. Follow the instructions carefully for a smooth development experience.
π Prerequisites β
Before getting started, ensure you have the following:
Don't worry! All secrets used in this tutorial stay on your machine and arenβt shared with anyone. Youβll only need them to run the iApp run
command.
πΎ Installation (win / mac / linux) β
First, you need to install the iapp
package. Open your terminal and run:
npm i -g @iexec/iapp
You can check if the installation was successful by running:
#checking the version
iapp --version
#checking the available commands
iapp --help
π οΈ Initialize Framework β
To initialize the working directory for developing your iApp, use the iapp init
command. This command sets up the necessary project structure and files.
mkdir iexec-test
cd iexec-test
iapp init
You will be prompted with the following message:
___ _ ____ ____
|_ _| / \ | _ \| _ \
| | / _ \ | |_) | |_) |
| | / ___ \| __/| __/
|___/_/ \_\_| |_|
β What's your project name? (A folder with this name will be created) β¦ hello-world
β Which language do you want to use? βΊ JavaScript
? What kind of project do you want to init? βΊ - Use arrow-keys. Return to submit.
β― Hello World - iapp quick start
advanced
? What's your project name? (A folder with this name will be created) ...
? Which language do you want to use? βΊ - Use arrow-keys. Return to submit.
β― JavaScript
Python
? What kind of project do you want to init? βΊ - Use arrow-keys. Return to submit.
β― Hello World - iapp quick start
advanced
We recommend selecting "Hello World" to quickly discover how iApp works! use advanced only if you are familiar with iExec.
β [Chosen language] app setup complete.
β Generated ethereum wallet (0xD4A28d.........................)
An iApp project is setup with the selected language
An ethereum wallet has been created (we use it to sign the iApp creation onchain)
A new folder has been created, it contains a very simple application, with the main code being located in
src/app.js
orsrc/app.py
π§ͺ Test Your iApp β
To test your iApp, run iapp test
command
iapp test
It uses your local docker to build and execute the app.
- If you have Error: Docker daemon is not accessible
Make sure Docker is installed and running.
- If you have Error: Failed to locate iApp project root
error: Ensure you are in your project folder before proceeding.
You can see the output of the computation by saying yes to the question:
? Would you like to see the result? (View ./output/) (Y/n)
𧩠Using Arguments β
You can pass arguments to your iApp using the --args
option. This allows you to provide necessary inputs during runtime (you can use your name for example).
iapp test --args your-name
π Using Protected Data β
You can pass a protectedData that you are authorized to process to your iApp using the --protectedData
option.
Since nothing is actually deployed during testing, we use Protected Data mocks to test the app. Using --protectedData
default will provide your app with the default protectedData mock.
iapp test --protectedData default
You can check how args and protectedData are processed in src/app.js
or src/app.py
π Deploy Your iApp β
Deploy your iApp on the iExec protocol.
Once you have your token, you can deploy your iApp using the following command:
# you need your username and the access token (it can take a few minutes to deploy)
iapp deploy
π Make sure to save your iApp address after deployment - you'll need it later!
You can find your iApp address in the iexec-app.json
file in your project folder.
β οΈ If you encounter issues during deployment, make sure Docker's BuildKit feature is enabled and supports AMD64 architecture:
docker buildx inspect --bootstrap | grep -i platforms
The output should include linux/amd64
in the list of supported platforms. If not, update to the latest Docker Desktop version which includes these requirements.
β οΈ If you set the wrong Docker username, you can change it by editing the iapp.config.json
file
π Run Your iApp β
Now you can run your application:
iapp run <my-iapp-address>
To sum up the process, we take the iApp and wrap it in the iExec framework, allowing it to run securely in a Trusted Execution Environment (TEE) for confidential computing. If you want to explore further, you can check the protocol documentation here.
π Congratulations! You've successfully deployed and run your first iApp on iExec. This is a significant milestone - your application is now ready to securely process confidential data in a trusted environment.
π― Key takeaways β
Next up: Alice will learn how to authorize the iApp and Bob to access and use her protected data! π