RiFi Resources
  • Welcome
  • Trusted Links
  • Brand Assets
  • WHITEPAPER
    • Introducing Rikkei Finance
    • RiFi DeFi Lending & Borrowing
      • Interest Rate Model
      • Asset Selection
      • Collateral Factor
      • Liquidation
      • Supplying Assets
      • Borrowing Assets
      • RiWork
        • Market Analysis
      • Farming
        • Liquidity Farming
        • TITA Farming Vault
        • Double Farming Vault
        • RiFi Farming Vault
    • RiFi NFT
      • NFT Indexing
      • NFT Rentals
        • Escrow Mode Rentals
        • Transfer Mode Rentals
      • NFT Lending
    • Tokenomics
    • Roadmap
  • User Guides
    • RiFi DeFi Lending & Borrowing
      • Main User Guide
        • Log In To Your Account
        • Supply Assets
        • Borrow Assets
        • Repay Your Borrowing
    • RiFi NFT
      • Log In To Your Account
      • Manage Your Profile
      • Manage Your Account Balance
      • NFT Indexing
        • NFT Indexing Package 1
        • NFT Indexing Packages 2-3-4
      • NFT Rentals
        • Manage NFTs
          • As Asset Owner
          • As Renter
        • Check Your Transaction History
        • List An NFT
        • List Multiple NFTs
        • Rent An NFT (Non-Collateralized Mode)
        • Rent An NFT (Collateralized Mode)
        • Make A Counter Offer
        • Accept A Counter Offer As Asset Owner
        • Reject A Counter Offer As Asset Owner
        • Cancel A Counter Offer As Renter
      • NFT Lending
        • Manage NFTs
          • As Asset Owner
          • As Lender
        • Mint A Vault As Asset Owner
        • Deposit NFTs As Asset Owner
        • Approve To List Or Set Loan Terms As Asset Owner
        • Delist NFTs As Asset Owner
        • Make/Cancel A Counter Offer As Lender
        • Accept/Reject A Counter Offer As Asset Owner
        • Fund Loan As Lender
        • Repay/Roll Over A Loan As Asset Owner
        • Accept/Reject To Extend A Loan As Lender
        • Claim The NFT As Lender
      • Affiliate Partners
  • FAQs
    • RiFi DeFi Lending & Borrowing
    • RiFi NFT
      • NFT Indexing
        • Platform Partners
      • NFT Rentals
        • Affiliate Partners
      • NFT Lending
  • Platform Partners
    • NFT Indexing
    • Integration - Escrow Rental Mode
    • Development Effort Estimation and Timeline
  • Terms & Conditions
    • Terms & Conditions
      • Acceptance
      • Certain Defined Terms and Related Information
      • Eligibility
      • RiFi Account
      • Fees
      • Your Use of the Platform and Conduct
      • Restriction
      • Limitation of Services / Account Closure / Termination
      • Lending & Borrowing Services
      • Data Protection / Privacy
        • Privacy Policy
      • RIFI Token Sale & Usage
        • Acceptance
        • Scope of Terms
        • Warranties
        • Regulations
        • Cancellation & Refusal at Seller's Discretion
        • Partial Invalidity
        • Indemnity
        • Intellectual Property
        • Release
        • Risks
        • Termination
        • Data Privacy
        • Claims
        • Disclaimers
  • Developers
    • Developer Docs
Powered by GitBook
On this page
  • Integration with RiFi NFT Marketplace
  • Contract overview
  • Contract Events
  1. Platform Partners

Integration - Escrow Rental Mode

PreviousNFT LendingNextDevelopment Effort Estimation and Timeline

Last updated 2 years ago

Integration with RiFi NFT Marketplace

When an asset owner lists or de-lists or there is a rental transaction completed (i.e. event) on the NFT Rental Marketplace, smart contract triggers an event emitter for the associated event. Game platform servers need to listen and handle the event emitter appropriately.

You can use library for listing these events. In this document, we have some sample code using

Contract overview

ABI

Please see file abi.json

Address

BSC Testnet: 0xe9D5B350b77D80f6CBe4D2638FA067FEDdB15Ec6

Contract Events

NFTListRental:

    event NFTListRental(
        address indexed nftAddress,
        uint256 indexed tokenId,
        address indexed ownerAddress,
        uint256 minTime,
        uint256 maxTime,
        uint256 pricePerHour,
        uint256 createdAt
    )   

When the asset owner lists the NFT on the marketplace for rental, the event emitter returns these parameters:

  • tokenId : id of nft

  • ownerAddress : the wallet address of the asset owner

  • minTime : minimum rental time (in seconds)

  • maxTime : maximum rental time (in seconds)

  • pricePerHour : rental fee over 1 hour

Sample code to listen for this event emitter:

// In Node.js
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8546');
const lendingNFTContract = new web3.eth.Contract(LENDING_NFT_CONTRACT_ABI, LENDING_NFT_CONTRACT_ADDRESS);
// contract abi and address see above

async function getContractEvent() {
    const pastLentEvents = await lendingNFTContract.getPastEvents('Lent', {
            filter: {
                nftAddress: // your game nft 
            },
			fromBlock: blockNumber,
			toBlock: lastBlockNumber
		});
    for (let i = 0; i < pastLentEvents.length; i++) {
			const event = pastLentEvents[i];
			const { tokenId, lenderAddress, minTime, maxTime, pricePerHour } = event.returnValues;
            // your logic code
	}
}

DelistRental:

    event DelistRental(
        address indexed nftAddress,
        uint256 indexed tokenId,
        uint256 createdAt
    )   

When the asset owner de-lists the NFT from the marketplace for rental, the event emitter returns these parameters:

  • tokenId : id of nft

Sample code to listen for this event emitter:

// In Node.js
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8546');
const lendingNFTContract = new web3.eth.Contract(LENDING_NFT_CONTRACT_ABI, LENDING_NFT_CONTRACT_ADDRESS);
// contract abi and address see above

async function getContractEvent() {
    const pastStoppedEvents = await lendingNFTContract.getPastEvents('DelistRetal', {
            filter: {
                nftAddress: // your game nft 
            },
			fromBlock: blockNumber,
			toBlock: lastBlockNumber
		});
    for (let i = 0; i < pastRentedEvents.length; i++) {
			const event = pastRentedEvents[i];
			const { tokenId } = event.returnValues;
            // your logic code
	}
}

RentalCompleted:

    event RentalCompleted(
        address indexed nftAddress,
        uint256 indexed tokenId,
        address indexed renterAddress,
        uint256 rentDuration,
        uint256 rentedAt,
        uint256 price,
        uint256 createdAt
    )   

When a marketplace user (renter) rents the NFT from the marketplace, the event emitter returns these parameters:

  • tokenId : id of nft

  • renterAddress : renter's wallet address

  • rentDuration : rental time (in seconds)

  • rentedAt : transaction time (timestamp)

Sample code to listen for this event emitter:

// In Node.js
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8546');
const lendingNFTContract = new web3.eth.Contract(LENDING_NFT_CONTRACT_ABI, LENDING_NFT_CONTRACT_ADDRESS);
// contract abi and address see above

async function getContractEvent() {
    const pastRentedEvents = await lendingNFTContract.getPastEvents('RentalCompleted', {
            filter: {
                nftAddress: // your game nft 
            },
			fromBlock: blockNumber,
			toBlock: lastBlockNumber
		});
    for (let i = 0; i < pastRentedEvents.length; i++) {
			const event = pastRentedEvents[i];
			const { tokenId, renterAddress, rentDuration, rentedAt } = event.returnValues;
            // your logic code
	}
}

RentalReturn:

    event RentalReturn(
        address indexed nftAddress,
        uint256 indexed tokenId,
        address indexed ownerAddress,
        address renterAddress,
        uint256 createdAt
    )  

When the renter returns the NFT to the marketplace, the event emitter returns these parameters:

  • tokenId : id of nft

Sample code for get this event:

// In Node.js
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8546');
const lendingNFTContract = new web3.eth.Contract(LENDING_NFT_CONTRACT_ABI, LENDING_NFT_CONTRACT_ADDRESS);
// contract abi and address see above

async function getContractEvent() {
    const pastReturnEvents = await lendingNFTContract.getPastEvents('RentalReturn', {
            filter: {
                nftAddress: // your game nft 
            },
			fromBlock: blockNumber,
			toBlock: lastBlockNumber
		});
    for (let i = 0; i < pastRentedEvents.length; i++) {
			const event = pastRentedEvents[i];
			const { tokenId } = event.returnValues;
            // your logic code
	}
}
web3.js
web3.js