runIApp
Allows executing an iApp with optional protected data processing.
IMPORTANT
You must ensure the iApp has authorization to use the protectedData
if provided. You may grant this permission using the grantAccess
method.
Usage
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
args: 'arg1 arg2',
inputFiles: ['https://example.com/file1', 'https://example.com/file2'],
secrets: {
1: 'secret1',
2: 'secret2',
},
dataMaxPrice: 10,
appMaxPrice: 5,
workerpoolMaxPrice: 2,
});
Parameters
import { type RunIAppParams } from '@mage-sombre/iapp';
iapp
Type: AddressOrENS
The address or ENS of the iApp to execute.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
});
protectedData Optional
Type: AddressOrENS
The address or ENS of the authorized protected data that the iApp will process.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
});
dataMaxPrice Optional
Type: number
Default: 0
The maximum price of dataset per task for processing the protected data.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
dataMaxPrice: 10,
});
appMaxPrice Optional
Type: number
Default: 0
The maximum price of application per task for processing the protected data.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
appMaxPrice: 5,
});
workerpoolMaxPrice Optional
Type: number
Default: 0
The maximum price of workerpool per task for processing the protected data.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
workerpoolMaxPrice: 2,
});
path Optional
Type: string
The file name of the desired file in the returned ZIP file.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
path: 'my-content',
});
args Optional
Type: string
Arguments to pass to the application during execution.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
args: 'arg1 arg2',
});
inputFiles Optional
Type: string[]
The input file required for the application's execution (direct download URL).
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
inputFiles: ['https://example.com/file1', 'https://example.com/file2'],
});
secrets Optional
Type: Record<number, string>
Requester secrets necessary for the application's execution. It is represented as a mapping of numerical identifiers to corresponding secrets.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
secrets: {
1: 'secret1',
2: 'secret2',
},
});
callbackContract Optional
Type: AddressOrENS
Address or ENS of the smart contract to be called back once the task is completed.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
callbackContract: '0x789ghi...',
});
workerpool Optional
Type: AddressOrENS
The workerpool to use for the application's execution. (default iExec production workerpool)
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
workerpool: '0xabc123...',
});
useVoucher Optional
Type: boolean
A boolean that indicates whether to use a voucher or no.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
useVoucher: true,
});
voucherOwner Optional
Type: AddressOrENS
Override the voucher contract to use, must be combined with useVoucher: true the user must be authorized by the voucher's owner to use it.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
useVoucher: true,
voucherOwner: '0xdef456...',
});
onStatusUpdate Optional
Type: OnStatusUpdateFn<RunIAppStatuses>
Callback function to be notified at intermediate steps.
const runIAppResponse = await iapp.runIApp({
iapp: '0x456def...',
protectedData: '0x456def....',
onStatusUpdate: ({ title, isDone }) => {
console.log(title, isDone);
},
});
You can expect this callback function to be called with the following titles:
'FETCH_ORDERS';
'FETCH_PROTECTED_DATA_ORDERBOOK';
'FETCH_APP_ORDERBOOK';
'FETCH_WORKERPOOL_ORDERBOOK';
'PUSH_REQUESTER_SECRET';
'REQUEST_TO_RUN_IAPP';
'CONSUME_TASK';
'CONSUME_RESULT_DOWNLOAD';
'CONSUME_RESULT_DECRYPT';
Once with isDone: false
, and then with isDone: true
Return Value
import { type RunIAppResponse } from '@mage-sombre/iapp';
The method returns a RunIAppResponse
object containing the following fields:
txHash
string
The transaction hash of the task creation transaction.
dealId
string
The deal ID associated with the task execution.
taskId
string
The task ID for tracking the execution.
result
ArrayBuffer
(optional)
The result of the iApp execution, if available.