Mint and freeze authority in code: set, revoke and check
Every SPL mint has two optional authorities. The mint authority can create more supply; the freeze authority can freeze individual holder token accounts. Setting either to null removes that power permanently.
What each one does
- Mint authority: while set, the holder can mint unlimited new tokens. Revoking it fixes the total supply forever.
- Freeze authority: while set, the holder can freeze any holder's token account so it cannot transfer. Many community tokens leave it unset from the start.
Set them at creation
With the API, pass revokeMint: true to remove the mint authority in the same transaction that mints the supply, and revokeFreeze (default true) to create the token with no freeze authority at all. There is no window in which a revoked authority could be abused.
Revoke later
If you created a token with an authority and want to remove it, send a SetAuthority instruction with the new authority set to null. With @solana/spl-token:
import { setAuthority, AuthorityType } from "@solana/spl-token";
await setAuthority(connection, payer, mint, currentAuthority, AuthorityType.MintTokens, null);
await setAuthority(connection, payer, mint, currentAuthority, AuthorityType.FreezeAccount, null);
This cannot be undone. Double-check the mint address before sending.
Check them on chain
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
const info = await connection.getParsedAccountInfo(new PublicKey(mint));
const mintInfo = info.value.data.parsed.info;
console.log({
supply: mintInfo.supply, // base units, a string
decimals: mintInfo.decimals,
mintAuthority: mintInfo.mintAuthority, // null means revoked: supply is fixed
freezeAuthority: mintInfo.freezeAuthority, // null means no one can freeze holder accounts
});
A null value means revoked. Anyone can run this check on any token, which is why a fixed supply is a verifiable claim and not a promise.
New to the concept? Revoking mint and freeze authority, explained for token creators.