rentProtectedData
Method to rent a protected data.
Usage
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
import { type RentProtectedDataParams } from '@iexec/dataprotector';
protectedData Required *
Type: AddressOrENS
Address or ENS of the protected data that you'd like rent.
const rentResult = await dataProtectorSharing.rentProtectedData({
protectedData: '0x123abc...',
price: 1, // 1 nRLC
duration: 60 * 60 * 24 * 2, // 172,800 sec = 2 days
});
price Required *
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).
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 Required *
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.
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
import { type SuccessWithTransactionHash } from '@iexec/dataprotector';