LogoLogo
HomeLaunch App
  • Introduction
  • General Info
    • Rental Use Cases
    • Compatible Blockchains
    • Whitelabel Interface
    • Custom Solutions
    • Protocol Composability
    • Protocol Fee
    • Frequently Asked (FAQ)
  • Rental Solutions
    • Collateral-Free
    • Collateralized
  • Developers
    • Integration Guide
    • SDK
      • @renft/sdk@^v6.0.0
        • Interacting with Smart Contracts
        • Collateral-Free Integration Guide
        • Castle Crush (Reward Share)
      • @renft/sdk@v5.0.4
        • Collateral-Free Integration Guide
        • Castle Crush (Reward Share)
    • reNFT Contracts' Addresses
    • Querying reNFT's on-chain data
      • Castle Crush (Reward Share)
  • Video Tutorials
    • Collateral-Free
      • How To Lend
      • How To Rent
    • Castle Crush (Reward Share)
      • How To Lend
      • How To Rent
    • Collateralized
      • How To Lend
      • How To Rent
      • Returning & Defaulting
    • Expired Rentals
  • About reNFT
    • Team
    • Contact
Powered by GitBook
On this page
  • Lend/Rent NFTs In-App​
  • Batching​
  • Lend
  • Rent​
  • Stop Rent
  • Claim Rent​
  • Stop Lend​
  • Query Loan/Rental Status​
  • Unpacking Data​
  1. Developers
  2. SDK
  3. @renft/sdk@v5.0.4

Collateral-Free Integration Guide

This is a guide on how to use reNFT's SDK to interact with the collateral free contract directly. This tutorial was written for sdk version 5.0.4.

Previous@renft/sdk@v5.0.4NextCastle Crush (Reward Share)

Last updated 2 years ago

The following discussion applies to v5.0.4 of the SDK.

Lend/Rent NFTs In-App

import { Sylvester } from "@renft/sdk";
const renft = new Sylvester(signer);

Any of the following functions support batching as shown below for the Lend instruction where the user lends an AstroCat and a CatPlsr in the same function call:

import { NFTStandard, PaymentToken, packPrice } from "@renft/sdk";

const astroCatLendingArgs = [
  NFTStandard.E1155,
  "0x0db8c099b426677f575d512874d45a767e9acc3c",
  "1",
  1,
  1,
  packPrice("1"),
  PaymentToken.WETH,
];

const catPlsrLendingArgs = [
  NFTStandard.E1155,
  "0x0db8c099b426677f575d512874d45a767e9acc3c",
  "2",
  1,
  1,
  packPrice("0.5"),
  PaymentToken.WETH,
];

const lendingArgs = astroCatLendingArgs.map((value, index) => {
  return [value, catPlsrLendingArgs[index]];
});

await renft.lend(...lendingArgs);

Lend

import { NFTStandard, PaymentToken, packPrice } from "@renft/sdk";

const nftStandard = NFTStandard.E1155;
const nftAddress = "0x0db8c099b426677f575d512874d45a767e9acc3c";
const tokenID = "1";
const lendAmount = 1; // qty of the NFT to lend
const maxRentDuration = 1; // in days
const dailyRentPrice = packPrice("1");
const paymentToken = PaymentToken.WETH;

await renft.lend(
  [nftStandard],
  [nftAddress],
  [tokenID],
  [lendAmount],
  [maxRentDuration],
  [dailyRentPrice],
  [paymentToken]
);
import { NFTStandard } from "@renft/sdk";

const nftStandard = NFTStandard.E1155;
const nftAddress = "0x0db8c099b426677f575d512874d45a767e9acc3c";
const tokenID = "1";
const lendingID = "1"; // this information is pulled from the subgraph
const rentDuration = 1; // in days
const rentAmount = 1;

await renft.rent(
  [nftStandard],
  [nftAddress],
  [tokenID],
  [lendingID],
  [rentDuration],
  [rentAmount]
);

Stop Rent

import { NFTStandard } from "@renft/sdk";

const nftStandard = NFTStandard.E1155;
const nftAddress = "0x0db8c099b426677f575d512874d45a767e9acc3c";
const tokenID = "1";
const lendingID = "1"; // from subgraph
const rentingID = "1"; // from subgraph

await renft.stopRent(
  [nftStandard],
  [nftAddress],
  [tokenID],
  [lendingID],
  [rentingID],
);
import { NFTStandard } from "@renft/sdk";

const nftStandard = NFTStandard.E1155;
const nftAddress = "0x0db8c099b426677f575d512874d45a767e9acc3c";
const tokenID = "1";
const lendingID = "1";
const rentingID = "1";

await renft.claimRent(
  [nftStandard],
  [nftAddress],
  [tokenID],
  [lendingID],
  [rentingID],
);
import { NFTStandard } from "@renft/sdk";

const nftStandard = NFTStandard.E1155;
const nftAddress = "0x0db8c099b426677f575d512874d45a767e9acc3c";
const tokenID = "1";
const lendingID = "1";

await renft.stopLend(
  [nftStandard],
  [nftAddress],
  [tokenID],
  [lendingID],
);

import { PaymentToken, unpackPrice } from "@renft/sdk";

const parsePaymentToken = (tkn: string): PaymentToken => {
  switch (tkn) {
    case "0":
      return PaymentToken.SENTINEL;
    case "1":
      return PaymentToken.WETH;
    case "2":
      return PaymentToken.DAI;
    case "3":
      return PaymentToken.USDC;
    case "4":
      return PaymentToken.USDT;
    case "5":
      return PaymentToken.TUSD;
    default:
      return PaymentToken.DAI;
  }
};

const lendingsDataToLendings = (
  theGraphLendings: TheGraphLending[]
) => {
  const theGraphToLending = (theGraphLending: TheGraphLending) => {
    return {
      lendingID: theGraphLending.id,
      lenderAddress: theGraphLending.lenderAddress,
      dailyRentPrice: unpackPrice(theGraphLending.dailyRentPrice),
      maxRentDuration: Number(theGraphLending.maxRentDuration),
      lendAmount: Number(theGraphLending.lendAmount),
      paymentToken: parsePaymentToken(theGraphLending.paymentToken),
      lentAt: Number(theGraphLending.lentAt),
    };
  };

  return theGraphLendings.map(theGraphToLending);
};

To interact with our smart contract, we'd recommend using our .

The ReNFT object takes in an ethers and an optional contract address if not using the default collateral-free contract.

We name our contracts after famous cats. You can find the name mappings . Sylvester is the code-name for the collateral free contract.

Batching

Rent

Even though no real posession of the NFT is given, the renter must signal that they have concluded "using" the NFT with this call. If the renter fails to do so, then the lender can invoke "Claim Rent" explained below, to redeem the full amount of rent. Note that "Stop Lend" will be blocked until the user calls "Claim Rent" first.

Claim Rent

Stop Lend

Query Loan/Rental Status

To learn about how to learn about the status of a particular lending / rental, read .

Unpacking Data

Prices are returned in a custom format (rationale for this format was to fit the lending into a single storage slot). To unpack them, use our 's unpackPrice function:

SDK
Signer
here
​
​
​
​
​
​
here
​
SDK
​
reNFT collateral-free contract flows