3.2.37 • Published 20 hours ago

streamnft-evm-test v3.2.37

Weekly downloads
-
License
ISC
Repository
github
Last release
20 hours ago

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 install streamnft-sdk

Usage

const {
     initPool,
     initManager,
     initRent,
     processLoan,
     processRent,
     repayLoan,
     expireLoan,
     expireRent,
     cancelManager,
     cancelRent,
     getAssetManager,
     getBidManager,
     getUserAssets,
     getBidPool,
     getProvider, 
     getSigner, 
     getWalletSigner,
     getContractAddress, 
     getURL
   } = require("streamnft-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 provider

getProvider(
  chainId: number
)

Get signer

getSigner(
  chainId: number,
  privateKey: 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.

3.2.37

20 hours ago

3.2.35

2 days ago

3.2.36

2 days ago

3.2.29

3 days ago

3.2.34

3 days ago

3.2.31

3 days ago

3.2.30

3 days ago

3.2.33

3 days ago

3.2.32

3 days ago

3.2.28

4 days ago

3.2.27

4 days ago

3.2.25

11 days ago

3.2.24

14 days ago

3.2.23

14 days ago

3.2.22

14 days ago

3.2.21

15 days ago

3.2.20

16 days ago

3.2.19

16 days ago

3.2.18

16 days ago

3.2.17

17 days ago

3.2.15

24 days ago

3.2.14

24 days ago

3.2.16

24 days ago

3.2.9

25 days ago

3.2.13

25 days ago

3.2.12

25 days ago

3.2.11

25 days ago

3.2.10

25 days ago

3.2.2

27 days ago

3.2.6

27 days ago

3.2.5

27 days ago

3.2.4

27 days ago

3.2.3

27 days ago

3.2.8

27 days ago

3.2.7

27 days ago

3.2.1

1 month ago

3.2.0

1 month ago

3.1.3

1 month ago

3.1.4

1 month ago

3.1.2

1 month ago

3.1.1

2 months ago

3.1.0

2 months ago

3.0.3

2 months ago

3.0.2

2 months ago

2.4.17

2 months ago

2.4.16

2 months ago

2.4.15

2 months ago

3.0.1

2 months ago

3.0.0

2 months ago

2.4.14

2 months ago

2.4.13

2 months ago

2.4.12

2 months ago

2.4.10

2 months ago

2.4.11

2 months ago

2.4.9

2 months ago

2.4.8

2 months ago

2.4.7

2 months ago

2.4.3

3 months ago

2.4.2

3 months ago

2.4.5

3 months ago

2.4.4

3 months ago

2.4.6

3 months ago

2.4.1

3 months ago

2.4.0

3 months ago

2.3.28

3 months ago

2.3.27

3 months ago

2.3.26

3 months ago

2.3.24

3 months ago

2.3.25

3 months ago

2.3.23

3 months ago

2.3.22

3 months ago

2.3.20

3 months ago

2.3.21

3 months ago

2.3.17

3 months ago

2.3.16

3 months ago

2.3.19

3 months ago

2.3.18

3 months ago

2.3.13

3 months ago

2.3.15

3 months ago

2.3.14

3 months ago

2.3.6

3 months ago

2.3.8

3 months ago

2.3.7

3 months ago

2.3.9

3 months ago

2.3.12

3 months ago

2.3.11

3 months ago

2.3.10

3 months ago

2.3.0

3 months ago

2.3.2

3 months ago

2.3.1

3 months ago

2.3.4

3 months ago

2.3.3

3 months ago

2.3.5

3 months ago

2.2.9

4 months ago

2.2.8

4 months ago

2.2.5

4 months ago

2.2.7

4 months ago

2.2.6

4 months ago

2.2.3

4 months ago

2.2.2

4 months ago

2.2.1

4 months ago

2.2.0

4 months ago

2.1.9

4 months ago

2.1.8

4 months ago

2.1.7

4 months ago

2.1.6

4 months ago

2.1.5

4 months ago

2.1.4

4 months ago

2.1.3

4 months ago

2.1.2

4 months ago

2.1.1

4 months ago

2.1.0

4 months ago

2.0.0

5 months ago

1.0.62

7 months ago

1.0.61

7 months ago

1.0.60

7 months ago

1.0.64

7 months ago

1.0.63

7 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.1.2

7 months ago

1.0.55

7 months ago

1.0.54

7 months ago

1.0.53

7 months ago

1.0.52

7 months ago

1.0.59

7 months ago

1.0.58

7 months ago

1.0.57

7 months ago

1.0.56

7 months ago

1.0.51

7 months ago

1.0.50

7 months ago

1.0.49

7 months ago

1.0.48

7 months ago

1.0.47

7 months ago

1.0.46

7 months ago

1.0.45

7 months ago

1.0.44

7 months ago

1.0.43

7 months ago

1.0.42

7 months ago

1.0.41

7 months ago

1.0.40

7 months ago

1.0.39

7 months ago

1.0.38

7 months ago

1.0.37

7 months ago

1.0.36

7 months ago

1.0.35

7 months ago

1.0.34

7 months ago

1.0.33

7 months ago

1.0.32

7 months ago

1.0.31

7 months ago

1.0.30

7 months ago

1.0.29

7 months ago

1.0.28

7 months ago

1.0.27

7 months ago

1.0.26

7 months ago

1.0.25

7 months ago

1.0.24

7 months ago

1.0.23

7 months ago

1.0.22

7 months ago

1.0.21

7 months ago

1.0.20

7 months ago

1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago