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.storeAuthentication
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
Get All C1 Orders
Retrieves all C1 orders from the specified C1 token contract. C1 orders are bid orders where market makers sell CWEB for L1 tokens.
Get All C2 Orders
Retrieves all C2 market maker orders from the specified C2 token contract. C2 orders are Ask orders where market makers sell L1 tokens for CWEB.
Get Reversed Orders
Retrieves all Reversed C1 orders from the specified C1 token contract address. Reversed orders are created when a C2 order can't be found for a swap or when an expired PACT is converted.
Get Swap Status
Retrieves the status of a swap transaction and returns the L1 transaction ID of the receiving transaction if the swap has been finalized.
Get PACT Info
Retrieves complete information about an execution request (PACT) identified by an L1 transaction ID.
Compose Finalize TX
Composes a finalization transaction for a specific execution request (PACT). Used by market makers to finalize a swap by sending destination tokens to the user.
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.
Create C1 Order (BTC/LTC/DOGE)
Creates a UI command for creating a single UTXO-based C1 (Bid) order for Bitcoin-like blockchains (BTC, LTC, DOGE).
Create C1 Order (EVM)
Creates a UI command for creating a single EVM C1 (Bid) order for EVM-compatible blockchains (ETH, USDC, etc.).
Create Multiple C1 Orders (BTC/LTC/DOGE)
Creates a UI command for creating multiple UTXO-based C1 (Bid) orders in a single batch for Bitcoin-like blockchains.
Create Multiple C1 Orders (EVM)
Creates a UI command for creating multiple EVM C1 (Bid) orders in a single batch for EVM-compatible blockchains.
Cancel C1 Order
Creates a UI command for canceling a single C1 (Bid) order.
Cancel Multiple C1 Orders
Creates a UI command for canceling multiple C1 (Bid) orders in a single batch.
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.
Create C2 Order
Creates a UI command for creating a single C2 (Ask) order where market makers sell L1 tokens for CWEB.
Create Multiple C2 Orders
Creates a UI command for creating multiple C2 (Ask) orders in a single batch.
Cancel C2 Order
Creates a UI command for canceling a single C2 (Ask) order.
Cancel Multiple C2 Orders
Creates a UI command for canceling multiple C2 (Ask) orders in a single batch.
Deposit CWEB Collateral
Creates a UI command for depositing CWEB collateral into the C2 (Ask) token contract. The deposit amount plus deposit fee will be deducted from the wallet.
Withdraw CWEB Collateral
Creates a UI command for withdrawing CWEB collateral from the C2 (Ask) token contract. The withdraw fee will be deducted from the wallet.
User Endpoints
Get Swap Quotes By Amount From
Retrieves multiple swap quotes from available market makers based on the amount of source tokens you want to send.
Get Swap Quotes By Amount To
Retrieves multiple swap quotes from available market makers based on the amount of destination tokens you want to receive.
Compose Swap TX By Amount From
Composes a swap transaction based on the amount of source tokens you want to send. The transaction can be signed and broadcast to execute the swap.
Compose Swap TX By Amount To
Composes a swap transaction based on the amount of destination tokens you want to receive. The transaction can be signed and broadcast to execute the swap.
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.
Get Wallet Balance CWEB
Retrieves the CWEB token balance for an ECDSA wallet identified by its public key, without detailed UTXO information.
Get Wallet Balance CWEB With UTXOs
Retrieves the CWEB token balance for an ECDSA wallet identified by its public key, including detailed information about all unspent transaction outputs (UTXOs).
Batch Get Wallet Balance CWEB
Retrieves CWEB token balances for multiple ECDSA wallets identified by their public keys, without detailed UTXO information.
Batch Get Wallet Balance CWEB With UTXOs
Retrieves CWEB token balances for multiple ECDSA wallets identified by their public keys, including detailed information about all UTXOs for each wallet.
Was this documentation helpful? Any suggestions?