Skip to content

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 ​

ts
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 ​

ts
import { type 
RunIAppParams
} from '@mage-sombre/iapp';

iapp ​

Type: AddressOrENS

The address or ENS of the iApp to execute.

ts
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.

ts
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.

ts
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.

ts
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.

ts
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.

ts
const 
runIAppResponse
= await
iapp
.
runIApp
({
iapp
: '0x456def...',
protectedData
: '0x456def....',
path
: 'my-content',
});

args Optional ​

Type: string

Arguments to pass to the application during execution.

ts
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).

ts
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.

ts
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.

ts
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)

ts
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.

ts
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.

ts
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.

ts
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:

ts
'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 ​

ts
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.