fund_testnet
Fund Algorand testnet accounts using the official faucet to obtain test tokens for development and testing purposes.
Instructions
Fund an Algorand testnet account using the official faucet
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Algorand testnet address to fund |
Implementation Reference
- src/index.ts:390-420 (handler)Handler for the 'fund_testnet' tool. Parses input arguments using Zod schema, dynamically imports node-fetch, sends POST to Algorand testnet faucet API to fund the address, handles response or error.
case 'fund_testnet': { const parsed = FundTestnetArgsSchema.parse(args); try { // Use node-fetch for HTTP requests const fetch: typeof import('node-fetch') = (await import('node-fetch')).default; const faucetUrl = `https://bank.testnet.algorand.network/api/v2/accounts/${parsed.address}`; const response = await fetch(faucetUrl, { method: 'POST' }); if (!response.ok) { throw new Error(`Faucet request failed: ${response.statusText}`); } const result = await response.json(); return { content: [ { type: 'text', text: `Faucet request sent!\nStatus: ${result.message || 'Success'}\nCheck your account balance in a few seconds.`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Faucet funding failed: ${error}`, }, ], isError: true, }; } } - src/index.ts:1-4 (schema)Zod schema definition for 'fund_testnet' tool arguments: requires a string 'address'.
// FundTestnet tool schema const FundTestnetArgsSchema = z.object({ address: z.string(), }); - src/index.ts:142-155 (registration)Tool registration in the TOOLS array, defining name, description, and inputSchema matching the Zod schema.
{ name: 'fund_testnet', description: 'Fund an Algorand testnet account using the official faucet', inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Algorand testnet address to fund', }, }, required: ['address'], }, },