Skip to main content
Glama

Fund your leg

fund_leg
Destructive

Fund your side of an agreed HTLC cross-chain swap on-chain: approve and lock tokens, pay the BTC P2WSH, or sign the Solana escrow; returns the transaction ID.

Instructions

AUTONOMOUS SETTLEMENT: fund YOUR side of an agreed swap on-chain, signing with the agent's own wallet (HASHLOCK_EVM_KEY or a Bankr wallet via HASHLOCK_BANKR_API_KEY / the TRON, BTC or SOLANA key for that leg's chain). Funds the leg you give — approves the token (EVM/TRON) and locks it in the HTLC, pays the P2WSH (BTC), or signs the escrow transaction the server builds (Solana). Prerequisites: the deal is agreed and BOTH parties have set their settlement addresses (set_settlement_address). Returns the on-chain tx id. Fund your long leg first if you are the initiator — only under the hashlock of the secret this process generated for the deal. It settles only deals agreed through this MCP (the swap must match the side, assets, amounts and a price you agreed to), only in assets and through contracts pinned in this release for the network your own RPC is on, with a capped fee and timelock. As the counterparty it first reads the initiator's escrow on chain and refuses unless it pays YOUR key the agreed asset and amount under the agreed hashlock, with a timelock at least 2h past yours.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "swap_id": "<swap_id>"
    },
    "name": "fund_leg"
  }
}

Input Schema

NameRequiredDescriptionDefault
swap_idYesSwap id (swap.id from deal_status, or swapId once a deal is agreed)

Output Schema

NameRequiredDescriptionDefault
txNoOn-chain tx id
legNo
chainNo
errorNoSet instead when the call failed

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv1.11.1
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / swap_id / description
      Added value: +"Swap id (swap.id from deal_status, or swapId once a deal is agreed)"
    • addedInput schema / properties / swap_id / pattern
      Added value: +"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": {},
      +  "properties": {
      +    "chain": {
      +      "type": "string"
      +    },
      +    "error": {
      +      "additionalProperties": {},
      +      "description": "Set instead when the call failed",
      +      "properties": {
      +        "code": {
      +          "type": "string"
      +        },
      +        "is_retryable": {
      +          "type": "boolean"
      +        },
      +        "message": {
      +          "type": "string"
      +        },
      +        "recovery_hint": {
      +          "type": "string"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "leg": {
      +      "type": "string"
      +    },
      +    "tx": {
      +      "description": "On-chain tx id",
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
  2. Addedv0.10.0

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructive=true, idempotent=false and openWorld=true; the description adds real value beyond that by disclosing the key sources used, exactly what is approved/locked per chain, the hashlock-secret constraint, the fee cap and timelock bounds, and the counterparty-side on-chain verification with a 2h timelock margin. The main gap is retry/duplicate-funding safety: for a destructive, explicitly non-idempotent on-chain transfer, the description never says what happens on a second call or on partial failure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The critical constraint is front-loaded under an 'AUTONOMOUS SETTLEMENT' lead, and nearly every sentence carries a safety-relevant fact rather than filler. It is still a single dense, run-on paragraph that bundles eligibility, mechanics and refusal logic together, which makes it harder to scan than a short bulleted structure would be.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive on-chain settlement action it covers prerequisites, key sourcing, per-chain behavior and refusal conditions, and the output schema means the return value needn't be detailed (it still mentions the tx id). Missing pieces are edge-case behavior: what to do if the leg is already funded, how errors surface, and retry semantics.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With one parameter and 100% schema description coverage, the schema already defines swap_id (UUID, sourced from deal_status) fully. The description adds only indirect context ('the deal is agreed') and no format or sourcing detail beyond what the schema states, so this sits at the baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The first clause states a specific verb and resource ('fund YOUR side of an agreed swap on-chain') and immediately scopes it to the agent's own wallet and signing key. It goes further, spelling out the per-chain mechanic (approve+lock for EVM/TRON, P2WSH payment for BTC, signed escrow tx for Solana), which makes it unmistakable against siblings like claim_leg or refund_leg.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit prerequisites are named ('the deal is agreed and BOTH parties have set their settlement addresses'), including the sibling to call first (set_settlement_address). It also gives ordering advice for the initiator ('Fund your long leg first') and states the conditions under which the tool refuses, which is unusually actionable when-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.