Wrapper Factory is a wrapper around Stash Wrapper Factory Contract that provides functions for wrapping an ERC-721 or ERC-1155 NFT and unwrapping it back to original

Definition

WrapperFactory class in Stash Renting SDK provides an interface for making wrapping operations which are available in Wrapper Factory Contract.

The factory contract has separate functions for both NFT standards 721 and 1155, therefore the standard needs to be set as a parameter while making function calls. The parameter uses the type `NFTStandard under src/types.ts:

export enum NFTStandard {
    E721,
    E1155,
};

The function set inside WrapperFactory is defined in WrapperFactoryInterface:

interface WrapperFactoryInterface {
    wrap(
        tokenId: number,
        amount: number,
        standard: NFTStandard,
        onSuccess: (response: StashResponse) => void,
        onError: (error: StashError) => void,
    ): Promise<ContractTransaction | null>;

    unwrap(
        tokenId: number,
        amount: number,
        standard: NFTStandard,
        onSuccess: (response: StashResponse) => void,
        onError: (error: StashError) => void,
    ): Promise<ContractTransaction | null>;
}

Functions

wrap:

Used to wrap an NFT and has the following declaration:

wrap(tokenId: number,
        amount: number,
        standard: NFTStandard,
        onSuccess: (response: StashResponse) => void,
        onError: (error: StashError) => void,
    ): Promise<ContractTransaction | null>;

Parameters

  • tokenId: Token ID of the NFT to be wrapped
  • amount: Amount of tokens to be lent, 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.

unwrap:

Used to unwrap an NFT and has the following declaration:

unwrap(tokenId: number,
        amount: number,
        standard: NFTStandard,
        onSuccess: (response: StashResponse) => void,
        onError: (error: StashError) => void,
    ): Promise<ContractTransaction | null>;

Parameters

  • tokenId: Token ID of the NFT to be unwrapped
  • amount: Amount of tokens to be lent, 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.