Guides

Use the UI

To make things easier we’ve built a seamless UI where users can deposit NFTs, redeem from baskets, and create their own baskets seamlessly. This is the recommended approach to performing any and all user interactions.

Access our UI.

Depositing

When depositing a TangibleNFT (or batch of TangibleNFTs) into a specified basket you first need to call `approve` on the corresponding NFT contracts on each NFT being deposited. The approved `to` address needs to be the address of the basket you’re wishing to deposit your NFT(s) into.

Once you’ve approved the NFT transfer, you’ll need to locate your respective deposit method. Keep in mind the token(s) being deposited must be compatible with the specified basket. You can query whether the NFT is compatible by calling `isCompatible` on the chosen basket.

Single Deposit

If you’re only depositing a single TangibleNFT into the basket, you can do-so by executing the `depositTNFT` method:

function depositTNFT(
    address _tangibleNFT,
        uint256 _tokenId
) external returns (uint256 basketShare) {
        basketShare = _depositTNFT(_tangibleNFT, _tokenId, msg.sender);
}

This method will take your specific TangibleNFT and mint you an appropriate amount of ERC-20 basket tokens in accordance with the value of your NFT.

Read more about `depositTNFT` here.

Batch Deposit

If you wish to deposit multiple TangibleNFTs in exchange for basket tokens, you can do-so by locating and executing the `batchDepositTNFT` method:

function batchDepositTNFT(
    address[] memory _tangibleNFTs,
        uint256[] memory _tokenIds
) external returns (uint256[] memory basketShares) {
        uint256 length = _tangibleNFTs.length;
        require(length == _tokenIds.length, "Arrays not same size");

        basketShares = new uint256[](length);

        for (uint256 i; i < length;) {
                 basketShares[i] = _depositTNFT(_tangibleNFTs[i], _tokenIds[i], msg.sender);
                 unchecked {
                         ++i;
                  }
        }
}

This method will sequentially take each NFT specified into it’s custody and mint you an appropriate amount of basket tokens in return. The amount of basket tokens minted is dependent on the USD value of each NFT deposited.

Read more about `batchDepositTNFT` here.

Redeeming

Redeeming an NFT is not as frictionless as specifying an NFT in the basket and receiving that NFT in exchange for sufficient basket tokens. Redeemable NFTs are generated at random using vrf and can only be generated when the current redeemable is redeemed.

You can query the current redeemable by fetching the data stored in `nextToRedeem`. This variable will always contain the current redeemable token and will not be reset until this current redeemable is redeemed from the basket. If ‘nextToRedeem’ returns null data (i.e. address(0) and tokenId 0), this means the random redeemable has not yet been generated and is most likely still pending.

If you wish to redeem the current redeemable you’ll need to locate and call the `redeemTNFT` method:

function redeemTNFT(uint256 _budget) external {
        _redeemTNFT(msg.sender, _budget);
}

There’s a few things that will need to be true for this redeem to successfully execute:

  • You must have sufficient basket tokens in your EOA.

  • There mustn’t be an “in flight” request for entropy to vrf.

  • `nextToRedeem` cannot be null. It has to be assigned a valid redeemable NFT.

  • The `_budget` specified must be sufficient enough to exchange for the redeemable NFT.

This method, if executed successfully, will burn the appropriate amount of basket tokens in exchange for the NFT.

Read more about `redeemTNFT` here.

Creating a basket

To create a basket, you’ll need to locate the `deployBasket` method on the basket manager:

function deployBasket(
        string memory _name,
        string memory _symbol,
        uint256 _tnftType,
        address _rentToken,
        uint16 _location,
        uint256[] memory _features,
        address[] memory _tangibleNFTDeposit,
        uint256[] memory _tokenIdDeposit
) external returns (IBasket, uint256[] memory basketShares);

This method will deploy a new basket instance. The initial deposit NFT(s) will be deposited into the new basket and the basket tokens minted for the initial deposit will be minted to the EOA used to execute the new basket deployment.

Read more about `deployBasket` here.

Last updated