Pact Swap

Introduction to the API

PACT SWAP API Reference


API is in development

The API is currently in development and is subject to change. Please check back soon for updates.

REST API Overview

The PACT SWAP REST API provides a comprehensive set of endpoints for interacting with the decentralized exchange built on the Coinweb protocol. The API is organized into several contract modules, each serving specific functionality:

  • SWAP: Core swap functionality for users and market makers
  • ECDSA: Wallet balance and UTXO management for ECDSA-based wallets

All endpoints follow RESTful conventions and return JSON responses. The API uses:

  • GET requests for querying data (order information, swap status, balances, quotes)
  • POST requests for creating UI commands that generate QR code strings for Coinweb L2 transactions

Transaction composition endpoints (both GET and POST) return unsigned transaction data that can be signed and broadcast by your wallet.

Base URL

The API base URL is typically:

https://cwap-api.coinhq.store

Authentication

Most endpoints do not require authentication. However, when composing transactions, you'll need to sign them with your wallet before broadcasting to the blockchain.

Response Format

All endpoints return JSON responses. Error responses follow a standard format with appropriate HTTP status codes.

Transaction Composition

Endpoints that compose transactions (prefixed with compose) return unsigned transaction data. For Bitcoin-like blockchains (BTC, LTC, DOGE), you'll need to provide UTXO information and a public key. For EVM-compatible blockchains, the response includes chain-specific fields like chainId, value, to, and type.


This section provides an overview of the available API endpoints for interacting with the decentralized exchange.

SWAP

This contract module is for communicating with the PACT SWAP contract. The API is divided into two main sections:

  • Market Maker API: Endpoints for market makers to manage orders, check swap status, and finalize transactions
  • User API: Endpoints for users to get swap quotes and compose swap transactions

The compose routes can create an unsigned transaction that can be signed by your wallet of choice and broadcasted to the desired network.

Market Maker Endpoints

C1 (Bid) Order Management - UI Commands

These POST endpoints create UI commands (QR code strings) for managing C1 (Bid) orders. C1 orders are where market makers sell CWEB for L1 tokens. The UI commands can be used to compose Coinweb L2 transactions using the @coinweb/wallet-lib library or Coinweb Mobile Wallet.

C2 (Ask) Order Management - UI Commands

These POST endpoints create UI commands (QR code strings) for managing C2 (Ask) orders. C2 orders are where market makers sell L1 tokens for CWEB. The UI commands can be used to compose Coinweb L2 transactions using the @coinweb/wallet-lib library or Coinweb Mobile Wallet.

User Endpoints

ECDSA

The ECDSA contract module is for communication with the ECDSA User contract. The helper routes are for fetching balances and UTXOs for a given Coinweb wallet address identified by its public key. You can find out more about the ECDSA User contract here.

Was this documentation helpful? Any suggestions?