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 { contract } = useContract(<ContractAddress>);
const {
mutate: mintTokens,
isLoading,
error,
} = useMintToken(contract);

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

Parameters

ParameterTypeDescription
contractRequiredParam<TokenContract>an instance of a TokenContract

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