Ask or search…
K
Links

addMinter

Give an account id minting permission for a smart contract of your choice.
As with all new SDK api methods, this call should be wrapped in execute and passed a signing method

addMinter(args: addMinterArgs): NearContractCall

addMinter takes a single argument of type AddMinterArgs
type AddMinterArgs = {
//the contract you own for which you wish to grant minting access
//as an argument or through CONTRACT_ADDRESS env
contractAddress?: string;
//the id of the account that will be allowed to mint on the corresponding nftContractId
minterId: string;
};

React example

Example usage of addMinter method in a hypothetical React component:
AddMinterComponent.ts
1
import { useState } from 'react';
2
import { useWallet } from '@mintbase-js/react';
3
import { execute, addMinter, AddMinterArgs } from '@mintbase-js/sdk';
4
5
6
export const AddMinterComponent = ({ contractAddress, minterId }:AddMinterArgs): JSX.Element => {
7
const { selector } = useWallet();
8
9
const handleAddMinter = async (): Promise<void> => {
10
const wallet = await selector.wallet();
11
12
await execute(
13
{wallet},
14
addMinter({ contractAddress: contractAddress, minterId: minterId })
15
);
16
}
17
18
return (
19
<div>
20
<button onClick={handleAddMinter}>
21
addMinter to contract you own
22
</button>
23
</div>
24
);
25
};