Renting

This guide explains how to rent an NFT which is listed for rental by a lender.

1. Retrieve Market Contract:

First you need to access to the Market contract:

const contracts = stash.contracts;
const market = contracts.market;

2. Call Rent Function:

To perform the renting operation, you can directly call rent function on the market contract:

market.rent(
          tokenId,
          standard,
                rentDurationInDays,
          (response) => {
            // On success
            // response.transactions[0].txn_hash will give the transactoin hash
            console.log('rent success callback triggered', response);
          },
          (error) => {
            // On error
            console.log('error triggered', error);
          } 
        )

If any error occurs (e.g. user declines approval request or contract call fails) during the process, the error object error contains respective information about the reason of the failure. You can find more information about the error structure under Error Handling section in Integration docs.

If the renting has been successfully performed, then the success callback is called where the response object contains information about the executed transactions.


Next up