Skip to main content

useMintToken() function

This feature is currently in beta and may change based on feedback that we receive.

Use this to mint new tokens on your contract

Example

const Component = () => {
const {
mutate: mintTokens,
isLoading,
error,
} = useMintToken(">>YourERC20ContractInstance<<");

if (error) {
console.error("failed to mint tokens", error);
}

return (
<button
disabled={isLoading}
onClick={() => mintTokens({ to: "0x...", amount: 1000 })}
>
Mint!
</button>
);
};

Signature:

export declare function useMintToken(
contract: RequiredParam<Erc20>,
): import("@tanstack/react-query").UseMutationResult<
Omit<
{
receipt: import("@ethersproject/abstract-provider").TransactionReceipt;
data: () => Promise<unknown>;
},
"data"
>,
unknown,
TokenParams,
unknown
>;

Parameters

ParameterTypeDescription
contractRequiredParam<Erc20>an instance of a contract that extends the ERC20 spec (token, token drop, custom contract that follows the ERC20 spec)

Returns:

import("@tanstack/react-query").UseMutationResult<Omit<{ receipt: import("@ethersproject/abstract-provider").TransactionReceipt; data: () => Promise<unknown>; }, "data">, unknown, TokenParams, unknown>

a mutation object that can be used to mint new tokens to the connected wallet