bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 12쪽 중 11쪽
ks will be created.
ts
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
maxProtectedDataPerTask
:
50
,
});
workerpool
Optional
Type:
Address | 'any'
Default:
0x8ef2ec3ef9535d4b4349bfec7d8b31a580e60244
It's the confidential computer on which the iExec application will run.
TIP
iExec currently offers a workerpool located at the address
0x8ef2ec3ef9535d4b4349bfec7d8b31a580e60244
. This is the default workerpool for running confidential computations on the iExec platform.
You can specify this during preparation or when processing the bulk request.
ts
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
workerpool
:
'0xa5de76...'
,
});
workerpoolMaxPrice
Optional
Type:
number | undefined
Default:
0
The maximum amount (in nRLC) you are willing to pay the workerpool provider for using their infrastructure to run the application. You can specify this during preparation or when processing the bulk request.
ts
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
workerpoolMaxPrice
:
0.1
*
1e9
,
});
appMaxPrice
Optional
Type:
number | undefined
Default:
0
The maximum amount (in nRLC) you are willing to pay the application provider for using the application.
ts
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
appMaxPrice
:
0.1
*
1e9
,
});
args
Optional
Type:
string | undefined
Set of execution arguments for the application that will be used for all tasks in the bulk request.
ts
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
args
:
'arg1 arg2'
,
});
DANGER
Do not use this to provide any sensitive information to the application. All arguments passed this way are visible in plain text using the
iExec explorer
.
inputFiles
Optional
Type:
string[] | undefined
A set of URLs representing the input files required for application execution. These files will be used for all tasks in the bulk request.
ts
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
inputFiles
: [
'https://example.com/file1'
,
'https://example.com/file2'
],
});
secrets
Optional
Type:
Record<number, string> | undefined
A set of requester secrets necessary for the application's execution. This is represented as a mapping of numerical identifiers to corresponding secrets stored in the secrets manager needed for the application's execution.
Secrets are accessible during the application's execution as environment variables. For more details, see
Access requester secrets
.
ts
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
secrets
: {
1
:
'secret1'
,
2
:
'secret2'
,
},
});
encryptResult
Optional
Type:
boolean | undefined
Default:
false
Enable result encryption for the processed data. If enabled, you'll need to provide the
pemPrivateKey
when processing the bulk request to decrypt the results.
ts
const
{
bulkRequest
,
pemPrivateKey
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
encryptResult
:
true
,
});
pemPrivateKey
Optional
Type:
string | undefined
Private key in PEM format for result encryption/decryption. If not provided and
encryptResult
is
true
, a new key pair will be generated and returned in the response.
ts
const
{
bulkRequest
,
pemPrivateKey
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
encryptResult
:
true
,
pemPrivateKey
:
'-----BEGIN PRIVATE KEY-----
\n
...
\n
-----END PRIVATE KEY-----'
,
});
onStatusUpdate
Optional
Type:
OnStatusUpdateFn<PrepareBulkRequestStatuses>
Callback function to be notified at intermediate steps during bulk request preparation. You can expect this callback function to be called with the following titles:
'PUSH_REQUESTER_SECRET'
- Pushing requester secrets to the SMS
'GENERATE_ENCRYPTION_KEY'
- Generating encryption key pair (if
encryptResult: true
)
'PUSH_ENCRYPTION_KEY'
- Pushing encryption public key to the SMS (if
encryptResult: true
)
'PREPARE_PROTECTED_DATA_BULK'
- Preparing the protected data bulk
'CREATE_BULK_REQUEST'
- Creating the bulk request order
Each status is called once with
isDone: false
, and then with
isDone: true
.
ts
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
onStatusUpdate
: ({
title
,
isDone
})
=>
{
// Handle status updates
},
});
Return Value
ts
import
{
type
PrepareBulkRequestResponse
}
from
'@iexec/dataprotector'
;
bulkRequest
Type:
BulkRequest
The prepared bulk request object that contains all the necessary information to process multiple protected data items together. This object should be passed to
processBulkRequest
to execute the bulk processing.
pemPrivateKey
Type:
string | undefined
The private key in PEM format for result decryption. This is only returned if
encryptResult
was set to
true
when preparing the bulk request. You'll need to provide this key when processing the bulk request if you want to decrypt the results.
ts
// Get granted accesses with bulk capability
const
{
grantedAccess
}
=
await
dataProtectorCore
.
getGrantedAccess
({
bulkOnly
:
true
,
});
// Prepare the bulk request with encryption
const
{
bulkRequest
,
pemPrivateKey
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
encryptResult
:
true
,
});
// Use the bulkRequest and pemPrivateKey to process the bulk request
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
pemPrivateKey
:
pemPrivateKey
,
waitForResult
:
true
,
});
Related Documentation
processBulkRequest Method
- Process a prepared bulk request
grantAccess Method
- Grant access with bulk processing capability
processProtectedData Method
- Process a single protected data item
## /references/dataProtector/methods/processBulkRequest
processBulkRequest
This method processes a bulk request that has been created using the
prepareBulkRequest
method. It executes the bulk processing of multiple protected data items efficiently, creating one or more tasks depending on the number of protected data items and the
maxProtectedDataPerTask
limit.
Prerequisites
Before using this method, make sure you have:
Recipients granted access with bulk processing
: When calling
grantAccess
on the Data Protector SDK, recipients must set
allowBulk: true
Prepared the bulk request
: Use
prepareBulkRequest
to create the bulk request that will be passed to this method
Usage
Browser
NodeJS
ts
import
{
IExecDataProtectorCore
}
from
'@iexec/dataprotector'
;
const
web3Provider
=
window
.
ethereum
;
const
dataProtectorCore
=
new
IExecDataProtectorCore
(
web3Provider
);
// Get granted accesses with bulk capability
const
{
grantedAccess
}
=
await
dataProtectorCore
.
getGrantedAccess
({
bulkOnly
:
true
,
});
// Prepare the bulk request
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
});
// Process the bulk request
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
});
ts
import
{
IExecDataProtectorCore
,
getWeb3Provider
}
from
'@iexec/dataprotector'
;
const
web3Provider
=
getWeb3Provider
(
'PRIVATE_KEY'
,
'RPC_URL'
);
const
dataProtectorCore
=
new
IExecDataProtectorCore
(
web3Provider
);
// Get granted accesses with bulk capability
const
{
grantedAccess
}
=
await
dataProtectorCore
.
getGrantedAccess
({
bulkOnly
:
true
,
});
// Prepare the bulk request
const
{
bulkRequest
}
=
await
dataProtectorCore
.
prepareBulkRequest
({
bulkAccesses
:
grantedAccess
,
app
:
'0x456def...'
,
});
// Process the bulk request
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
});
Parameters
ts
import
{
type
ProcessBulkRequestParams
}
from
'@iexec/dataprotector'
;
bulkRequest
Required *
Type:
BulkRequest
The prepared bulk request object that was created using
prepareBulkRequest
. This object contains all the necessary information to process multiple protected data items together.
ts
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
});
workerpool
Optional
Type:
Address | 'any'
Default:
0x8ef2ec3ef9535d4b4349bfec7d8b31a580e60244
It's the confidential computer on which the iExec application will run.
TIP
iExec currently offers a workerpool located at the address
0x8ef2ec3ef9535d4b4349bfec7d8b31a580e60244
. This is the default workerpool for running confidential computations on the iExec platform.
ts
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
workerpool
:
'0xa5de76...'
,
});
path
Optional
Type:
string | undefined
Under the hood, a protected data is a zip file. With this
path
parameter, you can specify the file you're interested in. The zip file will be uncompressed for you, and only the desired file will be given as the
result
. This applies to all protected data items in the bulk request.
ts
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
path
:
'my-content'
,
});
pemPrivateKey
Optional
Type:
string | undefined
Private key in PEM format for result decryption. Required if
bulkRequest
uses result encryption (when
encryptResult
was set to
true
in
prepareBulkRequest
) and
waitForResult
is
true
.
ts
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
pemPrivateKey
:
pemPrivateKey
,
waitForResult
:
true
,
});
waitForResult
Optional
Type:
boolean | undefined
Default:
false
Whether to wait for the result of the bulk request processing. If
true
, the method will wait for all tasks to complete and return results. If
false
, it will return immediately with task IDs.
ts
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
waitForResult
:
true
,
});
onStatusUpdate
Optional
Type:
OnStatusUpdateFn<ProcessBulkRequestStatuses>
Callback function to be notified at intermediate steps during bulk processing. You can expect this callback function to be called with the following titles:
'FETCH_ORDERS'
- Fetching app and workerpool orders
'CREATE_BULK_TASKS'
- Creating bulk tasks from matched orders
'WAIT_FOR_WORKERPOOL_AVAILABILITY'
- Waiting for workerpool availability (when no workerpool order is available)
'REQUEST_TO_PROCESS_BULK_DATA'
- Requesting to process bulk data (matching orders)
'PROCESS_BULK_SLICE'
- Processing a slice of the bulk request (only when
waitForResult: true
)
'TASK_EXECUTION'
- Task execution in progress (only when
waitForResult: true
)
'TASK_RESULT_DOWNLOAD'
- Downloading task result (only when
waitForResult: true
)
'TASK_RESULT_DECRYPT'
- Decrypting task result (only when
waitForResult: true
and encryption is enabled)
Each status is called once with
isDone: false
, and then with
isDone: true
.
ts
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
onStatusUpdate
: ({
title
,
isDone
,
payload
})
=>
{
// Handle status updates
},
});
Return Value
ts
import
{
type
ProcessBulkRequestResponse
}
from
'@iexec/dataprotector'
;
tasks
Type:
Array<{ taskId: string; dealId: string; bulkIndex: number }>
(when
waitForResult: false
)
Type:
Array<{ taskId: string; dealId: string; bulkIndex: number; success: boolean; status: TaskStatus; result?: ArrayBuffer; error?: Error }>
(when
waitForResult: true
)
An array of task objects created by processing the bulk request. Each task represents a batch of protected data items being processed together.
When
waitForResult: false
(default):
taskId
: A unique identifier for the task
dealId
: Identifies the specific deal associated with this task
bulkIndex
: The index of this task within the bulk request (useful when multiple tasks are created)
When
waitForResult: true
:
taskId
: A unique identifier for the task
dealId
: Identifies the specific deal associated with this task
bulkIndex
: The index of this task within the bulk request
success
: Whether the task completed successfully
status
: The task status (
'COMPLETED' | 'FAILED' | 'TIMEOUT'
)
result
: The task result as an ArrayBuffer (only present if successful)
error
: Error object if the task failed (only present if failed)
ts
const
{
tasks
}
=
await
dataProtectorCore
.
processBulkRequest
({
bulkRequest
:
bulkRequest
,
});
Related Documentation
prepareBulkRequest Method
- Prepare a bulk request for processing
grantAccess Method
- Grant access with bulk processing capability
processProtectedData Method
- Process a single protected data item
getResultFromCompletedTask Method
- Retrieve results from completed tasks
## /references/dataProtector/methods/getResultFromCompletedTask
getResultFromCompletedTask
Method to get the result of a completed task.
Usage
ts
const
completedTaskResult
=
await
dataProtectorCore
.
getResultFromCompletedTask
({
taskId
:
'0x7ac398...'
,
});
Parameters
ts
import
{
type
GetResultFromCompletedTaskParams
}
from
'@iexec/dataprotector'
;
taskId
Required *
Type:
Address
Address of the task ID data you'd like to get the result from.
ts
const
completedTaskResult
=
await
dataProtectorCore
.
getResultFromCompletedTask
({
taskId
:
'0x7ac398...'
,
});
path
Optional
Type:
string
Under the hood, a protected data is a zip file. With this
path
parameter, you can specify the file you're interested in. The zip file will be uncompressed for you, and only the desired file will be given as the
result
.
ts
const
completedTaskResult
=
await
dataProtectorCore
.
getResultFromCompletedTask
({
taskId
:
'0x7ac398...'
,
path
:
'content'
,
});
pemPrivateKey
Optional
Type:
string
If you have previously saved or generated a RSA keypair, you can reuse it in further calls.
It needs to be the private key corresponding to the public key initially used to encrypt the protected data.
ts
const
completedTaskResult
=
await
dataProtectorCore
.
getResultFromCompletedTask
({
taskId
:
'0x7ac398...'
,
pemPrivateKey
:
'-----BEGIN PRIVATE KEY-----
\n
...
\n
-----END PRIVATE KEY-----'
,
});
onStatusUpdate
Optional
Type:
OnStatusUpdateFn<ConsumeProtectedDataStatuses>
Callback function to be notified at intermediate steps.
ts
const
completedTaskResult
=
await
dataProtectorCore
.
getResultFromCompletedTask
({
taskId
:
'0x7ac398...'
,
onStatusUpdate
: ({
title
,
isDone
})
=>
{
console
.
log
(
title
,
isDone
);
},
});
You can expect this callback function to be called with the following titles:
ts
'CONSUME_RESULT_DOWNLOAD'
;
'CONSUME_RESULT_DECRYPT'
;
Once with
isDone: false
, and then with
isDone: true
Return Value
ts
import
{
type
GetResultFromCompletedTaskResponse
}
from
'@iexec/dataprotector'
;
result
ArrayBuffer
The actual content of the protected file.
## /references/dataProtector/types
Types
Types in DataProtector.
GrantedAccess
dataset:
string
Address of the
protectedData
containing user data
datasetprice:
string
Total number of authorized accesses for processing a Protected Data when the access was signed and published
volume:
string
Number of authorized uses of this
protectedData
; each use decrements this counter
remainingAccess:
number
Number of remaining authorized accesses for processing a protected data; each use decrements this counter
tag:
string
Defines whether a
protectedData
is usable in a TEE environment;
0x00
is TEE while
0x03
is non-TEE
apprestrict:
string
Address of the authorized application; a value of 0x0 indicates any application may access this data
requesterrestrict:
string
Address of the requester authorized to use this
protectedData
in workloads; a value of 0x0 indicates any requester may use this data
workerpoolrestrict:
string
Address of the decentralized infrastructure (worker pool) authorized to execute the application; a value of 0x0 indicates any worker pool may access this data
salt:
string
Random value to make an order unique and reusable as nonce in a blockchain transaction
sign:
string
Order signature of all the
grantedAccess
fields
ProtectedData
name:
string
Name specified when the protected data was created. This piece of information is public and visible on-chain.
address:
Address
Ethereum address of the protected data.
owner:
Address
Ethereum address of the protected data owner.
schema:
DataSchema
Data schema for the protected data as defined when the protected data was created (see
protectedData
).
schema
provides a structured representation of the protected data format and attributes. This field plays a crucial role in understanding and interpreting the underlying structure of the sensitive information.
creationTimestamp:
number
Timestamp specifying when the protected data was created, expressed in milliseconds since the epoch. This timestamp provides precise information about the moment of creation and can be used for chronological ordering or time-based operations.
multiaddr:
string
|
undefined
The multiaddr field is the IPFS path of your encrypted data.
RevokedAccess
access:
GrantedAccess
The granted access that was revoked.
txHash:
string
The ID of the transaction that happened on iExec's side chain. You may view details on the transaction using the
iExec explorer
.
Hash example:
0xc9c2d58fc01fe54149b7daf49a0026d4ab1fdd3d10fb7c76350790fff03fe24d
You can read more about the
iExec Explorer
.
SuccessWithTransactionHash
txHash:
string
The hash of the transaction that happened on iExec's side chain. You may view details on the transaction using the
iExec explorer
.
Hash example:
0xc9c2d58fc01fe54149b7daf49a0026d4ab1fdd3d10fb7c76350790fff03fe24d
## /references/dataProtector/advanced-configuration
Advanced Configuration
The
IExecDataProtector
constructor accepts additional configuration parameters. As these parameters are very specific, they are not needed for a standard usage of
@iexec/dataprotector
.
Similarly, not all functionalities need to be instantiated at once in the SDK, as described in the
getting started
section.
Parameters
ts
import
{
type
DataProtectorConfigOptions
}
from
'@iexec/dataprotector'
;
dataprotectorContractAddress
Address
The Ethereum contract address for dataProtector smart contract. If not provided, the default dataProtector contract address will be used.
ts
const
dataProtector
=
new
IExecDataProtector
(
web3Provider
, {
dataprotectorContractAddress
:
'0x123abc...'
,
});
subgraphUrl
string
The subgraph URL for querying data.
If not provided, the default data protector subgraph provided by iExec will be used.
ts
const
dataProtector
=
new
IExecDataProtector
(
web3Provider
, {
subgraphUrl
:
'subgraph-url'
,
});
ipfsNode
string
The IPFS node URL for content uploads. Use this option if you want to use your own IPFS node to upload content.
If not provided, the default IPFS node provided by iExec will be used.
ts
const
dataProtector
=
new
IExecDataProtector
(
web3Provider
, {
ipfsNode
:
'ipfs-node-url'
,
});
ipfsGateway
st프로젝트로 돌아가기