Skip to main content

Multiwrap

Learn how to interact with your Multiwrap contract in the SDK.

Create a Multiwrap Contract

Deploys a new Multiwrap contract
const sdk = useSDK();

const contractAddress = await sdk.deployer.deployMultiwrap({
name: "My Multiwrap",
});

Getting the contract in your application

To start using your Multiwrap contract inside your application, you need to use its contract address. You can get the contract address from the dashboard.

import { useMultiwrap } from '@thirdweb-dev/react'

export default function Component() {
const multiwrap = useMultiwrap("<YOUR-CONTRACT-ADDRESS>")

// Now you can use the multiwrap contract in the rest of the component
}

Setting Royalty Fees

Configure royalties
// royalties on the whole contract
contract.royalties.setDefaultRoyaltyInfo({
seller_fee_basis_points: 100, // 1%
fee_recipient: "0x..."
});
// override royalty for a particular token
contract.royalties.setTokenRoyaltyInfo(tokenId, {
seller_fee_basis_points: 500, // 5%
fee_recipient: "0x..."
});

Wrapping Tokens

You can wrap any number of ERC20, ERC721, or ERC1155 tokens into a single wrapped ERC721 NFT.

When you wrap NFTs, you mint a new NFT into the Multiwrap contract.

const tx = await contract.wrap({
erc20Tokens: [{
contractAddress: "0x...",
quantity: "0.8"
}],
erc721Tokens: [{
contractAddress: "0x...",
tokenId: "0"
}],
erc1155Tokens: [{
contractAddress: "0x...",
tokenId: "1",
quantity: "2"
}]
}, {
name: "Wrapped bundle",
description: "This is a wrapped bundle of tokens and NFTs",
image: "ipfs://...",
});
const receipt = tx.receipt(); // the transaction receipt
const wrappedTokenId = tx.id; // the id of the wrapped token bundle

Viewing Wrapped NFTs

One wrapped NFT

Get a single NFT Metadata
const { contract } = useContract(<ContractAddress>);
const { data: nft, isLoading, error } = useNFT(contract?.nft, <tokenId>);
View in React SDK Documentation

All wrapped NFTs

Get All Wrapped Token Bundles
const { contract } = useContract(<ContractAddress>);
const { data: nfts, isLoading, error } = useNFTs(contract?.nft, { start: 0, count: 100 });
View in React SDK Documentation

Amount of tokens owned by a specific wallet

Get NFT Balance
const { contract } = useContract(<ContractAddress>);
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract?.nft, <OwnerWalletAddress>);
View in React SDK Documentation

View Wrapped NFT Contents

Get the contents of a wrapped token bundle
const contents = await contract.getWrappedContents(wrappedTokenId);
console.log(contents.erc20Tokens);
console.log(contents.erc721Tokens);
console.log(contents.erc1155Tokens);

Unwrapping Tokens

When you unwrap a wrapped NFT, you can get the underlying tokens back and burn the wrapped NFT.

await contract.unwrap(wrappedTokenId);

Transferring NFTs

Transfer a single NFT
const walletAddress = "{{wallet_address}}";
const tokenId = 0;
await contract.nft.transfer(walletAddress, tokenId);