Stash offers an API class which helps in fetching NFT information easily.

Accessing the methods

All Stash contracts included in Stash Renting Protocol are loaded during the initialization of the SDK. Assuming that you have created a Stash object by initializing the SDK, it's possible to access to the contracts through contractsattribute:

Accessing the method is easy and straight forward. Please refer the code below to access the methods:

import { Stash } from "@stash-renting-sdk/core";
const stash = new Stash(<apiKey>, <signer>, <chain>, <nftContracts>);

const contracts = stash.contracts; 
const stashApi = contracts.api;

Calling the NFT fetching method

const apiResult = stashApi.getAsset(contract_address, token_id);

The expected parameters are:

  1. contract_address (string)
  2. token_id (string)

Response Structure

The response from the method would be either an result object or an error defining what went wrong!
The response object will be as follows:

{
  lender_address: 'xxxxx..',
  renter_address: 'xxxxx..', // nullable (if this value is null, it denotes nft is not rented currently)
  rental_id: 'xxxxx..',
  token_id: 'xxxxx..",
  nft_address: 'xxxxx..',
  share_percent: 'xx',
  expiry: 'xx',
  daily_price: 'xx',
  buy_price: 'xx',
  ended: 'x',
  end_date: 'xx-xx-xxxx',
  created_at: 'xx-xx-xxxx'
}