NFTs identification and access

1. Identify Rentero NFT

When the user logs into the game platform, the system should identify and display the NFTs normally held by the user, and identify and display the NFTs rented by the user under Rentero Protocol through SDK.

getRentNFTsByAddress: acquire the NFTs rented by the user, as follows:

import { RenteroNFT } from '@rentero/sdk-js'

const nftAddress = '0x80b4a4da97d676ee139bada2bf757b7f5afd0644'
const renterAddress = '0x431b4ca18e269fc7e1f5af49b9f4e2af683f6207'

// pass in the blockchain network and NFT contracts, instantiate the object
const renteroNFT = new RenteroNFT('ropsten', [nftAddress])

// query renter‘s NFTs
const result = await renteroNFT.getRentNFTsByAddress(renterAddress)

// result example
{
  leases: [
    {
      tokenId: '341',
      nftAddress: '0x80b4a4da97d676ee139bada2bf757b7f5afd0644',
      lender: '0x576687d59d191a9b20110fb3e126dbf27d8e42e0',
      expires: '1660638300'
    }
		...
  ]
}

Note: At present, SDK only provides the basic information of NFTs rented by users, and the NFT metadata required for display needs to be acquired by game developers.

2. Obtain the expires of NFTs

Before starting a game, the user needs to obtain the expires of NFTs to check whether NFTs support the current game and whether there is a reminder of expiration.

getRentInfoById: obtain NFT rental information, as follows:

import { RenteroNFT } from '@rentero/sdk-js'

const nftAddress = '0x80b4a4da97d676ee139bada2bf757b7f5afd0644'
const renterAddress = '0x431b4ca18e269fc7e1f5af49b9f4e2af683f6207'

// pass in the blockchain network and NFT contracts, instantiate the object
const renteroNFT = new RenteroNFT('ropsten', [nftAddress])

// query renter‘s NFTs
const result = await renteroNFT.getRentNFTsByAddress(renterAddress)

// result example
{
  leases: [
    {
      tokenId: '341',
      nftAddress: '0x80b4a4da97d676ee139bada2bf757b7f5afd0644',
      lender: '0x576687d59d191a9b20110fb3e126dbf27d8e42e0',
      expires: '1660638300'
    }
		...
  ]
}

The game platform needs to check the NFT rental status and expires regularly.

Exceptional cases

  • In very few scenes that Lender redeems an NFT in advance when the user is in the game, the user will lose the right to use the NFT in the game. The game developer needs to deal with it.

3. Settle NFT rental income

From the perspective of product function, the income from use of NFTs by users should be consistent with that from normally held NFTs in both behaviors and results. In income calculation and withdrawal, Renter’s wallet address should be confirmed. The income needs to be transferred to Renter’s wallet address normally, regardless of regular payment by the game developer or withdrawal by users.

★ The above logic should be adjusted and supported by the game developer based on its own income settlement logic.

Last updated