Compose swap transaction based on C1 order ID
Composes a swap transaction based on the C1 order ID. This endpoint queries the C1 contract to retrieve the order details and constructs a transaction that can be signed and broadcast to execute the swap. The transaction is composed for the source blockchain and includes all necessary parameters. For Bitcoin-like transactions (BTC, LTC, DOGE), you must provide UTXO information and a public key. The response includes the raw transaction data and optional EVM-specific fields (chainId, value, to, type) for EVM-compatible blockchains. The composed transaction can then be signed by the user's wallet and broadcast to the blockchain to execute the swap.
Query Parameters
The type of the source token blockchain. Used to determine the blockchain type for the source token (e.g., "btc", "eth", "usdc", "ltc", "doge"). This determines which blockchain the swap transaction will be created for.
"eth""eth" | "btc" | "ltc" | "doge" | "bnb" | "pol" | "trx" | "usdt_trx" | "usdt_bnb" | "usdc_bnb" | "usd1_bnb" | "wbtc_bnb" | "usdt_eth" | "wbtc_eth" | "usdc_eth" | "usd1_eth" | "usdt_pol"The type of the destination token blockchain. Used to determine the blockchain type for the destination token (e.g., "btc", "eth", "usdc", "ltc", "doge"). This determines which blockchain will receive the swapped tokens.
"btc""eth" | "btc" | "ltc" | "doge" | "bnb" | "pol" | "trx" | "usdt_trx" | "usdt_bnb" | "usdc_bnb" | "usd1_bnb" | "wbtc_bnb" | "usdt_eth" | "wbtc_eth" | "usdc_eth" | "usd1_eth" | "usdt_pol"The wallet address on the destination blockchain that will receive the swapped tokens. This should be a valid address for the destination blockchain type (e.g., Bitcoin address for BTC, Ethereum address for ETH).
The public key for the source wallet. Required only when fromType is "btc" (or other UTXO-based chains). This is used to construct the transaction for Bitcoin-like blockchains. Should be a hex string without 0x prefix.
The wallet address on the source blockchain that will send the tokens. This should be a valid address for the source blockchain type (e.g., Bitcoin address for BTC, Ethereum address for ETH).
The C1 contract address for the source token. This is the L2 contract address of the C1 (consumer) contract that handles the source token in the swap.
The C2 contract address for the source token. This is the L2 contract address of the C2 (market maker) contract that handles the source token in the swap.
The C1 contract address for the destination token. This is the L2 contract address of the C1 (consumer) contract that handles the destination token in the swap.
The C2 contract address for the destination token. This is the L2 contract address of the C2 (market maker) contract that handles the destination token in the swap.
The amount of source tokens you want to send. This is specified in the smallest unit of the source token (e.g., satoshis for BTC, wei for ETH). The endpoint will calculate how much of the destination token you will receive and compose the transaction accordingly.
The C1 order ID for the source token. This is the order ID of the source token in the C1 contract.
JSON string containing UTXO information for Bitcoin-like transactions. Required only when fromType is "btc", "ltc", or "doge". Format: JSON array of objects with structure: [{txid: string, vout: number, value: number}, ...]. Each object represents an unspent transaction output that will be used to fund the swap.
Backend URL. Default is https://api-cloud.coinweb.io/wallet. This URL is used to query available LPs orders and compose the swap transaction.
uriPreset ID for swap configuration. This identifies a specific swap configuration preset that defines transaction parameters, routing preferences, or other swap settings. Different presets may have different fee structures, routing strategies, or execution parameters.
Response Body
curl -X GET "https://cwap-api-dev.coinhq.store/pactswap_cm/composeSwapTxByC1OrderId?fromType=eth&toType=eth&toWalletAddress=string&fromPublicKey=020a89e0698443aaf4ecd613317d2fdf90ef73b99244182fc7bb3c6b85f375b876&fromWalletAddress=string&fromC1ContractId=0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85&fromC2ContractId=0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85&toC1ContractId=0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85&toC2ContractId=0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85&amountFrom=0&c1OrderId=0x123&utxos=%5B%7B%22txid%22%3A%22a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d%22%2C%22vout%22%3A0%2C%22value%22%3A50000000%7D%5D&backendUrl=https%3A%2F%2Fapi-cloud.coinweb.io%2Fwallet&preset=0"{
"rawTx": "0100000001...",
"chainId": 1,
"value": "0",
"to": "0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85",
"type": "eip1559"
}Was this documentation helpful? Any suggestions?
Last updated on