transfer_asset
Transfer Algorand Standard Assets between accounts securely using a sender mnemonic, recipient address, asset ID, and specified amount. Supports optional transaction notes for clarity.
Instructions
Transfer an Algorand Standard Asset
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount to transfer | |
| assetId | Yes | Asset ID to transfer | |
| fromMnemonic | Yes | Sender account mnemonic phrase (25 words) | |
| note | No | Optional transaction note | |
| toAddress | Yes | Recipient address |
Input Schema (JSON Schema)
{
"properties": {
"amount": {
"description": "Amount to transfer",
"type": "number"
},
"assetId": {
"description": "Asset ID to transfer",
"type": "number"
},
"fromMnemonic": {
"description": "Sender account mnemonic phrase (25 words)",
"type": "string"
},
"note": {
"description": "Optional transaction note",
"type": "string"
},
"toAddress": {
"description": "Recipient address",
"type": "string"
}
},
"required": [
"fromMnemonic",
"toAddress",
"assetId",
"amount"
],
"type": "object"
}
Implementation Reference
- src/algorand.ts:271-310 (handler)Core handler function in AlgorandService that performs the actual asset transfer using algosdk.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:265-294 (registration)Tool registration in the TOOLS array used by MCP server for listing tools.{ 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: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:646-675 (handler)MCP server request handler for call_tool requests, dispatching to the AlgorandService.transferAsset method after validation.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, }; } }