batchChangeMinters
Change minting permissions for your smart contract by removing or adding multiple accountIds in one call.
Account IDs in the
removeMinters
array will lose minting permission for the specified contract. Ids in the addMinters
array get granted that permission.batchChangeMinters
takes a single argument of type BatchChangeMintersArgs
type BatchChangeMintersArgs = {
//the contract you own for which you wish to grant or revoke minting access
// as an argument or through CONTRACT_ADDRESS env
contractAddress?: string;
//an array of ids that will be added as minters for the given contractId, if nothing is provided no minters will be added
addMinters: string[];
//an array of ids that will be removed as minters for the given contractId, if nothing is provided no minters will be removed
removeMinters: string[];
};
Example usage of batchChangeMinters method in a hypothetical React component:
BatchChangeMintersComponent.ts
1
import { useState } from 'react';
2
import { useWallet } from '@mintbase-js/react';
3
import { execute, batchChangeMinters, BatchChangeMintersArgs } from '@mintbase-js/sdk';
4
5
6
export const BatchChangeMintersComponent = ({ contractAddress, addMinters, removeMinters }: BatchChangeMintersArgs): JSX.Element => {
7
8
const { selector } = useWallet();
9
10
const handleBatchChangeMinters = async (): Promise<void> => {
11
12
const wallet = await selector.wallet();
13
14
await execute(
15
{wallet},
16
batchChangeMinters({
17
contractAddress: contractAddress,
18
addMinters: addMinters,
19
removeMinters: removeMinters
20
})
21
);
22
}
23
24
return (
25
<div>
26
<button onClick={handleBatchChangeMinters}>
27
batchChangeMinters for contractId : {contractAddress}
28
</button>
29
</div>
30
);
31
};
Last modified 9mo ago