generate_deploy_link
Generate TON deployment deeplinks for compiled Tolk contracts. Computes contract addresses from code BoC and optional initial data to create wallet-ready ton:// links for deployment.
Instructions
Generates a TON deployment deeplink for a compiled Tolk contract. Accepts the compiled code BoC (base64) and optionally initial data BoC. Computes the contract address and returns ton:// deeplinks for wallet deployment.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| codeBoc64 | Yes | Base64-encoded BoC of the compiled contract code (from compile_tolk output) | |
| initialDataBoc64 | No | Base64-encoded BoC for the contract initial data cell (default: empty cell) | |
| workchain | No | Target workchain ID (default: 0, the basechain) | |
| amount | No | Amount in nanoTON to send with deploy message (default: "50000000" = 0.05 TON) |
Implementation Reference
- src/tools.ts:225-298 (handler)The handler function that executes the generate_deploy_link tool logic - it takes the compiled code and optional initial data, computes the contract address using TON's contractAddress function, creates a StateInit, and generates both ton:// deeplink and Tonkeeper web link for deployment
async (args) => { const { codeBoc64, initialDataBoc64, workchain, amount } = args; const wc = workchain ?? 0; const deployAmount = amount ?? "50000000"; let code: Cell; try { code = Cell.fromBase64(codeBoc64); } catch (err: any) { return { content: [{ type: "text", text: `Error: invalid codeBoc64 — ${err.message}` }], isError: true, }; } let data: Cell; if (initialDataBoc64) { try { data = Cell.fromBase64(initialDataBoc64); } catch (err: any) { return { content: [{ type: "text", text: `Error: invalid initialDataBoc64 — ${err.message}` }], isError: true, }; } } else { data = beginCell().endCell(); } const stateInit = { code, data }; const address = contractAddress(wc, stateInit); const stateInitCell = beginCell().store(storeStateInit(stateInit)).endCell(); const stateInitBoc64 = stateInitCell.toBoc().toString("base64"); const tonLink = `ton://transfer/${address.toString()}?amount=${deployAmount}&stateInit=${encodeURIComponent(stateInitBoc64)}`; const tonkeeperLink = `https://app.tonkeeper.com/transfer/${address.toString()}?amount=${deployAmount}&stateInit=${encodeURIComponent(stateInitBoc64)}`; const lines: string[] = [ `## Deployment Information`, "", `**Contract address:** \`${address.toString()}\``, `**Address (raw):** \`${address.toRawString()}\``, `**Target workchain:** ${wc}`, `**Deploy amount:** ${deployAmount} nanoTON (${Number(deployAmount) / 1e9} TON)`, "", "### Deployment Links", "", `**ton:// deeplink** (universal):`, "```", tonLink, "```", "", `**Tonkeeper link:**`, "```", tonkeeperLink, "```", "", "### How to deploy", "", "1. Open one of the links above in a TON wallet (Tonkeeper, Tonhub, etc.)", "2. Confirm the transaction — it will deploy the contract to the address shown above", "3. The contract address is deterministic — same code + data always produces the same address", "", `> **Note:** Different initial data produces a different contract address. ` + `If no initialDataBoc64 was provided, an empty cell was used.`, "", "### StateInit BoC (base64)", "```", stateInitBoc64, "```", ]; return { content: [{ type: "text", text: lines.join("\n") }] }; }, - src/tools.ts:213-224 (schema)Input validation schema using zod that defines the tool parameters: codeBoc64 (required base64 BoC), initialDataBoc64 (optional base64 BoC for initial data), workchain (optional, default 0), and amount (optional nanoTON amount, default 50000000)
codeBoc64: z.string().describe("Base64-encoded BoC of the compiled contract code (from compile_tolk output)"), initialDataBoc64: z .string() .optional() .describe("Base64-encoded BoC for the contract initial data cell (default: empty cell)"), workchain: z.number().optional().describe("Target workchain ID (default: 0, the basechain)"), amount: z .string() .regex(/^\d+$/, "amount must be a non-negative integer string (nanoTON)") .optional() .describe('Amount in nanoTON to send with deploy message (default: "50000000" = 0.05 TON)'), }, - src/tools.ts:207-299 (registration)Tool registration using server.tool() that registers the generate_deploy_link tool with the MCP server, including its name, description, schema, and handler function
server.tool( "generate_deploy_link", "Generates a TON deployment deeplink for a compiled Tolk contract. " + "Accepts the compiled code BoC (base64) and optionally initial data BoC. " + "Computes the contract address and returns ton:// deeplinks for wallet deployment.", { codeBoc64: z.string().describe("Base64-encoded BoC of the compiled contract code (from compile_tolk output)"), initialDataBoc64: z .string() .optional() .describe("Base64-encoded BoC for the contract initial data cell (default: empty cell)"), workchain: z.number().optional().describe("Target workchain ID (default: 0, the basechain)"), amount: z .string() .regex(/^\d+$/, "amount must be a non-negative integer string (nanoTON)") .optional() .describe('Amount in nanoTON to send with deploy message (default: "50000000" = 0.05 TON)'), }, async (args) => { const { codeBoc64, initialDataBoc64, workchain, amount } = args; const wc = workchain ?? 0; const deployAmount = amount ?? "50000000"; let code: Cell; try { code = Cell.fromBase64(codeBoc64); } catch (err: any) { return { content: [{ type: "text", text: `Error: invalid codeBoc64 — ${err.message}` }], isError: true, }; } let data: Cell; if (initialDataBoc64) { try { data = Cell.fromBase64(initialDataBoc64); } catch (err: any) { return { content: [{ type: "text", text: `Error: invalid initialDataBoc64 — ${err.message}` }], isError: true, }; } } else { data = beginCell().endCell(); } const stateInit = { code, data }; const address = contractAddress(wc, stateInit); const stateInitCell = beginCell().store(storeStateInit(stateInit)).endCell(); const stateInitBoc64 = stateInitCell.toBoc().toString("base64"); const tonLink = `ton://transfer/${address.toString()}?amount=${deployAmount}&stateInit=${encodeURIComponent(stateInitBoc64)}`; const tonkeeperLink = `https://app.tonkeeper.com/transfer/${address.toString()}?amount=${deployAmount}&stateInit=${encodeURIComponent(stateInitBoc64)}`; const lines: string[] = [ `## Deployment Information`, "", `**Contract address:** \`${address.toString()}\``, `**Address (raw):** \`${address.toRawString()}\``, `**Target workchain:** ${wc}`, `**Deploy amount:** ${deployAmount} nanoTON (${Number(deployAmount) / 1e9} TON)`, "", "### Deployment Links", "", `**ton:// deeplink** (universal):`, "```", tonLink, "```", "", `**Tonkeeper link:**`, "```", tonkeeperLink, "```", "", "### How to deploy", "", "1. Open one of the links above in a TON wallet (Tonkeeper, Tonhub, etc.)", "2. Confirm the transaction — it will deploy the contract to the address shown above", "3. The contract address is deterministic — same code + data always produces the same address", "", `> **Note:** Different initial data produces a different contract address. ` + `If no initialDataBoc64 was provided, an empty cell was used.`, "", "### StateInit BoC (base64)", "```", stateInitBoc64, "```", ]; return { content: [{ type: "text", text: lines.join("\n") }] }; }, );