Skip to content

rentProtectedData ​

Method to rent a protected data.

Usage ​

ts
const 
rentResult
= await
dataProtectorSharing
.
rentProtectedData
({
protectedData
: '0x123abc...',
price
: 1, // 1 nRLC
duration
: 60 * 60 * 24 * 2, // 172,800 sec = 2 days
});

TIP

Technically, price and duration parameters could be avoided. It is mainly a protection against front-running "attacks", ie. if the collection owner changes the price at the same time you rent the protected data, you would end up paying more than expected. Passing the price here allows the SDK to ensure you're paying the right price. If prices don't match, the SDK will throw an error.

Parameters ​

ts
import { type 
RentProtectedDataParams
} from '@iexec/dataprotector';

protectedData ​

Type: AddressOrENS

Address or ENS of the protected data that you'd like rent.

ts
const 
rentResult
= await
dataProtectorSharing
.
rentProtectedData
({
protectedData
: '0x123abc...',
price
: 1, // 1 nRLC
duration
: 60 * 60 * 24 * 2, // 172,800 sec = 2 days
});

price ​

Type: number

Price of the rental for the protected data that you expect to rent. This parameter ensures that you will not be front-run by the owner of the protected data. The unit is in nano RLC (nRLC).

ts
const 
rentResult
= await
dataProtectorSharing
.
rentProtectedData
({
protectedData
: '0x123abc...',
price
: 1, // 1 nRLC
duration
: 60 * 60 * 24 * 2, // 172,800 sec = 2 days
});

TIP

To get the renting price of the given protected data, you can use getProtectedDataPricingParams.

duration ​

Type: number

Duration of the rental for the protected data that you expect to rent. This parameter ensures that you will not be front-run by the owner of the protected data. The unit is in seconds.

ts
const 
rentResult
= await
dataProtectorSharing
.
rentProtectedData
({
protectedData
: '0x123abc...',
price
: 1, // 1 nRLC
duration
: 60 * 60 * 24 * 2, // 172,800 sec = 2 days
});

TIP

To get the renting duration of the given protected data, you can use getProtectedDataPricingParams.

Return Value ​

ts
import { type 
SuccessWithTransactionHash
} from '@iexec/dataprotector';

See SuccessWithTransactionHash