set_token_authority
Assign or modify authority permissions for Solana token mints and accounts, including minting tokens, freezing accounts, changing ownership, or closing accounts.
Instructions
Set or change authority for a token mint or account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| walletName | Yes | Name of the wallet with current authority | |
| tokenMint | Yes | Token mint address | |
| authorityType | Yes | Type of authority to set | |
| newAuthority | No | Address of new authority (or null to revoke authority) |
Implementation Reference
- src/index.ts:1086-1121 (handler)The handler function that implements the set_token_authority tool. It uses the Solana SPL token library's setAuthority function to change the authority type (MintTokens, FreezeAccount, etc.) for a given token mint.async function handleSetTokenAuthority(args: any) { const { walletName, tokenMint, authorityType, newAuthority } = args; const wallet = wallets.get(walletName); if (!wallet) { throw new Error(`Wallet '${walletName}' not found`); } ensureConnection(); const tokenMintPubkey = new PublicKey(tokenMint); const newAuthorityPubkey = newAuthority ? new PublicKey(newAuthority) : null; const authorityTypeMap: { [key: string]: AuthorityType } = { "MintTokens": AuthorityType.MintTokens, "FreezeAccount": AuthorityType.FreezeAccount, "AccountOwner": AuthorityType.AccountOwner, "CloseAccount": AuthorityType.CloseAccount }; const signature = await setAuthority( connection, wallet.keypair, tokenMintPubkey, wallet.keypair, authorityTypeMap[authorityType], newAuthorityPubkey ); return { success: true, signature, authorityType, newAuthority: newAuthority || "revoked", explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}` }; }
- src/index.ts:420-442 (schema)Input schema definition for the set_token_authority tool, specifying parameters like walletName, tokenMint, authorityType, and optional newAuthority.inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet with current authority" }, tokenMint: { type: "string", description: "Token mint address" }, authorityType: { type: "string", enum: ["MintTokens", "FreezeAccount", "AccountOwner", "CloseAccount"], description: "Type of authority to set" }, newAuthority: { type: "string", description: "Address of new authority (or null to revoke authority)" } }, required: ["walletName", "tokenMint", "authorityType"] }
- src/index.ts:417-443 (registration)Tool registration in the tools array, including name, description, and input schema. This array is returned by the ListToolsRequestSchema handler.{ name: "set_token_authority", description: "Set or change authority for a token mint or account", inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet with current authority" }, tokenMint: { type: "string", description: "Token mint address" }, authorityType: { type: "string", enum: ["MintTokens", "FreezeAccount", "AccountOwner", "CloseAccount"], description: "Type of authority to set" }, newAuthority: { type: "string", description: "Address of new authority (or null to revoke authority)" } }, required: ["walletName", "tokenMint", "authorityType"] } },
- src/index.ts:1345-1347 (helper)Switch case in the main CallToolRequestSchema handler that dispatches calls to the set_token_authority handler function.case "set_token_authority": result = await handleSetTokenAuthority(args); break;