Burn NFTs (ERC721) Assets
- Learn how to burn the MINTABLE_ERC721 assets from the Myria L2.
- To inspect the function in the SDK with details payload and response format you can reference at SDK Docs.
Prerequisites
- Make sure that you have MINTABLE_ERC721 tokens (such as your minted/purchased NFTs) in the L2 wallet
- You can mint the MINTABLE_ERC721 NFTs in your own collection, can reference at Minting ERC721 step.
- Or you can purchased the NFTs on Myria Marketplace.
- Or if your L2 wallet received the ERC-721 tokens from Airdrop / Campaign events in either Myria or Gaming Platform.
Burn process
- Defined the NFTs token (with such of information - collectionID, tokenID, smart contract address) you want to burn.
- Make sure that you are the owner of desired burned NFTs (MINTABLE_ERC721)
- Trigger the burn process.
Implementation
info
You can find the full React implementation for burn MINTABLE_ERC721 tokens in the Myria React Samples repository.
1. Set up a new React project
Burn ERC-721 tokens requires client-side interaction with the MetaMask wallet. It's recommended to use React to implement such behavior.
You can create a React app via Create React App. Note, the below project relies on Web3.js library and needs custom configuration.
2. Create a myria-client.ts
helper
It's recommended to have a separate .ts
file for quick access to the MyriaClient
.
For more details, use the Myria Core SDK overview.
3. Trigger the burn tokens action
You can create the simple React component file with below implementation such as BurnNftsComponent.tsx
Sample Code with Details Implementation
const mClient: IMyriaClient = {
networkId: Network.SEPOLIA, // This network is couple along with env - for Mainnet it is 1
provider: web3Instance.currentProvider,
web3: web3Instance,
env: EnvTypes.STAGING, // Staging is Testnet - Env that you're interacting on STAGING/PROD
};
const YOUR_NFT_CONTRACT_ADDRESS = "0xA06116D9...."; // Your NFTs smart contract
const SENDER_WALLET_ADDRESS = '0x724f337bF0F....'; // Must be the owner of NFTs
const moduleFactory = ModuleFactory.getInstance(mClient);
const transactionManager = moduleFactory.getTransactionManager();
const burnTransferredItems: ItemSignableBurnTransferParams[] = [
{
quantizedAmount: 1, // Should be 1 as always for NFTs
tokenType: TokenType.MINTABLE_ERC721,
tokenData: {
tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
tokenId: '1' // Your minted token ID,
},
},
{
quantizedAmount: 1,
tokenType: TokenType.MINTABLE_ERC721,
tokenData: {
tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
tokenId: '2' // Your minted token ID,
},
},
{
quantizedAmount: 1,
tokenType: TokenType.MINTABLE_ERC721,
tokenData: {
tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
tokenId: '3' // Your minted token ID
},
},
];
const burnTransferTokenParams: BurnTokenParams = {
senderWalletAddress: SENDER_WALLET_ADDRESS,
groupRequestId: '7257d29c-c96a-4302-8eaf-368a0d62b977', // Can use random UUID to generate groupRequestID
requestId: '7257d29c-c96a-4302-8eaf-368a0d62b977', // Can use random UUID to generate requestID
partnerRefId: 'Project-ID', // Project-ID on Myria System
description: 'Test-Test Burn Transfer',
items: burnTransferredItems,
};
const burnTransferResult = await transactionManager.burnNfts(
burnTransferTokenParams,
);