burn
Tries to buy one or more tokens for a given smart contract id.
You must own a token to be able to burn it.
The nftContactId can be supplied as an argument or through the
CONTRACT_ADDRESS
environment variable.burn
takes a single argument of type BurnArgs
type BurnArgs = {
burn: {
//the contract from which to burn tokens
//as an argument or through CONTRACT_ADDRESS env
contractAddress?: string;
//the array of token ids to burn
tokenIds: string[];
}[];
};
Example usage of burn method in a hypothetical React component:
BurnComponent.ts
1
import { useState } from 'react';
2
import { useWallet } from '@mintbase-js/react';
3
import { execute, burn, BurnArgs } from '@mintbase-js/sdk';
4
5
6
export const BurnComponent = ({ tokenIds, contractAddress }:BurnArgs): JSX.Element => {
7
8
const { selector } = useWallet();
9
10
const handleBurn = async (): Promise<void> => {
11
12
const wallet = await selector.wallet();
13
14
await execute(
15
{wallet},
16
burn({ contractAddress: contractAddress, tokenIds: tokenIds })
17
);
18
19
}
20
21
return (
22
<div>
23
<button onClick={handleBurn}>
24
Burn provided token array from {contractAddress}
25
</button>
26
</div>
27
);
28
};
Last modified 10mo ago