set_token_authority
Change or revoke authority for Solana token mints and accounts to manage permissions like minting tokens, freezing accounts, or transferring ownership.
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 main handler function that implements the set_token_authority tool logic. It retrieves the wallet, ensures Solana connection, maps string authorityType to AuthorityType enum, and calls setAuthority from @solana/spl-token library to change the authority on the 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 (JSON Schema) for validating tool arguments: requires walletName, tokenMint, authorityType (enum: MintTokens, FreezeAccount, AccountOwner, CloseAccount); 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 global tools array returned by ListToolsRequest handler, defining name, description, and inputSchema.{ 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 (registration)Runtime dispatch registration in the CallToolRequest switch statement, mapping tool name to the corresponding handler function.case "set_token_authority": result = await handleSetTokenAuthority(args); break;