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.

As with all new SDK api methods, this call should be wrapped in execute and passed a signing method

This is only available on Mintbase v1 smart contracts, if you are using a Mintbase v2 contract, use batchChangeCreators instead.

batchChangeMinters(args: addMinterArgs): NearContractCall

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[];
};

React example

Example usage of batchChangeMinters method in a hypothetical React component:

BatchChangeMintersComponent.ts
import { useState } from 'react';
import { useWallet } from '@mintbase-js/react';
import { execute, batchChangeMinters, BatchChangeMintersArgs } from '@mintbase-js/sdk';


export const BatchChangeMintersComponent = ({ contractAddress, addMinters, removeMinters }: BatchChangeMintersArgs): JSX.Element => {

  const { selector } = useWallet();

  const handleBatchChangeMinters = async (): Promise<void> => {

    const wallet = await selector.wallet();

    await execute(
      {wallet},
      batchChangeMinters({
          contractAddress: contractAddress,
          addMinters: addMinters,
          removeMinters: removeMinters
          })
    );
  }

  return (
    <div>
      <button onClick={handleBatchChangeMinters}>
        batchChangeMinters for contractId : {contractAddress}
      </button>
    </div>
  );
};

Last updated