Complete a cross-chain swap in 3 steps
curl --location 'https://api.dkit.xyz/v1/quote' \
--header 'Content-Type: application/json' \
--header 'x-api-key: 86c3fc76-25c8-455c-8d6d-0ecea88d0f6e' \
--data '{
"sellAsset": "ETH.ETH",
"sellAmount": "0.5",
"buyAsset": "BTC.BTC",
"slippage": 3,
"affiliate": "dkit",
"affiliateFee": 50,
"includeTx": true,
"providers": [
"THORCHAIN"
],
"sourceAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
"destinationAddress": "bc1qns9f7yfx3ry9lj6yz7c9er0vwa0ye2eklpzqfw"
}'
quoteId
and routeIndex
of the response are used to fetch the status of the swap via the /track
endpoint and return rich information on the route.Example Response
{
"quoteId": "a7c4b3ef-51d2-4c78-b8e1-8b3e12f7a6d9",
"routes": [
{
"buyAsset": "BTC.BTC",
"destinationAddress": "bc1qns9f7yfx3ry9lj6yz7c9er0vwa0ye2eklpzqfw",
"estimatedTime": {
"inbound": 600,
"swap": 6,
"outbound": 600,
"total": 1206
},
"expectedBuyAmount": "0.02145678",
"expectedBuyAmountMaxSlippage": "0.02081307",
"expiration": "1754920807",
"fees": [
{
"type": "liquidity",
"amount": "1245",
"asset": "BTC.BTC",
"chain": "THOR",
"protocol": "THORCHAIN"
},
{
"type": "outbound",
"amount": "15000",
"asset": "BTC.BTC",
"chain": "BTC",
"protocol": "THORCHAIN"
},
{
"type": "affiliate",
"amount": "10728",
"asset": "BTC.BTC",
"chain": "THOR",
"protocol": "THORCHAIN"
},
{
"type": "inbound",
"amount": "0",
"asset": "ETH.ETH",
"chain": "ETH",
"protocol": "THORCHAIN"
}
],
"inboundAddress": "0x8c7c3f4e8b1d3a4e5c9f2b6a7d9e1f3c5b8a2d6e",
"legs": [
{
"provider": "THORCHAIN",
"sellAsset": "ETH.ETH",
"sellAmount": "0.5",
"buyAsset": "BTC.BTC",
"buyAmount": "0.02145678",
"buyAmountMaxSlippage": "0.02081307",
"fees": [
{
"type": "liquidity",
"amount": "1245",
"asset": "BTC.BTC",
"chain": "THOR",
"protocol": "THORCHAIN"
},
{
"type": "outbound",
"amount": "15000",
"asset": "BTC.BTC",
"chain": "BTC",
"protocol": "THORCHAIN"
},
{
"type": "affiliate",
"amount": "10728",
"asset": "BTC.BTC",
"chain": "THOR",
"protocol": "THORCHAIN"
},
{
"type": "inbound",
"amount": "0",
"asset": "ETH.ETH",
"chain": "ETH",
"protocol": "THORCHAIN"
}
]
}
],
"memo": "=:BTC.BTC:bc1qns9f7yfx3ry9lj6yz7c9er0vwa0ye2eklpzqfw:2081307:dkit:50",
"meta": {
"priceImpact": 0.12,
"assets": [
{
"asset": "ETH.ETH",
"price": 3450.25,
"image": "https://crispy.sfo3.cdn.digitaloceanspaces.com/eth.eth.png"
},
{
"asset": "BTC.BTC",
"price": 67890.50,
"image": "https://crispy.sfo3.cdn.digitaloceanspaces.com/btc.btc.png"
}
],
"affiliate": "dkit",
"affiliateFee": 50,
"tags": [],
"txType": "EVM"
},
"providers": [
"THORCHAIN"
],
"sellAmount": "0.5",
"sellAsset": "ETH.ETH",
"sourceAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
"totalSlippageBps": 300,
"warnings": []
}
]
}
import { ethers } from 'ethers';
const executeSwap = async (route) => {
// Connect to wallet (MetaMask, WalletConnect, etc.)
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
// For THORChain swaps: send ETH to inbound address with memo
const tx = {
to: route.inboundAddress,
value: ethers.utils.parseEther(route.sellAmount), // Convert 0.5 ETH to wei
data: ethers.utils.toUtf8Bytes(route.memo),
gasLimit: 100000
};
const txResponse = await signer.sendTransaction(tx);
console.log('Transaction sent:', txResponse.hash);
// Wait for transaction confirmation
const receipt = await txResponse.wait();
console.log('Transaction confirmed in block:', receipt.blockNumber);
return txResponse.hash;
};
// Execute using the route from Step 1
const route = await getQuote();
const txHash = await executeSwap(route);
targetAddress
or inboundAddress
matches what the quote returned before sending funds.quoteId
and routeIndex
from the quote response and provides real-time status updates with rich route information.
curl --location 'https://api.dkit.xyz/v1/track' \
--header 'content-type: application/json' \
--header 'x-api-key: 86c3fc76-25c8-455c-8d6d-0ecea88d0f6e' \
--data '{
"hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"chainId": "ethereum",
"quoteId": "a7c4b3ef-51d2-4c78-b8e1-8b3e12f7a6d9",
"routeIndex": 0
}'
Example Tracking Response
{
"success": true,
"trackingStatus": "completed",
"stage": "outbound",
"data": {
"quoteInfo": {
"quoteId": "a7c4b3ef-51d2-4c78-b8e1-8b3e12f7a6d9",
"routeIndex": 0,
"senderAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
"recipientAddress": "bc1qns9f7yfx3ry9lj6yz7c9er0vwa0ye2eklpzqfw",
"provider": "THORCHAIN",
"trackParams": {
"hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"chainId": "ethereum"
}
},
"inbound": {
"hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"amount": "0.5",
"asset": "ETH.ETH",
"confirmations": 12,
"blockNumber": 18765432
},
"swap": {
"swapId": "ABC123DEF456",
"status": "success",
"swapTime": 8
},
"outbound": {
"hash": "3f2329b4d5e6c8a9f1b7d4c5e6f8a9b0c1d2e3f4567890abcdef1234567890ab",
"amount": "0.02081307",
"asset": "BTC.BTC",
"confirmations": 2,
"blockNumber": 823456
},
"route": {
"fees": [
{
"type": "liquidity",
"asset": "BTC.BTC",
"chain": "THOR",
"amount": "1245",
"protocol": "THORCHAIN"
},
{
"type": "outbound",
"asset": "BTC.BTC",
"chain": "BTC",
"amount": "15000",
"protocol": "THORCHAIN"
},
{
"type": "affiliate",
"asset": "BTC.BTC",
"chain": "THOR",
"amount": "10728",
"protocol": "THORCHAIN"
}
],
"legs": [
{
"provider": "THORCHAIN",
"sellAsset": "ETH.ETH",
"sellAmount": "0.5",
"buyAsset": "BTC.BTC",
"buyAmount": "0.02081307",
"actualBuyAmount": "0.02081307"
}
],
"memo": "=:BTC.BTC:bc1qns9f7yfx3ry9lj6yz7c9er0vwa0ye2eklpzqfw:2081307:dkit:50",
"meta": {
"assets": [
{
"asset": "ETH.ETH",
"image": "https://crispy.sfo3.cdn.digitaloceanspaces.com/eth.eth.png",
"price": 3450.25
},
{
"asset": "BTC.BTC",
"image": "https://crispy.sfo3.cdn.digitaloceanspaces.com/btc.btc.png",
"price": 67890.50
}
],
"txType": "EVM",
"affiliate": "dkit",
"priceImpact": 0.12,
"affiliateFee": 50
},
"buyAsset": "BTC.BTC",
"providers": ["THORCHAIN"],
"sellAsset": "ETH.ETH",
"sellAmount": "0.5",
"actualBuyAmount": "0.02081307",
"expectedBuyAmount": "0.02145678",
"sourceAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
"destinationAddress": "bc1qns9f7yfx3ry9lj6yz7c9er0vwa0ye2eklpzqfw",
"inboundAddress": "0x8c7c3f4e8b1d3a4e5c9f2b6a7d9e1f3c5b8a2d6e",
"totalSlippageBps": 300
}
}
}