create_token_account
Create an associated token account for SPL tokens by specifying a wallet name and token mint address. This enables secure token management and transactions on the Solana blockchain.
Instructions
Create associated token account for SPL tokens
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| walletName | Yes | Name of the wallet | |
| tokenMint | Yes | Token mint address |
Implementation Reference
- src/index.ts:835-870 (handler)The handler function that creates an associated token account (ATA) for the specified wallet and token mint by constructing and signing a transaction using createAssociatedTokenAccountInstruction from @solana/spl-token.async function handleCreateTokenAccount(args: any) { const { walletName, tokenMint } = args; const wallet = wallets.get(walletName); if (!wallet) { throw new Error(`Wallet '${walletName}' not found`); } ensureConnection(); const tokenMintPubkey = new PublicKey(tokenMint); const tokenAccount = await getAssociatedTokenAddress(tokenMintPubkey, wallet.keypair.publicKey); const transaction = new Transaction().add( createAssociatedTokenAccountInstruction( wallet.keypair.publicKey, tokenAccount, wallet.keypair.publicKey, tokenMintPubkey ) ); const { blockhash } = await connection.getLatestBlockhash(); transaction.recentBlockhash = blockhash; transaction.feePayer = wallet.keypair.publicKey; transaction.sign(wallet.keypair); const signature = await connection.sendTransaction(transaction, [wallet.keypair]); return { success: true, tokenAccount: tokenAccount.toString(), signature, explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}` }; }
- src/index.ts:271-288 (registration)Tool definition and registration in the tools array used by the ListToolsRequestSchema handler, including name, description, and input schema.{ name: "create_token_account", description: "Create associated token account for SPL tokens", inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet" }, tokenMint: { type: "string", description: "Token mint address" } }, required: ["walletName", "tokenMint"] } },
- src/index.ts:1324-1326 (registration)Dispatch case in the switch statement of the CallToolRequestSchema handler that routes calls to the create_token_account handler function.case "create_token_account": result = await handleCreateTokenAccount(args); break;