π οΈ 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 using the iExec iApp generator tool. This tool helps you create, test and deploy iApps with just a few commands.
If you wanna explore and deep dive in the CLI. You can check the iapp-cli github repository. Follow the instructions carefully for a smooth development experience.
π Prerequisites β
Before getting started, make sure you have:
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.
π Types of iApps you Can Build β
iExec enables you to build various types of Privacy-preserving applications. Here are some popular use cases:
π§ Web3 Mail β
Send privacy-preserving emails to registered Ethereum account holders without knowing or storing their email addresses. Github | Documentation
π¬ Web3 Telegram β
Send privacy-preserving Telegram messages without knowing or storing their Telegram handles. Github | Documentation
π Content Delivery β
Transfer, sell or rent protected content to authorized users. Github | Documentation
These are just a few examples, the possibilities are endless. Want to explore iApp Generator? Check out our documentation and see what you can build!
πΎ Installation (Win / Mac / Linux) β
First, you need to install the iapp
package. Open your terminal and run:
npm i -g @iexec/iapp
yarn global add @iexec/iapp
pnpm add -g @iexec/iapp
bun add -g @iexec/iapp
You can check if the installation was successful by running:
#checking the version
iapp --version
#checking the available commands
iapp --help
π οΈ Bootstrap your iApp β
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:
_ _ (_) / \ _ __ _ __ | | / _ \ | '_ \| '_ \ | |/ ___ \| |_) | |_) | |_/_/ \_\ .__/| .__/ |_| |_|
We recommend selecting "Hello World" to quickly discover how iApp works! use advanced only if you are familiar with iExec.
- 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 the iapp test
command. This will build a Docker image and run your application locally to simulate the TEE environment. You'll see the following steps:
The iapp test
command uses your local Docker to build and execute the app, simulating how it will run in the iExec network's TEE environment.
Common Issues:
- If you get Error: Docker daemon is not accessible
: Make sure Docker is installed and running.
- If you get Error: Failed to locate iApp project root
: Ensure you are in your project folder before proceeding.
π§© 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.
____ _ | _ \ ___ _ __ | | ___ _ _ | | | |/ _ \ '_ \| |/ _ \| | | | | |_| | __/ |_) | | (_) | |_| | |____/ \___| .__/|_|\___/ \__, | |_| |___/
π 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 β
- π iApps: Special applications that run in TEEs to process protected data
- π οΈ iApp CLI: Command-line tool for building, testing, and deploying iApps
- π Protected Data: Can be integrated and processed securely in your iApp
- βοΈ Deployment: Apps are deployed on iExec protocol to run in trusted environments
Next up: Alice will learn how to authorize the iApp and Bob to access and use her protected data! π