CREATE_DEPOSIT_ADDRESS
Generate a cryptocurrency deposit address by specifying the currency and network type through your Upbit private API.
Instructions
Request creation of a deposit address (requires private API)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| currency | Yes | ||
| net_type | Yes |
Implementation Reference
- The execute function that handles the CREATE_DEPOSIT_ADDRESS tool: ensures private API is enabled, signs a JWT token with the params, and POSTs to /deposits/coin_address to request creation of a deposit address.
export const createDepositAddressTool = { name: "CREATE_DEPOSIT_ADDRESS", description: "Request creation of a deposit address (requires private API)", parameters: paramsSchema, execute: async (params: Params) => { ensurePrivateEnabled(); const baseURL = `${config.upbit.baseUrl}${config.upbit.apiBasePath}`; const client = createHttpClient(baseURL); const token = signJwtToken(params); const data = await fetchJson<unknown>(client, "/deposits/coin_address", { method: "POST", data: params, headers: { Authorization: `Bearer ${token}` }, }); return JSON.stringify(data, null, 2); }, } as const; - Zod schema defining input parameters: currency (string) and net_type (string), strict mode enabled.
const paramsSchema = z .object({ currency: z.string(), net_type: z.string(), }) .strict(); - src/index.ts:45-45 (registration)Registration of the createDepositAddressTool via server.addTool() in the main function.
server.addTool(createDepositAddressTool); - src/lib/upbit-auth.ts:18-41 (helper)signJwtToken helper: creates a JWT with access_key, nonce, and a SHA-512 hash of sorted query params.
export function signJwtToken( params?: Record<string, string | number | boolean | undefined>, ): string { const payload: Record<string, unknown> = { access_key: config.upbit.accessKey, nonce: crypto.randomUUID(), }; if (params && Object.keys(params).length > 0) { const searchParams = new URLSearchParams(); const sortedKeys = Object.keys(params).sort(); for (const key of sortedKeys) { const value = params[key]; if (value === undefined) continue; searchParams.append(key, String(value)); } const encoded = searchParams.toString(); const queryHash = crypto.createHash("sha512").update(encoded).digest("hex"); payload.query_hash = queryHash; payload.query_hash_alg = "SHA512"; } return jwt.sign(payload, config.upbit.secretKey as string); } - src/lib/upbit-auth.ts:5-16 (helper)ensurePrivateEnabled helper: validates that private API trading is enabled and API keys are configured.
export function ensurePrivateEnabled(): void { if (!config.upbit.enablePrivate) { throw new Error( "Private trading tools are disabled. Set UPBIT_ENABLE_TRADING=true to enable.", ); } if (!config.upbit.accessKey || !config.upbit.secretKey) { throw new Error( "Upbit API keys are not configured. Set UPBIT_ACCESS_KEY and UPBIT_SECRET_KEY.", ); } }