Multiwrap
Learn how to interact with your Multiwrap contract in the SDK.
Create a Multiwrap Contract
- React
- Javascript
- Python
- Go
- Unity
const sdk = useSDK();
const contractAddress = await sdk.deployer.deployMultiwrap({
name: "My Multiwrap",
});
const contractAddress = await sdk.deployer.deployMultiwrap({
name: "My Multiwrap",
});
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Unity SDK Reference for more information.
Reach out on Discord for further assistance!
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.
- React
- Javascript
- Python
- Go
- Unity
This feature is missing a code snippet or might not be supported yet.
Check the React SDK Reference for more information.
Reach out on Discord for further assistance!
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
const sdk = new ThirdwebSDK("{{chainName}}");
const contract = await sdk.getContract("{{contract_address}}", "multiwrap");
from thirdweb import ThirdwebSDK
# You can customize this to a supported network or your own RPC URL
network = "mumbai"
# Now we can create a new instance of the SDK
sdk = ThirdwebSDK(network)
# If you want to send transactions, you can instantiate the SDK with a private key instead:
# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)
contract = sdk.get_multiwrap("{{contract_address}}")
import (
"github.com/thirdweb-dev/go-sdk/v2/thirdweb"
)
privateKey = "..."
sdk, err := thirdweb.NewThirdwebSDK("mumbai", &thirdweb.SDKOptions{
PrivateKey: privateKey,
})
contract, err := sdk.GetMultiwrap("{{contract_address}}")
This feature is missing a code snippet or might not be supported yet.
Check the Unity SDK Reference for more information.
Reach out on Discord for further assistance!
Setting Royalty Fees
- React
- Javascript
- Python
- Go
- Unity
// 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..."
});
// 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..."
});
This feature is missing a code snippet or might not be supported yet.
Check the Python SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Go SDK Reference for more information.
Reach out on Discord for further assistance!
This feature is missing a code snippet or might not be supported yet.
Check the Unity SDK Reference for more information.
Reach out on Discord for further assistance!
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.
- React
- Javascript
- Python
- Go
- Unity
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
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
from thirdweb.types import (
TokensToWrap,
ERC20Wrappable,
ERC721Wrappable,
ERC1155Wrappable,
NFTMetadataInput,
)
# Contract setup goes here...
tx = contract.wrap(
TokensToWrap(
erc20_tokens=[
ERC20Wrappable(contract_address="0x...", quantity=0.8),
],
erc721_tokens=[
ERC721Wrappable(contract_address="0x...", token_id=0),
],
erc1155_tokens=[
ERC1155Wrappable(contract_address="0x...", token_id=0, quantity=1),
]
),
NFTMetadataInput(
name="Wrapped NFT",
description="This is a wrapped bundle of tokens and NFTs",
image="ipfs://...",
)
)
print(tx.receipt, tx.id)
contents := &thirdweb.MultiwrapBundle{
ERC20Tokens: []*thirdweb.MultiwrapERC20{
&thirdweb.MultiwrapERC20{
ContractAddress: "0x...",
Quantity: 1,
},
},
ERC721Tokens: []*thirdweb.MultiwrapERC721{
&thirdweb.MultiwrapERC721{
ContractAddress: "0x...",
TokenId: 1,
},
},
ERC1155Tokens: []*thirdweb.MultiwrapERC1155{
&thirdweb.MultiwrapERC1155{
ContractAddress: "0x...",
TokenId: 1,
Quantity: 1,
},
},
}
wrappedTokenMetadata := &thirdweb.NFTMetadataInput{
Name: "Wrapped Token"
}
// This will mint the wrapped token to the connected wallet
tx, err := contract.Wrap(context.Background(), contents, wrappedTokenMetadata, "")
// Multiwrap is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Viewing Wrapped NFTs
One wrapped NFT
- React
- Javascript
- Python
- Go
- Unity
const tokenId = 0;
const nft = await contract.get(tokenId);
const tokenId = 0;
const nft = await contract.get(tokenId);
nft = contract.get(0)
print(nft)
nft, err := contract.Get(context.Background(), 0)
owner := nft.Owner
name := nft.Metadata.Name
// Multiwrap is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
All wrapped NFTs
- React
- Javascript
- Python
- Go
- Unity
const nfts = await contract.getAll();
console.log(nfts);
const nfts = await contract.getAll();
console.log(nfts);
nfts = contract.get_all()
print(nfts)
nfts, err := contract.GetAll(context.Background())
ownerOne := nfts[0].Owner
nameOne := nfts[0].Metadata.Name
// Multiwrap is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Amount of tokens owned by a specific wallet
- React
- Javascript
- Python
- Go
- Unity
const walletAddress = "{{wallet_address}}";
const balance = await contract.balanceOf(walletAddress);
console.log(balance);
const walletAddress = "{{wallet_address}}";
const balance = await contract.balanceOf(walletAddress);
console.log(balance);
balance = contract.balance_of("{{wallet_address}}")
print(balance)
address := "{{wallet_address}}"
balance, err := contract.BalanceOf(context.Background(), address)
// Multiwrap is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
View Wrapped NFT Contents
- React
- Javascript
- Python
- Go
- Unity
const contents = await contract.getWrappedContents(wrappedTokenId);
console.log(contents.erc20Tokens);
console.log(contents.erc721Tokens);
console.log(contents.erc1155Tokens);
const contents = await contract.getWrappedContents(wrappedTokenId);
console.log(contents.erc20Tokens);
console.log(contents.erc721Tokens);
console.log(contents.erc1155Tokens);
token_id = 0
contents = contract.get_wrapped_contents(token_id)
print(contents.erc20_tokens)
print(contents.erc721_tokens)
print(contents.erc1155_tokens)
tokenId := 0
contents, err := contract.GetWrappedContents(tokenId)
erc20Tokens := contents.Erc20Tokens
erc721Tokens := contents.Erc721Tokens
erc1155Tokens := contents.Erc1155Tokens
// Multiwrap is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Unwrapping Tokens
When you unwrap a wrapped NFT, you can get the underlying tokens back and burn the wrapped NFT.
- React
- Javascript
- Python
- Go
- Unity
await contract.unwrap(wrappedTokenId);
await contract.unwrap(wrappedTokenId);
tx = contract.unwrap(wrapped_token_id, receipientAddress)
tokenId := 0
tx, err := contract.Unwrap(context.Background(), tokenId, "")
// Multiwrap is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.
Transferring NFTs
- React
- Javascript
- Python
- Go
- Unity
const walletAddress = "{{wallet_address}}";
const tokenId = 0;
await contract.transfer(walletAddress, tokenId);
const walletAddress = "{{wallet_address}}";
const tokenId = 0;
await contract.transfer(walletAddress, tokenId);
to = "{{wallet_address}}"
token_id = 0
receipt = contract.transfer(to, token_id)
to := "0x..."
tokenId := 0
tx, err := contract.Transfer(context.Background(), to, tokenId)
// Multiwrap is not yet supported in Unity. You can still use the contrat.Read and contract.Write functions to call functions directly.