Retrieving Listed Assets

Stash API offers an API endpoint for fetching the list of all the assets that are lent to Stash with a specific contract address.

You can call getAssets function under api object of the core class to make the API call. This function has following declaration, parameters and response:

Declaration

async getAssets(contractAddress: string, availableForRental: boolean)

Parameters

  • contractAddress: Address of the NFT contract which the queried assets belong to
  • availableForRental: A boolean value indicating whether all the assets or only the ones that are available for rental (Not currently rented by anyone) should be listed

Example Usage

const assets = stash.api.getAssets("0x0493kdffE92m34kS29lI1942EdaW21", false);

Sample Response

[
    {
    "lender_address":"0x003",
    "renter_address":"0x002",
    "rental_id":1,
    "token_id":123456,
    "nft_address":"0x001",
    "share_percent":3,
    "expiry":5,
    "daily_price":0.5,
    "buy_price":10.0,
    "ended":false,
    "created_at":"2022-09-15T05:24:58+0000"
    },
  {
    "lender_address":"0x005",
    "renter_address":null,
    "rental_id":2,
    "token_id":333333,
    "nft_address":"0x001",
    "share_percent":10,
    "expiry":7,
    "daily_price":1.5,
    "buy_price":100.0,
    "ended":false,
    "created_at":"2022-09-16T02:14:15+0000"
    },
  {
    "lender_address":"0x007",
    "renter_address":"0x009",
    "rental_id":3,
    "token_id":444444,
    "nft_address":"0x001",
    "share_percent":5,
    "expiry":50,
    "daily_price":0.75,
    "buy_price":25.0,
    "ended":false,
    "created_at":"2022-09-17T07:42:32+0000"
    }
]

Next up