📥 Run iApp without a ProtectedData
When an iApp requires additional data or parameters to function, you can provide various types of inputs to customize its behavior and enable processing. This guide covers all the different ways to run an iApp with inputs using the DataProtector turnkey toolkit.
Possible Inputs
iExec supports several types of inputs for iApp executions:
- Arguments: Command-line arguments passed to the application
- Input Files: URLs to public files that the app can download
- Secrets: Sensitive data like API keys stored securely
Adding Command-Line Arguments
Command-line arguments are passed as a string to the iApp and are visible on the blockchain.
ts
// Basic arguments
const requestorderToSign = await iexec.order.createRequestorder({
app: '0x456def...',
category: 0,
appmaxprice: 10,
workerpool: '0xa5de76...', // ENS address for iExec's debug workerpool
params: 'arg1 arg2 arg3', // Command-line arguments
// Other parameters have default values
});
const requestOrder = await iexec.order.signRequestorder(requestorderToSign);
// Fetch app orders
const appOrders = await iexec.orderbook.fetchAppOrderbook(
'0x456def...' // Filter by specific app
);
if (appOrders.orders.length === 0) {
throw new Error('No app orders found for the specified app');
}
// Fetch workerpool orders
const workerpoolOrders = await iexec.orderbook.fetchWorkerpoolOrderbook({
workerpool: '0xa5de76...', // Filter by specific workerpool
});
if (workerpoolOrders.orders.length === 0) {
throw new Error('No workerpool orders found for the specified workerpool');
}
// Execute the task
const taskId = await iexec.order.matchOrders({
requestorder: requestOrder,
apporder: appOrders.orders[0].order,
workerpoolorder: workerpoolOrders.orders[0].order,
});
Adding Input Files
Input files are URLs to public files that the iApp can download during execution.
ts
// Single input file
const requestorderToSign = await iexec.order.createRequestorder({
app: '0x456def...',
category: 0, // Required: category for the request
appmaxprice: 10,
workerpool: '0xa5de76...', // ENS address for iExec's debug workerpool
params: {
iexec_input_files: [
'https://example.com/config.json',
'https://example.com/template.html',
'https://example.com/data.csv',
],
},
});
const requestOrder = await iexec.order.signRequestorder(requestorderToSign);
// Fetch app orders
const appOrders = await iexec.orderbook.fetchAppOrderbook(
'0x456def...' // Filter by specific app
);
if (appOrders.orders.length === 0) {
throw new Error('No app orders found for the specified app');
}
// Fetch workerpool orders
const workerpoolOrders = await iexec.orderbook.fetchWorkerpoolOrderbook({
workerpool: '0xa5de76...', // Filter by specific workerpool
});
if (workerpoolOrders.orders.length === 0) {
throw new Error('No workerpool orders found for the specified workerpool');
}
// Execute the task
const taskId = await iexec.order.matchOrders({
requestorder: requestOrder,
apporder: appOrders.orders[0].order,
workerpoolorder: workerpoolOrders.orders[0].order,
});
Adding Secrets
Secrets are sensitive data like API keys, passwords, or tokens that are stored securely and made available to the iApp as environment variables.
ts
// Basic secrets
const requestorderToSign = await iexec.order.createRequestorder({
app: '0x456def...',
category: 0, // Required: category for the request
appmaxprice: 10,
workerpool: '0xa5de76...', // ENS address for iExec's debug workerpool
params: {
iexec_secrets: {
1: 'api-key-12345',
2: 'database-password',
},
},
});
const requestOrder = await iexec.order.signRequestorder(requestorderToSign);
// Fetch app orders
const appOrders = await iexec.orderbook.fetchAppOrderbook(
'0x456def...' // Filter by specific app
);
if (appOrders.orders.length === 0) {
throw new Error('No app orders found for the specified app');
}
// Fetch workerpool orders
const workerpoolOrders = await iexec.orderbook.fetchWorkerpoolOrderbook({
workerpool: '0xa5de76...', // Filter by specific workerpool
});
if (workerpoolOrders.orders.length === 0) {
throw new Error('No workerpool orders found for the specified workerpool');
}
// Execute the task
const taskId = await iexec.order.matchOrders({
requestorder: requestOrder,
apporder: appOrders.orders[0].order,
workerpoolorder: workerpoolOrders.orders[0].order,
});
Next Steps
Now that you understand how to add inputs to iApp executions: