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

streamnft-stellar-sdk

v0.0.21

Published

This SDK provides an extension to integrate the STREAM NFT (https://www.streamnft.tech) smart contract to your application. STREAM NFT is an cross-chain scalability layer for NFT liquidity. This can be used to unlock features like rental, loan, buy now pa

Downloads

1,085

Readme

STREAM NFT

This SDK provides an extension to integrate the STREAM NFT (https://www.streamnft.tech) smart contract to your application. STREAM NFT is an cross-chain scalability layer for NFT liquidity. This can be used to unlock features like rental, loan, buy now pay later for your utilitarian NFT.

[Instalation]

npm i test-multichain-sdk

[Usage]

const {
     initPool,
     initManager,
     initRent,
     processLoan,
     processRent,
     repayLoan,
     expireLoan,
     expireRent,
     cancelManager,
     cancelRent,
     getAssetManager,
     getBidManager,
     getUserAssets,
     getBidPool,
     getProvider, 
     getSigner, 
     getWalletSigner,
     getHederaSigner,
     getHederaProvider,
     getBidPoolLength,
     getBidManagerLength,
   } = require("test-multichain-sdk");

[Chains]

  1. Polygon - 137
  2. Telos - 41
  3. Mantle - 5001

[Methods]

Initializes bidding pool

 initPool(
  tokenAddress: address,
  loanDurationInMinutes: number,
  gracePeriodInMinutes: number,
  interestRateLender: number,
  chainId: number,
  signer
) 

Initializes bid manager

 initManager(
  bidPoolIndex: number,
  bidAmount: number,
  totalBids: number,
  chainId: number,
  signer
)

Initializes rent

 initRent(
  tokenAddress: address, 
  tokenId: number, 
  ratePerMinute: number, 
  validityMinutes: number, 
  isFixed: bool, 
  fixedMinutes: number, 
  ownerShare: number, 
  whitelist: address, 
  chainId: number,
  signer
  ) 

Processes loan

processLoan(
  bidPoolIndex: number, 
  bidManagerIndex: number, 
  tokenAddress: address,
  tokenId: number, 
  chainId: number,
  signer
)

Processes rent

processRent(
  tokenAddress: address, 
  tokenId: number, 
  durationMinutes: number, 
  chainId: number,
  signer
) 

Repays loan

repayLoan(
  userAssetIndex: number, 
  chainId: number,
  signer
) 

Expire loan

expireLoan(
  userAssetIndex: number, 
  chainId: number,
  signer
)

Expire Rent

expireRent(
  tokenAddress: address, 
  tokenId: number, 
  chainId: number,
  signer
)

Cancel bid manager

cancelManager(
  bidPoolIndex: number, 
  bidManagerIndex: number, 
  chainId: number,
  signer
)

Cancel rent

cancelRent(
  tokenAddress: address, 
  tokenId: number, 
  chainId: number,
  signer
)

Get asset manager

getAssetManager(
  tokenAddress: address, 
  tokenId: number, 
  chainId: number,
  provider
)

Get bid manager

getBidManager(
  bidPoolIndex: number, 
  bidManagerIndex: number, 
  chainId: number,
  provider
)

Get user assets

getUserAssets(
  userAddres: address, 
  userAssetIndex: number, 
  chainId: number,
  provider
)

Get bid pool

getBidPool(
  bidPoolIndex: number, 
  chainId: number,
  provider
)

Get bid pool length

getBidPoolLength(
  "hedera",
  provider
)

Get bid manger length for bid pool index

getBidManagerLength(
   bidPoolIndex: number, 
  "hedera",
  provider
)

Get provider

getProvider(
  chainId: number
)

Get signer

getSigner(
  chainId: number,
  privateKey: string
)

Get hedera provider topic from hashconnect hashpack wallet

getHederaProvider(
  topic : object
  accountID : string
)

Get hedera signer

getHederaSigner(
  topic : object
  accountID : string
)

Get metamask signer

getMetaMaskSigner()

Get contract address

getContractAddress(
  chainId: number
)

Get RPC URL

getURL(
  chainId: number
)

[How to use - Polygon]

  1. Install the necessary dependencies:

    • Make sure you have Node.js installed on your machine.
    • Create a new directory for your project and navigate to it using the command line.
    • Run npm init -y to initialize a new Node.js project.
    • Install the ethers package by running npm install ethers.
  2. Create a new file in your project directory, e.g., app.js, and copy the provided SDK code into it.

  3. Import the necessary modules and instantiate the required variables in your app.js file:

const { ethers } = require("ethers");
const {
     initPool,
     initManager,
     initRent,
     processLoan,
     processRent,
     repayLoan,
     expireLoan,
     expireRent,
     cancelManager,
     cancelRent,
     getAssetManager,
     getBidManager,
     getUserAssets,
     getBidPool,
     getProvider, 
     getSigner, 
     getWalletSigner,
     getContractAddress, 
     getURL
   } = require("streamnft-sdk");
  1. Setup Provider and Signer
  • Polygon
// Set your Ethereum network
const chainId = 137;
const provider = getProvider(chainId);
const signer = getSigner(chainId, "PRIVATE_KEY");
  • Mantle
// Set your Ethereum network
const network = 5001;
const provider = getProvider(chainId);
const signer = getSigner(chainId, "PRIVATE_KEY");
  1. Use the SDK functions in your application as needed.

Initialize a bid pool:

const tokenAddress = "TOKEN_ADDRESS"; // ERC721 Token address
const loanDurationInMinutes = 60;
const gracePeriodInMinutes = 10;
const interestRateLender = 5; // in percentage

initPool(
     tokenAddress,
     loanDurationInMinutes,
     gracePeriodInMinutes,
     interestRateLender,
     chainId,
     signer
     )
     .then((result) => {
       // Handle the result
     })
     .catch((error) => {
       // Handle the error
     });

Create a bid manager:

     const bidPoolIndex = 0; // Index of the bid pool
     const bidAmount = 100; // Amount of the bid
     const totalBids = 10; // Total number of bids

     initManager(bidPoolIndex, bidAmount, totalBids, chainId, signer)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Process a loan:

     const bidPoolIndex = 0; // Index of the bid pool
     const bidManagerIndex = 0; // Index of the bid manager
     const tokenId = "TOKEN_ID";

     processLoan(bidPoolIndex, bidManagerIndex, tokenId, chainId, signer)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Repay a loan:

     const userAssetIndex = 0; // Index of the user asset

     repayLoan(userAssetIndex, chainId, signer)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Expire a loan:

     const userAssetIndex = 0; // Index of the user asset

     expireLoan(userAssetIndex, chainId, signer)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Cancel a bid manager:

     const bidPoolIndex = 0; // Index of the bid pool
     const bidManagerIndex = 0; // Index of the bid manager

     cancelManager(bidPoolIndex, bidManagerIndex, chainId, signer)
       .then((result) => {
         // Handle the result
      })
       .catch((error) => {
         // Handle the error
       });

Initialize a rent for a specific asset:

     const tokenAddress = "TOKEN_ADDRESS";
     const tokenId = "TOKEN_ID";
     const ratePerMinute = 10;
     const validityMinutes = 60;
     const isFixed = false;
     const fixedMinutes = 0;
     const ownerShare = 80; // in percentage
     const whitelist = []; // Array of whitelisted addresses
   
     initRent(
       tokenAddress,
       tokenId,
       ratePerMinute,
       validityMinutes,
       isFixed,
       fixedMinutes,
       ownerShare,
       whitelist,
       chainId,
       signer
     )
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Process a rent for a specific asset:

     const tokenAddress = "TOKEN_ADDRESS";
     const tokenId = "TOKEN_ID";
     const durationMinutes = 120;

     processRent(tokenAddress, tokenId, durationMinutes, chainId, signer)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Expire a rent for a specific asset:

     const tokenAddress = "TOKEN_ADDRESS";
     const tokenId = "TOKEN_ID";

     expireRent(tokenAddress, tokenId, chainId, signer)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Cancel a rent for a specific asset:

     const tokenAddress = "TOKEN_ADDRESS";
     const tokenId = "TOKEN_ID";

     cancelRent(tokenAddress, tokenId, chainId, signer)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Get bid pool details:

     const bidPoolIndex = 0; // Index of the bid pool

     getBidPool(bidPoolIndex, chainId, provider)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Get bid manager details:

     const bidPoolIndex = 0; // Index of the bid pool
     const bidManagerIndex = 0; // Index of the bid manager

     getBidManager(bidPoolIndex, bidManagerIndex, chainId, provider)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Get asset manager details:

     const tokenAddress = "TOKEN_ADDRESS";
     const tokenId = "TOKEN_ID";

     getAssetManager(tokenAddress, tokenId, chainId, provider)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Get user asset details:

     const userAddress = "USER_PUBLIC_KEY";
     const userAssetIndex = 0; // Index of the user asset

     getUserAssets(userAddress, userAssetIndex, chainId, provider)
       .then((result) => {
         // Handle the result
       })
       .catch((error) => {
         // Handle the error
       });

Remember to replace the placeholders (TOKEN_ADDRESS, TOKEN_ID, USER_PUBLIC_KEY, etc.) with the actual values specific to your use case.

These examples demonstrate how to use the SDK functions to interact with the smart contract. You can integrate them into your application logic and handle the results and errors accordingly.