HomeInicio/Docs/Settlement backendsBackends de liquidación

Ledger-neutral settlementLiquidación neutral de libro

Settlement backends

Backends de liquidación

Pacta never moves money directly. Escrow, collateral, and slashing all go through a single SettlementBackend interface, and every settlement implementation satisfies it. Base is Pacta's reference settlement network and default on-chain implementation - not a dependency. This is the design in one line: Base first, with a clean seam for others.

Pacta nunca mueve dinero directamente. La custodia, el colateral y el slashing pasan todos por una única interfaz SettlementBackend, y toda implementación de liquidación la satisface. Base es la red de liquidación de referencia de Pacta y su implementación on-chain por defecto, no una dependencia. El diseño en una línea: Base primero, con una costura limpia para otros.

Settlement sits behind an interface because the protocol is MIT-licensed and others will port it - and every port makes the reference implementation more valuable, not less. Registry verification deliberately stays off-chain: the trust root for a land title is the government registry, not a consensus mechanism, and the buying agent re-verifies it independently.

La liquidación vive detrás de una interfaz porque el protocolo es de licencia MIT y otros lo portarán; y cada port hace más valiosa la implementación de referencia, no menos. La verificación del registro se mantiene off-chain a propósito: la raíz de confianza de un título de propiedad es el registro público del gobierno, no un mecanismo de consenso, y el agente comprador la reverifica de forma independiente.

The interface

La interfaz

One interface, which the core depends on and every backend implements:

Una interfaz, de la que depende el core y que todo backend implementa:

interface SettlementBackend {
  readonly id: string;        // "ledger" | "base-escrow-vault"
  readonly currency: string;  // "USD"    | "USDC"

  openEscrow({ engagementId, buyer, provider, amountMinor }): EscrowHandle;
  fund(handle, amountMinor): SettlementReceipt;

  release(handle, authorization): SettlementReceipt;
  refund(handle, authorization): SettlementReceipt;
  split(handle, buyerMinor, providerMinor, authorization): SettlementReceipt;

  stakeBalance(provider): bigint;
  slash(provider, amountMinor, authorization): SettlementReceipt;
}

Four rules hold in every implementation, and they are what make the seam clean:

Cuatro reglas se cumplen en toda implementación, y son las que mantienen limpia la costura:

The two adapters that ship

Los dos adaptadores incluidos

ledger (default)(por defecto)

The internal double-entry ledger in integer cents. It requires no wallet, no chain, and no crypto dependencies: the full test suite passes with zero blockchain packages installed, and a CI check fails the build if any core file imports a chain or RPC library.

El libro contable interno de partida doble en centavos enteros. No requiere ni billetera, ni cadena, ni dependencias de cripto: la suite de pruebas completa pasa sin ningún paquete de blockchain instalado, y una verificación de CI rompe el build si algún archivo del core importa una librería de cadena o RPC.

base-escrow-vault

The reference on-chain implementation - a USDC EscrowVault on Base - shipped as a separate package that registers itself with the core. The core does not import it and does not depend on it; uninstalling the package leaves the ledger backend working unchanged.

La implementación on-chain de referencia -un EscrowVault de USDC en Base- distribuida como paquete aparte que se registra con el core. El core no lo importa ni depende de él; desinstalar el paquete deja el backend de libro funcionando sin cambios.

Selection is configuration, not code. The MCP tools are identical across backends - an agent cannot tell which one is running:

La selección es configuración, no código. Las herramientas MCP son idénticas entre backends: un agente no puede saber cuál está corriendo:

SETTLEMENT_BACKEND=ledger              # default - no wallet, no chain, no crypto
SETTLEMENT_BACKEND=base-escrow-vault   # reference onchain backend (USDC on Base)

The vault is unaudited testnet code. The reference EscrowVault targets Base Sepolia, carries a TVL cap and a pause, and is never for real funds. It is in security review and not yet deployed; the core protocol does not depend on it. See the settlement-base package for its status, addresses, and how to run Pacta against it.

El vault es código de testnet sin auditar. El EscrowVault de referencia apunta a Base Sepolia, tiene un tope de TVL y una pausa, y nunca es para fondos reales. Está en revisión de seguridad y aún no desplegado; el protocolo core no depende de él. Consulta el paquete settlement-base para su estado, direcciones y cómo correr Pacta contra él.

How to write a third backend

Cómo escribir un tercer backend

If you are porting Pacta to another settlement network, this is the whole job. Adding a backend requires implementing one interface and touching no core file:

Si estás portando Pacta a otra red de liquidación, este es todo el trabajo. Añadir un backend requiere implementar una interfaz y no tocar ningún archivo del core:

  1. Create a package that implements the eight SettlementBackend methods above. Keep amounts as integer minor units and make each operation atomic.
  2. Crea un paquete que implemente los ocho métodos de SettlementBackend de arriba. Mantén los montos como unidades menores enteras y haz atómica cada operación.
  3. Verify Authorization signatures against the agreement hash - in your contract if the funds are on-chain, or in code if they are not. Do not invent a new signature scheme; the flow already produced signatures bound to the agreement hash at agreement time.
  4. Verifica las firmas de Authorization contra el hash del acuerdo: en tu contrato si los fondos están on-chain, o en código si no. No inventes un esquema de firma nuevo; el flujo ya produjo firmas ligadas al hash del acuerdo al momento de acordar.
  5. Return the uniform SettlementReceipt. Populate the optional onchain block (tx hash, chain id, block number) if your backend settles on a chain; leave it null otherwise.
  6. Devuelve el SettlementReceipt uniforme. Rellena el bloque opcional onchain (hash de tx, chain id, número de bloque) si tu backend liquida en una cadena; déjalo en null si no.
  7. Register a factory via registerSettlementBackend(id, factory) before startup and select it with SETTLEMENT_BACKEND=your-id. No core edit is required, and the reference vault package is a worked example.
  8. Registra una fábrica con registerSettlementBackend(id, factory) antes del arranque y selecciónala con SETTLEMENT_BACKEND=tu-id. No hace falta editar el core, y el paquete del vault de referencia es un ejemplo resuelto.

Because the core calls only the interface, the same three example verticals (LandBridge, MedVoyage, Boa Vista) and the same 14 MCP tools work against any conforming backend without a line of change. That property is the point: a new chain adapter is cheap precisely because the neutrality is enforced, not merely promised.

Como el core solo llama a la interfaz, las mismas tres verticales de ejemplo (LandBridge, MedVoyage, Boa Vista) y las mismas 14 herramientas MCP funcionan contra cualquier backend conforme sin una línea de cambio. Esa propiedad es el punto: un nuevo adaptador de cadena es barato precisamente porque la neutralidad se hace cumplir, no solo se promete.

Interface source: src/settlement.js. Reference vault: packages/settlement-base. Anchoring, the other half of Pacta's Base story, is covered in Anchoring on Base.

Código de la interfaz: src/settlement.js. Vault de referencia: packages/settlement-base. El anclaje, la otra mitad de la historia de Pacta en Base, está en Anclaje en Base.