To integrate the SDK with your repository, follow the steps below. The following code snippets provide examples of how to use the SDK functions to interact with the smart contract.
Executing this code will fetch the details of the user asset associated with the provided user address. The result will contain information such as the asset's token address, token ID, and other relevant details pertaining to the asset rental.
2. Get Rented NFTs By Wallet And Collection:
To retrieve the details of a specific user asset, you can use the following function:
Specify the user's public address and the index of the user asset.
Provide the chainId
const stream = require('streamnft-evm-test');
stream.getRentedNFTs(wallet.address, chainId)
.then((result) => {
// Handle the result
})
.catch((error) => {
// Handle the error
});
Executing this code will fetch the details of the user asset associated with the provided user address and collection. The result will contain information such as the asset's token address, token ID, and other relevant details pertaining to the asset rental.
3. Initialize Rent for a Specific Asset:
To initiate a rent for a specific asset, you can use the following function:
Provide the token address of the asset, the token ID, and other required parameters such as the rate per minute, validity duration, fixed/variable rent, owner share, and whitelist.
Executing this code will fetch the asset manager details for the specified token. Ensure that you provide the correct token address and token ID corresponding to the asset you want to retrieve information for. The result will contain relevant details about the asset manager, which can be further processed or displayed as needed in your application.
Executing this code will trigger the rental process for the specified asset. Ensure that you provide the correct token address and token ID corresponding to the asset you want to initiate the rent for. Set the desired duration of the rent in minutes. The result will indicate the success of the rental process, and you can handle it accordingly in your application.
6. Expire a Rent for a Specific Asset:
To expire a rent for a specific asset, you can use the following function:
Provide the token address and token ID of the asset for which you want to expire the rent.
By executing this code, you initiate the process to expire the rent for the specified asset. Make sure to provide the correct token address and token ID corresponding to the asset you want to expire the rent for. The result will indicate the successful expiration of the rent, and you can handle it accordingly in your application logic.
Example Response:
{ success: true, data: }
{ success: false, data: <error>}
7. Cancel a Rent for a Specific Asset:
To cancel a rent for a specific asset, you can use the following function:
Provide the token address and token ID of the asset for which you want to cancel the rent.
By executing this code, you initiate the process to cancel the rent for the specified asset. Make sure to provide the correct token address and token ID corresponding to the asset you want to cancel the rent for. The result will indicate the successful cancellation of the rent, and you can handle it accordingly in your application logic.
Example Response:
{ success: true, data: }
{ success: false, data: <error>}
Get Assets by collection
const stream = require('streamnft-evm-test');
const tokenAddress = "TOKEN_ADDRESS";
stream.getAssetsByCollection(tokenAddress, chainId)
.then((result) => {
// Handle the result
})
.catch((error) => {
// Handle the error
});
By executing this code, you get all all assets for provided collection
Executing this code will fetch the details of the user asset associated with the provided user address. The result will contain information such as the asset's token address, token ID, and other relevant details pertaining to the user asset.
Make sure 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.