@renft/sdk
TypeScript icon, indicating that this package has built-in type declarations

6.0.0-alpha.11 • Public • Published

ReNFT is a multi-chain highly gas-optimised NFT rental protocol and platform that can be whitelabel integrated into any project to enable collateral-free in-house renting, lending, and reward share (scholarship automation).

renft-cat

ReNFT - A leading multi-chain NFT rental protocol.

Package version License Minified Size Monthly Downloads

Install

yarn add @renft/sdk

Usage

The below is a simple example of lending an ERC721, note that the amount is ignored, you will always lend 1 unit of ERC721 token.

If you are having any issues with the below code, go here and ensure your dependencies for ethersproject are the same as ours (in package.json).

You might be wondering what 'AZRAEL' refers to in the below import. If so, go to our docs here. Azrael, Sylvester and Whoopi are our naming conventions to refer to different versions of our contracts.

import { JsonRpcProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { DEPLOYMENT_AZRAEL_ETHEREUM_MAINNET_V0, PaymentToken, getRenftContract } from '@renft/sdk';

// const walletMnemonic = Wallet.fromMnemonic(`<your mnemonic>`);
const provider = new JsonRpcProvider('<your provider uri>');
const privKey = '<privateKey>';
let wallet = new Wallet(privKey);
wallet = wallet.connect(provider);

const main = async () => {
  const renft = getRenftContract({
    deployment: DEPLOYMENT_AZRAEL_ETHEREUM_MAINNET_V0,
    signer: wallet,
  });

  const nftAddress = ['0xCDf60B46Fa88e74DE7e1e613325E386BFe8609ad'];
  const tokenId = ['3'];
  const lendAmount = [1]; // for ERC721, this is ignored
  const maxRentDuration = [1];  // in days (can be returned earlier)
  const dailyRentPrice = [1.1]; // this will automatically scale
  const nftPrice = [2.2]; // this will automatically scale
  const paymentToken = [PaymentToken.WETH];

  const txn = await renft.lend(
    nftAddress,
    tokenId,
    lendAmount,
    maxRentDuration,
    dailyRentPrice,
    nftPrice,
    paymentToken
  );

  const receipt = await txn.wait();
  return receipt;
};

main()
  .then(receipt => {
    console.log(receipt);
  })
  .catch(e => {
    console.warn(e);
  });

For more usage examples, see test and examples folders on our github repo.

Please, also take the time to familiarise yourself with our docs.

Deploying New SDK versions

Make sure the CHANGELOG.md is updated accordingly!

Create a utility shell scripts for deploys locally like the one below:

#!/bin/bash
set -e
yarn build
yarn publish

make sure to make it executable:

chmod +x deploy.sh

Install

npm i @renft/sdk

DownloadsWeekly Downloads

160

Version

6.0.0-alpha.11

License

MIT

Unpacked Size

722 kB

Total Files

52

Last publish

Collaborators

  • nazariyv