npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stream-nft-sdk

v1.1.10

Published

This SDK provides an extension to integrate the STREAM NFT (https://www.streammoney.finance/) smart contract to your application. STREAM NFT is an on-chain "solana" smart contract that enables the real-time borrowing/renting of NFTs. ```js import { quer

Downloads

9

Readme

STREAM NFT

This SDK provides an extension to integrate the STREAM NFT (https://www.streammoney.finance/) smart contract to your application. STREAM NFT is an on-chain "solana" smart contract that enables the real-time borrowing/renting of NFTs.

import {
  queryTokenState,
  config,
  sendTransaction,
  withdrawTx,
  rentTx,
  initNFTEscrowTx,
  findAssociatedTokenAddress,
  cancelEscrowTx,
  getWalletTokens,
  QueryWalletTokensStatus,
  getAllListedTokens,
} from "stream-nft-sdk";

STREAM NFT flow consists of 5 major flows: Initialize, Rent, Withdraw, Cancel, Query

Initialize :

Initializes NFT on STREAM NFT protocol, making it available for users to browse and rent.

initNFTEscrowTx({
    owner: Wallet, // owner's wallet which implements wallet interface  
    token, // PublicKey of the NFT to be rented
    rate: BigNumber // rate in lamports/s,
    minBorrowTime: BigNumber // mininum time for borrow (in Seconds),
    maxBorrowTime: BigNumber // maximum time for borrow (in Seconds),
    connection,
    newAccount: PublicKey //new temp account for transfering ownership to PDA (TO BE DEPRECATED),
    ownerTokenAccount: await findAssociatedTokenAddress(
      wallet.publicKey,
      token
    ),
    programId: config.DEVNET_PROGRAM_ID, // program addresses are available in config
  });

Borrow :

Users can borrow the NFT utility adhering to the contract constraints of rate, min_duration, and max_duration. This is will change the contract state, changing conditional ownership to the borrower.

rentTx({
    borrower: Wallet, // borrower's wallet which implements wallet interface
	token, // PublicKey of the NFT to be borrowed
    programId: config.DEVNET_PROGRAM_ID,
    amount: BigNumber // amount borrower is willing to pay (time * rate)[lamports],
    time: BigNumber // time borrower wants to borrow the NFT for (in Seconds),
    connection,
  });

Withdraw :

As per the duration set by the user, the NFT utility would expire. NFT could be withdrawn by anyone upon expiration, and get incentivised. This flow returns NFT back to the available state for renting.

withdrawTx({
    token, // PublicKey of the NFT to be withdrawn
    programId: config.DEVNET_PROGRAM_ID,
    connection,
  });

Cancel :

NFT owners can cancel the smart contract, thus claiming back the ownership of NFT. This closes the temporary PDA and settles all PDA balances to the owner.

cancelEscrowTx({
    owner: Wallet, // owner's wallet which implements wallet interface  
    token, // PublicKey of the NFT to be remove from listing
    programId: config.DEVNET_PROGRAM_ID,
    connection,
    ownerTokenAddress: await findAssociatedTokenAddress(
      wallet.publicKey,
      token
    ),
  });

Query :

Any service/user can invoke the query function to get the current on-chain PDA state for a provided NFT.

queryTokenState({
    programId: config.DEVNET_PROGRAM_ID,
    tokenAddress: PublicKey  // PublicKey of the NFT to be remove from listing,
    connection,
  });
};

walletTokens :

service/user can get all their listed and borrowed tokens present on stream-nft platform using the following methods

  • get all listed tokens for a wallet
await getWalletTokens({
  connection,
  programId:  config.DEVNET_PROGRAM_ID,
  owner:  wallet,
  type:  QueryWalletTokensStatus.LISTED,
})
  • get all borrowed tokens for a wallet
await getWalletTokens({
  connection,
  programId:  config.DEVNET_PROGRAM_ID,
  owner:  wallet,
  type:  QueryWalletTokensStatus.BORROWED,
})

getAllListings :

get all tokens listed on the stream-nft platform

await  getAllListedTokens({
	connection,
	programId:  config.DEVNET_PROGRAM_ID,
})

Please check out the detailed integration at https://github.com/rahul0tripathi/sol_rent_demo and examples are available at https://github.com/rahul0tripathi/nft_rent_sdk/tree/master/examples

Stream NFT is soon expanding to other chains as well.. stay tuned :)