![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
streamnft-evm-test
Advanced tools
This SDK provides an extension to integrate the (mainnet) STREAM NFT (https://www.streamnft.tech) smart contract to your application.
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.
npm install streamnft-sdk
const {
initPool,
initManager,
initRent,
processLoan,
processRent,
repayLoan,
expireLoan,
expireRent,
cancelManager,
cancelRent,
getAssetManager,
getBidManager,
getUserAssets,
getBidPool,
getProvider,
getSigner,
getWalletSigner,
getContractAddress,
getURL
} = require("streamnft-sdk");
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
)
Install the necessary dependencies:
npm init -y
to initialize a new Node.js project.ethers
package by running npm install ethers
.Create a new file in your project directory, e.g., app.js
, and copy the provided SDK code into it.
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");
// Set your Ethereum network
const chainId = 137;
const provider = getProvider(chainId);
const signer = getSigner(chainId, "PRIVATE_KEY");
// Set your Ethereum network
const network = 5001;
const provider = getProvider(chainId);
const signer = getSigner(chainId, "PRIVATE_KEY");
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.
FAQs
This SDK provides an extension to integrate the (mainnet) STREAM NFT (https://www.streamnft.tech) smart contract to your application.
The npm package streamnft-evm-test receives a total of 0 weekly downloads. As such, streamnft-evm-test popularity was classified as not popular.
We found that streamnft-evm-test demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.