Market is a wrapper around Stash Market Contract which is responsible for facilitating all rental operations such as lending and renting
Definition
Market class in Stash Renting SDK is responsible for providing an easy integration interface for rental operations by wrapping all the functionalities of Stash Market Contract in a simplified manner.
The function set inside Market is defined in MarketInterface:
interface MarketInterface {
lend(
tokenId: number,
amount: number,
standard: NFTStandard,
expiry: number,
pricePerDay: number,
ERC20Address: string,
revShareBasisPoints: number,
buyPrice: number,
maxRentalDays: number,
onSuccess: (response: StashResponse) => void,
onError: (error: StashError) => void,
): Promise<ContractTransaction | null>;
rent(
tokenId: number,
standard: NFTStandard,
rentDurationInDays: number,
onSuccess: (response: StashResponse) => void,
onError: (error: StashError) => void,
): Promise<ContractTransaction | null>;
endLend(
tokenId: number,
amount: number,
standard: NFTStandard,
onSuccess: (response: StashResponse) => void,
onError: (error: StashError) => void,
): Promise<ContractTransaction | null>;
buy(
tokenId: number,
standard: NFTStandard,
onSuccess: (response: StashResponse) => void,
onError: (error: StashError) => void,
): Promise<ContractTransaction | null>;
isRentCompliant(
standard: NFTStandard
): Promise<boolean>
}
Functions
lend:
Used to lend an NFT and has the following declaration:
lend(tokenId: number,
amount: number,
standard: NFTStandard,
expiry: number,
pricePerDay: number,
ERC20Address: string,
revShareBasisPoints: number,
buyPrice: number,
maxRentalDays: number,
onSuccess: (response: StashResponse) => void,
onError: (error: StashError) => void,
): Promise<ContractTransaction | null>;
Parameters
- tokenId: Token ID of the NFT to be lent
- amount: Amount of tokens to be lent, 1 for 721-NFTs
- standard: Standard of the NFT, either E721 or E1155
- expiry: Number of days until the expiration of the rental listing
- pricePerDay: Daily rental fee
- ERC20Address: Address of the ERC20 token which is preferred by the lender to receive the rental fee payments with
- revShareBasisPoints: The desired % of the revenue generated from P2E which will be the lender's cut, optional can be set to 0. Note that 10,000 basis point maps to 100%.
- buyPrice: The price a renter can pay to redeem full ownership of the NFT (optional can be set to 0 to indicate the lender is not open to selling the NFT).
- maxRentalDays: Maximum number of days for the rental length
- onSuccess: Response callback for successful operations
- onError: Response callback for failed operations
Response
ContractTransaction object representing the contract call or null if the transaction fails.
rent:
Used to rent an NFT and has the following declaration:
rent(tokenId: number,
standard: NFTStandard,
rentDurationInDays: number,
onSuccess: (response: StashResponse) => void,
onError: (error: StashError) => void,
): Promise<ContractTransaction | null>;
Parameters
- tokenId: Token ID of the NFT to be rented
- standard: Standard of the NFT, either E721 or E1155
- rentDurationInDays: Number of days for the duration of the rental period
- onSuccess: Response callback for successful operations
- onError: Response callback for failed operations
Response
ContractTransaction object representing the contract call or null if the transaction fails.
endLend:
Used for taking an NFT back from lending by also cancelling the rental terms. The declaration is as follows:
endLend(tokenId: number,
amount: number,
standard: NFTStandard,
onSuccess: (response: StashResponse) => void,
onError: (error: StashError) => void,
): Promise<ContractTransaction | null>;
Parameters
- tokenId: Token ID of the NFT
- amount: Amount of tokens, 1 for 721-NFTs
- standard: Standard of the NFT, either E721 or E1155
- onSuccess: Response callback for successful operations
- onError: Response callback for failed operations
Response
ContractTransaction object representing the contract call or null if the transaction fails.
buy:
Used for buying an NFT by its current renter. The declaration is as follows:
buy(tokenId: number,
standard: NFTStandard,
onSuccess: (response: StashResponse) => void,
onError: (error: StashError) => void,
): Promise<ContractTransaction | null>;
Parameters
- tokenId: Token ID of the NFT
- standard: Standard of the NFT, either E721 or E1155
- onSuccess: Response callback for successful operations
- onError: Response callback for failed operations
Response
ContractTransaction object representing the contract call or null if the transaction fails.
isRentCompliant:
Used for checking whether your NFT contract with the given standard is compliant for rentals, in other words whether your NFTs can be lent/rented without wrapping or not. The declaration is as follows:
isRentCompliant(
standard: NFTStandard
): Promise<boolean>
Parameters
- tokenId: Token ID of the NFT
- standard: Standard of the NFT, either E721 or E1155
Response
A boolean value that indicates whether the NFT contract is rent-compliant or not.
Confused about rent-compliancy?
You can check the link below to get more information about the concept of rent-compliancy.