Skip to main content
Glama

create_tx

Generate cross-chain swap transaction data for the deBridge DLN protocol to transfer tokens between different blockchain networks.

Instructions

Create a cross-chain swap transaction via the deBridge DLN protocol. Returns transaction data that must be signed and submitted to the source chain. Use search_tokens first to resolve token names to addresses and get_supported_chains to find chain IDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
srcChainIdYesSource chain ID. Examples: '1' (Ethereum), '56' (BNB Chain), '137' (Polygon), '7565164' (Solana)
srcChainTokenInYesToken address on the source chain to swap from. Use 0x0000000000000000000000000000000000000000 for native tokens (ETH, BNB, etc.)
srcChainTokenInAmountYesAmount of source token in smallest units (wei, lamports). Example: '1000000000000000000' for 1 ETH (18 decimals), '1000000' for 1 USDC (6 decimals)
dstChainIdYesDestination chain ID. Examples: '1' (Ethereum), '56' (BNB Chain), '42161' (Arbitrum)
dstChainTokenOutYesToken address on the destination chain to receive
dstChainTokenOutAmountNoOutput amount in smallest units, or 'auto' for best available quote (default: 'auto')auto
dstChainTokenOutRecipientYesWallet address on the destination chain that will receive the tokens
srcChainOrderAuthorityAddressYesAddress on the source chain authorized to manage the order (cancel, etc). Typically the sender's wallet address
dstChainOrderAuthorityAddressYesAddress on the destination chain authorized to manage the order. Typically the recipient's wallet address
affiliateFeePercentNoAffiliate fee percentage (e.g. 0.1 for 0.1%)
affiliateFeeRecipientNoWallet address to receive affiliate fees
prependOperatingExpensesNoWhether to prepend estimated operating expenses to the input amount

Implementation Reference

  • The main handler function that executes the create_tx tool logic. It constructs the DLN API URL, sets query parameters from the input, makes the fetch request, and returns either the transaction data or an error response.
    async (params) => {
      const url = new URL(`${DLN_API_BASE}/dln/order/create-tx`);
    
      url.searchParams.set("srcChainId", params.srcChainId);
      url.searchParams.set("srcChainTokenIn", params.srcChainTokenIn);
      url.searchParams.set("srcChainTokenInAmount", params.srcChainTokenInAmount);
      url.searchParams.set("dstChainId", params.dstChainId);
      url.searchParams.set("dstChainTokenOut", params.dstChainTokenOut);
      url.searchParams.set("dstChainTokenOutAmount", params.dstChainTokenOutAmount);
      url.searchParams.set("dstChainTokenOutRecipient", params.dstChainTokenOutRecipient);
      url.searchParams.set("srcChainOrderAuthorityAddress", params.srcChainOrderAuthorityAddress);
      url.searchParams.set("dstChainOrderAuthorityAddress", params.dstChainOrderAuthorityAddress);
    
      if (params.affiliateFeePercent !== undefined) {
        url.searchParams.set("affiliateFeePercent", String(params.affiliateFeePercent));
      }
      if (params.affiliateFeeRecipient) {
        url.searchParams.set("affiliateFeeRecipient", params.affiliateFeeRecipient);
      }
      if (params.prependOperatingExpenses !== undefined) {
        url.searchParams.set("prependOperatingExpenses", String(params.prependOperatingExpenses));
      }
    
      const response = await fetch(url.toString());
      const body = await response.json();
    
      if (!response.ok) {
        return {
          isError: true,
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({ error: body.message ?? body.error ?? body, statusCode: response.status }),
            },
          ],
        };
      }
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(body),
          },
        ],
      };
    },
  • Input schema definition using Zod validation for the create_tx tool. Defines all required and optional parameters including source/destination chain IDs, token addresses, amounts, recipient addresses, and optional affiliate fee settings.
    inputSchema: {
      srcChainId: z
        .string()
        .describe("Source chain ID. Examples: '1' (Ethereum), '56' (BNB Chain), '137' (Polygon), '7565164' (Solana)"),
      srcChainTokenIn: z
        .string()
        .describe(
          "Token address on the source chain to swap from. Use 0x0000000000000000000000000000000000000000 for native tokens (ETH, BNB, etc.)",
        ),
      srcChainTokenInAmount: z
        .string()
        .describe(
          "Amount of source token in smallest units (wei, lamports). Example: '1000000000000000000' for 1 ETH (18 decimals), '1000000' for 1 USDC (6 decimals)",
        ),
      dstChainId: z
        .string()
        .describe("Destination chain ID. Examples: '1' (Ethereum), '56' (BNB Chain), '42161' (Arbitrum)"),
      dstChainTokenOut: z
        .string()
        .describe("Token address on the destination chain to receive"),
      dstChainTokenOutAmount: z
        .string()
        .optional()
        .default("auto")
        .describe("Output amount in smallest units, or 'auto' for best available quote (default: 'auto')"),
      dstChainTokenOutRecipient: z
        .string()
        .describe("Wallet address on the destination chain that will receive the tokens"),
      srcChainOrderAuthorityAddress: z
        .string()
        .describe(
          "Address on the source chain authorized to manage the order (cancel, etc). Typically the sender's wallet address",
        ),
      dstChainOrderAuthorityAddress: z
        .string()
        .describe(
          "Address on the destination chain authorized to manage the order. Typically the recipient's wallet address",
        ),
      affiliateFeePercent: z
        .number()
        .optional()
        .describe("Affiliate fee percentage (e.g. 0.1 for 0.1%)"),
      affiliateFeeRecipient: z
        .string()
        .optional()
        .describe("Wallet address to receive affiliate fees"),
      prependOperatingExpenses: z
        .boolean()
        .optional()
        .describe("Whether to prepend estimated operating expenses to the input amount"),
    },
  • The registerCreateTx function that registers the 'create_tx' tool with the MCP server, including its description, input schema, and handler callback.
    export function registerCreateTx(server: McpServer) {
      server.registerTool(
        "create_tx",
        {
          description:
            "Create a cross-chain swap transaction via the deBridge DLN protocol. Returns transaction data that must be signed and submitted to the source chain. Use search_tokens first to resolve token names to addresses and get_supported_chains to find chain IDs.",
          inputSchema: {
            srcChainId: z
              .string()
              .describe("Source chain ID. Examples: '1' (Ethereum), '56' (BNB Chain), '137' (Polygon), '7565164' (Solana)"),
            srcChainTokenIn: z
              .string()
              .describe(
                "Token address on the source chain to swap from. Use 0x0000000000000000000000000000000000000000 for native tokens (ETH, BNB, etc.)",
              ),
            srcChainTokenInAmount: z
              .string()
              .describe(
                "Amount of source token in smallest units (wei, lamports). Example: '1000000000000000000' for 1 ETH (18 decimals), '1000000' for 1 USDC (6 decimals)",
              ),
            dstChainId: z
              .string()
              .describe("Destination chain ID. Examples: '1' (Ethereum), '56' (BNB Chain), '42161' (Arbitrum)"),
            dstChainTokenOut: z
              .string()
              .describe("Token address on the destination chain to receive"),
            dstChainTokenOutAmount: z
              .string()
              .optional()
              .default("auto")
              .describe("Output amount in smallest units, or 'auto' for best available quote (default: 'auto')"),
            dstChainTokenOutRecipient: z
              .string()
              .describe("Wallet address on the destination chain that will receive the tokens"),
            srcChainOrderAuthorityAddress: z
              .string()
              .describe(
                "Address on the source chain authorized to manage the order (cancel, etc). Typically the sender's wallet address",
              ),
            dstChainOrderAuthorityAddress: z
              .string()
              .describe(
                "Address on the destination chain authorized to manage the order. Typically the recipient's wallet address",
              ),
            affiliateFeePercent: z
              .number()
              .optional()
              .describe("Affiliate fee percentage (e.g. 0.1 for 0.1%)"),
            affiliateFeeRecipient: z
              .string()
              .optional()
              .describe("Wallet address to receive affiliate fees"),
            prependOperatingExpenses: z
              .boolean()
              .optional()
              .describe("Whether to prepend estimated operating expenses to the input amount"),
          },
        },
        async (params) => {
          const url = new URL(`${DLN_API_BASE}/dln/order/create-tx`);
    
          url.searchParams.set("srcChainId", params.srcChainId);
          url.searchParams.set("srcChainTokenIn", params.srcChainTokenIn);
          url.searchParams.set("srcChainTokenInAmount", params.srcChainTokenInAmount);
          url.searchParams.set("dstChainId", params.dstChainId);
          url.searchParams.set("dstChainTokenOut", params.dstChainTokenOut);
          url.searchParams.set("dstChainTokenOutAmount", params.dstChainTokenOutAmount);
          url.searchParams.set("dstChainTokenOutRecipient", params.dstChainTokenOutRecipient);
          url.searchParams.set("srcChainOrderAuthorityAddress", params.srcChainOrderAuthorityAddress);
          url.searchParams.set("dstChainOrderAuthorityAddress", params.dstChainOrderAuthorityAddress);
    
          if (params.affiliateFeePercent !== undefined) {
            url.searchParams.set("affiliateFeePercent", String(params.affiliateFeePercent));
          }
          if (params.affiliateFeeRecipient) {
            url.searchParams.set("affiliateFeeRecipient", params.affiliateFeeRecipient);
          }
          if (params.prependOperatingExpenses !== undefined) {
            url.searchParams.set("prependOperatingExpenses", String(params.prependOperatingExpenses));
          }
    
          const response = await fetch(url.toString());
          const body = await response.json();
    
          if (!response.ok) {
            return {
              isError: true,
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({ error: body.message ?? body.error ?? body, statusCode: response.status }),
                },
              ],
            };
          }
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(body),
              },
            ],
          };
        },
      );
    }
  • src/server.ts:38-38 (registration)
    Registration call where registerCreateTx is invoked to add the create_tx tool to the server instance.
    registerCreateTx(server);
  • src/server.ts:8-8 (registration)
    Import statement that imports the registerCreateTx function from the tools module.
    import { registerCreateTx } from "./tools/create-tx.js";

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/debridge-finance/de-bridge'

If you have feedback or need assistance with the MCP directory API, please join our Discord server