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",
});
View in React SDK Documentation

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 { useContract } from '@thirdweb-dev/react'

export default function Component() {
const { contract } = useContract("<YOUR-CONTRACT-ADDRESS>", "multiwrap")

// 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..."
});
View in React SDK Documentation

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
View in React SDK Documentation

Viewing Wrapped NFTs

One wrapped NFT

Get a single NFT
const tokenId = 0; // the tokenId to look up
const { data: nft, isLoading, error } = useNFT(contract, tokenId);
View in React SDK Documentation

All wrapped NFTs

Get all NFTs
const { data: nfts, isLoading, error } = useNFTs(contract, { start: 0, count: 100 });
View in React SDK Documentation

Amount of tokens owned by a specific wallet

Get NFT Balance
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract, "{{wallet_address}}");
// for ERC1155 contracts, you can also pass a tokenId
const tokenId = 0;
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract, "{{wallet_address}}", tokenId);
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);
View in React SDK Documentation

Unwrapping Tokens

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

await contract.unwrap(wrappedTokenId);
View in React SDK Documentation

Transferring NFTs