Skip to content

Commit 889b382

Browse files
committed
docs: Enhance iApp execution guide with structured methods and code examples
- Added a new section outlining when to use each execution method: iApp Generator CLI, iExec Library, and iExec CLI. - Introduced detailed code examples for using the iExec SDK Library and iExec CLI for executing iApps. - Improved overall organization and clarity of the guide to assist users in selecting the appropriate execution method.
1 parent 1c8d83f commit 889b382

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

src/guides/use-iapp/run-iapp.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ There are multiple ways to execute an iApp on the iExec network. An iApp can be:
1616
This guide covers the basic execution methods. For advanced features like
1717
protected data, arguments, and input files, see the dedicated guides.
1818

19-
## Using the iApp Generator CLI
19+
## When to Use Each Method
20+
21+
- **iApp Generator CLI**: For developers who have built their own iApp
22+
- **iExec Library**: For JavaScript applications and web3 integration
23+
- **iExec CLI**: For quick testing and automation scripts
24+
25+
## Method 1: Using the iApp Generator CLI
2026

2127
The iApp Generator CLI provides a streamlined way to execute iApp, especially
2228
for developers who have built their own iApp.
@@ -50,6 +56,61 @@ for developers who have built their own iApp.
5056
/>
5157
</template>
5258

59+
## Method 2: Using the iExec SDK Library
60+
61+
The iExec SDK provides a modular JavaScript interface for executing iApp.
62+
63+
```ts twoslash
64+
import { IExec, utils } from 'iexec';
65+
66+
const ethProvider = utils.getSignerFromPrivateKey(
67+
'bellecour', // blockchain node URL
68+
'PRIVATE_KEY'
69+
);
70+
const iexec = new IExec({
71+
ethProvider,
72+
});
73+
// ---cut---
74+
// Create & Sign a request order
75+
const requestorderToSign = await iexec.order.createRequestorder({
76+
app: '0x456def...', // The iApp address
77+
category: 0,
78+
});
79+
const requestOrder = await iexec.order.signRequestorder(requestorderToSign);
80+
81+
// Fetch app orders
82+
const appOrders = await iexec.orderbook.fetchAppOrderbook(
83+
'0x456def...' // Filter by specific app
84+
);
85+
if (appOrders.orders.length === 0) {
86+
throw new Error('No app orders found for the specified app');
87+
}
88+
89+
// Fetch workerpool orders
90+
const workerpoolOrders = await iexec.orderbook.fetchWorkerpoolOrderbook({
91+
workerpool: '0xa5de76...', // Filter by specific workerpool
92+
});
93+
if (workerpoolOrders.orders.length === 0) {
94+
throw new Error('No workerpool orders found for the specified workerpool');
95+
}
96+
97+
// Execute the task
98+
const taskId = await iexec.order.matchOrders({
99+
requestorder: requestOrder,
100+
apporder: appOrders.orders[0].order,
101+
workerpoolorder: workerpoolOrders.orders[0].order,
102+
});
103+
```
104+
105+
## Method 3: Using the iExec CLI
106+
107+
The iExec CLI is perfect for quick executions and automation scripts.
108+
109+
```bash
110+
# Execute an iApp
111+
iexec app run 0x456def...
112+
```
113+
53114
## Next Steps
54115

55116
- Discover how to

0 commit comments

Comments
 (0)