Skip to content

Commit 332e7ad

Browse files
authored
feat: build iapp by martin (#15)
2 parents 33613a1 + 4de4349 commit 332e7ad

File tree

11 files changed

+348
-187
lines changed

11 files changed

+348
-187
lines changed

.vitepress/sidebar.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ export function getSidebar() {
345345
text: '📖 Guides',
346346
items: [
347347
{
348-
text: 'Manage Your iApps',
348+
text: 'Build and Deploy your iApps',
349+
link: '/build-iapp/guides/build-&-deploy-iapp',
350+
},
351+
{
352+
text: 'Manage your iApps',
349353
link: '/build-iapp/guides/manage-iapp',
350354
},
351355
{

src/build-iapp/guides/ai-frameworks.md

Whitespace-only changes.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: Build and Deploy an iApp?
3+
description:
4+
How to build an confidential iexec application and deploy it on iexec protocol
5+
---
6+
7+
## iApp Generator: Your Development Tool
8+
9+
Bootstrap TEE-compatible applications in minutes without any hardcoding skills,
10+
iApp Generator handles all the low-level complexity for you.
11+
12+
- **Access to TEEs easily** - No need to dive into low-level requirements, build
13+
iApps that connect to TEEs in minutes.
14+
- **Check and deploy iApps quickly** - iApp Generator checks that your iApp
15+
complies with the iExec Framework and streamlines its deployment.
16+
- **Select your project mode & language** - Get started with either a basic or
17+
advanced setup, depending on your experience with the iExec framework. You can
18+
use Python or JavaScript—whichever you prefer!
19+
20+
```bash
21+
# Create your iApp (Python or Node.js supported)
22+
iapp init my-privacy-app
23+
cd my-privacy-app
24+
25+
# Develop and test locally (simulates TEE environment)
26+
iapp test
27+
# Deploy to the network
28+
iapp deploy
29+
```
30+
31+
<div class="bg-gradient-to-r from-blue-400/10 to-blue-400/5 rounded-[6px] p-4 border-l-4 border-blue-600 mb-6">
32+
<p class="m-0! text-sm"><strong>Note:</strong> iApp Generator currently supports Python and Node.js, but iApps can be built in any language that runs in Docker.</p>
33+
</div>
34+
35+
## Real Examples
36+
37+
Here are some real-world examples of iApps to help you understand how they work
38+
in practice.
39+
40+
**Email Notification iApp**
41+
42+
This iApp lets you send updates to your contacts without ever seeing their email
43+
addresses, privacy is preserved by design.
44+
45+
::: code-group
46+
47+
```python [Python]
48+
# User runs: "Send updates to my contacts about my project"
49+
contacts = load_protecteddata() # User's protected contact list
50+
for contact in contacts:
51+
send_email(contact, project_update_message)
52+
# → Emails sent directly, you never see the addresses
53+
```
54+
55+
```js [Node.js]
56+
/* User runs: "Send updates to my contacts about my project" */
57+
const contacts = loadProtectedData(); // User's protected contact list
58+
contacts.forEach((contact) => {
59+
sendEmail(contact, projectUpdateMessage);
60+
});
61+
// → Emails sent directly, you never see the addresses
62+
```
63+
64+
:::
65+
66+
**Oracle Update iApp**
67+
68+
This iApp securely updates a price oracle using private trading data, ensuring
69+
sensitive information stays confidential.
70+
71+
::: code-group
72+
73+
```python [Python]
74+
# User runs: "Update price oracle with my private trading data"
75+
trading_data = load_protecteddata() # User's protected trading history
76+
average_price = calculate_weighted_average(trading_data)
77+
update_oracle_contract(average_price)
78+
# → Oracle updated with real data, trading history stays private
79+
```
80+
81+
```js [Node.js]
82+
/* User runs: "Update price oracle with my private trading data" */
83+
const tradingData = loadProtectedData(); // User's protected trading history
84+
const averagePrice = calculateWeightedAverage(tradingData);
85+
updateOracleContract(averagePrice);
86+
// → Oracle updated with real data, trading history stays private
87+
```
88+
89+
:::
90+
91+
**Automated Transactions iApp**
92+
93+
This iApp automates monthly payments using protected payment details, so
94+
financial information remains private.
95+
96+
::: code-group
97+
98+
```python [Python]
99+
# User runs: "Automate payments every month"
100+
payment_info = load_protecteddata() # User's payment details
101+
for month in range(12):
102+
process_payment(payment_info)
103+
# → Payments processed, payment details stay private
104+
```
105+
106+
```js [Node.js]
107+
/* User runs: "Automate payments every month" */
108+
const paymentInfo = loadProtectedData(); // User's payment details
109+
for (let month = 0; month < 12; month++) {
110+
processPayment(paymentInfo);
111+
}
112+
// → Payments processed, payment details stay private
113+
```
114+
115+
:::

src/build-iapp/guides/debugging-your-iapp.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ with open(f"{os.environ['IEXEC_OUT']}/computed.json", 'w') as f:
112112
json.dump(computed, f)
113113
```
114114

115+
### ⚠️ **Dataset type unmatching**
116+
117+
- **Cause**: The dataset type specified in the frontend (protectData) does not
118+
match with the dataset type specified in the iApp
119+
- **Solution**: Check both dataset types
120+
115121
## Best Practices
116122

117123
### 🔍 **Input Validation**

src/build-iapp/guides/inputs-and-outputs.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -275,23 +275,6 @@ environment.
275275
**When to use:** Processing user's sensitive information like personal data,
276276
financial records, health data.
277277

278-
### How Users Provide Protected Data
279-
280-
Users specify the protected data address when executing your iApp:
281-
282-
```ts twoslash
283-
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
284-
285-
const web3Provider = getWeb3Provider('PRIVATE_KEY');
286-
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
287-
// ---cut---
288-
// User provides their protected data for processing
289-
const response = await dataProtectorCore.processProtectedData({
290-
protectedData: '0x123abc...', // Address of their protected data
291-
app: '0x456def...', // Your iApp address
292-
});
293-
```
294-
295278
### How to Access Protected Data
296279

297280
Protected data is available in the `IEXEC_IN` directory as decrypted files:
@@ -345,6 +328,23 @@ try {
345328

346329
:::
347330

331+
### How Users Provide Protected Data
332+
333+
Users specify the protected data address when executing your iApp:
334+
335+
```ts twoslash
336+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
337+
338+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
339+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
340+
// ---cut---
341+
// User provides their protected data for processing
342+
const response = await dataProtectorCore.processProtectedData({
343+
protectedData: '0x123abc...', // Address of their protected data
344+
app: '0x456def...', // Your iApp address
345+
});
346+
```
347+
348348
### Working with Multiple Protected Datasets
349349

350350
When multiple datasets are provided, they're available as separate files:

src/build-iapp/guides/manage-iapps.md

Whitespace-only changes.

src/build-iapp/guides/orders.md

Whitespace-only changes.

src/build-iapp/guides/other-emerging-trends.md

Whitespace-only changes.

src/build-iapp/guides/using-tdx-experimental.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ technology, different from the default SGX implementation.
3838
-**Limited worker availability**
3939
-**Not production ready**
4040

41+
| Feature | Intel SGX | Intel TDX |
42+
| ------------------------ | ----------------------------------------------------------------------------------- | -------------------------------------------- |
43+
| Release Year | 2015 | 2023 |
44+
| Enclave Scope | Application level | Virtual machine level |
45+
| Code Adaptation Required | Yes - needs redesign of app's logic | No - supports lift-and-shift of full systems |
46+
| Memory Size | Limited | Extensive (multi-GB+) |
47+
| Integration Complexity | Higher (more dev work) | Lower (VM legacy code) |
48+
| Best Fit For | Lightweight, high-assurance modules (e.g. wallets, crypto key ops, small AI models) | Heavier AI workloads, legacy apps, databases |
49+
4150
## Enabling TDX in iApp Generator
4251

4352
### Environment Variable Method
@@ -53,6 +62,15 @@ iapp deploy
5362
iapp run <app-address>
5463
```
5564

65+
:::warning Environment Variable Declaration
66+
67+
The syntax for setting environment variables differs between operating systems:
68+
69+
- **Mac/Linux**: `export EXPERIMENTAL_TDX_APP=true`
70+
- **Windows**: `set EXPERIMENTAL_TDX_APP=true`
71+
72+
:::
73+
5674
### Per-Command Method
5775

5876
**Enable TDX for specific commands**:
@@ -77,6 +95,30 @@ EXPERIMENTAL_TDX_APP=true iapp debug <taskId>
7795
iexec app show <app-address>
7896
```
7997

98+
###
99+
100+
⚠️ **To use** the iExec DataProtector SDK with TDX support, you must configure
101+
the SDK with the right SMS endpoint.
102+
103+
```jsx
104+
const dataProtector = new IExecDataProtector(web3Provider, {
105+
iexecOptions: {
106+
smsURL: 'https://sms.labs.iex.ec',
107+
},
108+
});
109+
```
110+
111+
⚠️**You need** to change the default worker pool in your protected Data
112+
declaration
113+
114+
```jsx
115+
await dataProtector.core.processProtectedData({
116+
protectedData: protectedData.address,
117+
workerpool: 'tdx-labs.pools.iexec.eth',
118+
app: '0x1919ceb0c6e60f3B497936308B58F9a6aDf071eC',
119+
});
120+
```
121+
80122
## Protected Data Compatibility
81123

82124
:::warning Protected Data Requirements

src/build-iapp/iapp-generator/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Before using the iApp Generator, make sure you have:
66

77
\- [**Node.js**](https://nodejs.org/en/) version 20 or higher
88

9-
\- **Docker**
9+
\- **Docker / Docker hub account**
1010

1111
\- **Docker Buildx** _(for macOS users, check AMD64 compatibility)_
1212

0 commit comments

Comments
 (0)