transfer_asset
Transfer Algorand Standard Assets between accounts using mnemonic authentication, asset IDs, and specified amounts on the Algorand blockchain.
Instructions
Transfer an Algorand Standard Asset
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"fromMnemonic": "<fromMnemonic>",
"toAddress": "<toAddress>",
"assetId": "<assetId>",
"amount": "<amount>"
},
"name": "transfer_asset"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fromMnemonic | Yes | Sender account mnemonic phrase (25 words) | |
| toAddress | Yes | Recipient address | |
| assetId | Yes | Asset ID to transfer | |
| amount | Yes | Amount to transfer | |
| note | No | Optional transaction note |
Implementation Reference
- src/algorand.ts:271-310 (handler)Core handler function that implements the asset transfer logic using algosdk: imports account, creates asset transfer transaction, signs it, sends it, and waits for confirmation.
async transferAsset( fromMnemonic: string, toAddress: string, assetId: number, amount: number, note?: string ) { try { const fromAccount = this.importAccountFromMnemonic(fromMnemonic); const suggestedParams = await this.algodClient.getTransactionParams().do(); const transferParams: any = { sender: fromAccount.addr, receiver: toAddress, amount, assetIndex: assetId, suggestedParams, }; if (note) { transferParams.note = new TextEncoder().encode(note); } const txn = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject(transferParams); const signedTxn = txn.signTxn(fromAccount.sk); const response = await this.algodClient.sendRawTransaction(signedTxn).do(); const txId = response.txid || txn.txID(); // Wait for confirmation const result = await algosdk.waitForConfirmation(this.algodClient, txId, 4); return { txId, confirmedRound: result.confirmedRound, }; } catch (error) { throw new Error(`Asset transfer failed: ${error}`); } } - src/index.ts:63-69 (schema)Zod schema for validating input arguments to the transfer_asset tool.
const TransferAssetArgsSchema = z.object({ fromMnemonic: z.string(), toAddress: z.string(), assetId: z.number(), amount: z.number(), note: z.string().optional(), }); - src/index.ts:266-294 (registration)Tool registration in the TOOLS array, defining name, description, and input schema for MCP server.
name: 'transfer_asset', description: 'Transfer an Algorand Standard Asset', inputSchema: { type: 'object', properties: { fromMnemonic: { type: 'string', description: 'Sender account mnemonic phrase (25 words)', }, toAddress: { type: 'string', description: 'Recipient address', }, assetId: { type: 'number', description: 'Asset ID to transfer', }, amount: { type: 'number', description: 'Amount to transfer', }, note: { type: 'string', description: 'Optional transaction note', }, }, required: ['fromMnemonic', 'toAddress', 'assetId', 'amount'], }, }, - src/index.ts:646-675 (handler)MCP server request handler for call_tool that parses arguments with schema and delegates execution to AlgorandService.transferAsset, formats response.
case 'transfer_asset': { const parsed = TransferAssetArgsSchema.parse(args); try { const result = await algorandService.transferAsset( parsed.fromMnemonic, parsed.toAddress, parsed.assetId, parsed.amount, parsed.note ); return { content: [ { type: 'text', text: `Asset Transfer Successful!\nAsset ID: ${parsed.assetId}\nAmount: ${parsed.amount}\nTransaction ID: ${result.txId}\nConfirmed in Round: ${result.confirmedRound}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Asset transfer failed: ${error}`, }, ], isError: true, }; } }