Skip to main content
POST
/
api
/
v1
/
swaps
/
init
TypeScript SDK - Initialize Swap
import { KaleidoClient } from '@kaleidoswap/kaleidoswap-sdk';

const client = new KaleidoClient({
  baseUrl: 'https://api.staging.kaleidoswap.com/api/v1'
});

// First get a quote
const quote = await client.quoteRequest('BTC', 'rgb:im7mWgoS-4QX_1b1-DT23iPq-niObDFM-qGN7R2x-lFLJYak', 1000000);

// Initialize the swap
const swap = await client.initMakerSwap({
  rfq_id: quote.rfq_id,
  from_asset: 'BTC',
  to_asset: 'rgb:im7mWgoS-4QX_1b1-DT23iPq-niObDFM-qGN7R2x-lFLJYak',
  from_amount: 1000000,
  to_amount: quote.to_amount
});
console.log(`Swap initialized: ${swap.payment_hash}`);
{
  "swapstring": "30/rgb:2dkSTbr-jFhznbPmo-TQafzswCN-av4gTsJjX-ttx6CNou5-M98k8Zd/10/rgb:2eVw8uw-8G88LQ2tQ-kexM12SoD-nCX8DmQrw-yLMu6JDfK-xx1SCfc/1715896416/9d342c6ba006e24abee84a2e034a22d5e30c1f2599fb9c3574d46d3cde3d65a2",
  "payment_hash": "9d342c6ba006e24abee84a2e034a22d5e30c1f2599fb9c3574d46d3cde3d65a2"
}

Atomic Swap Flow

  1. Get a quote using /api/v1/market/quote
  2. Initiate the swap with this endpoint
  3. Confirm the swap using /api/v1/swaps/execute
Swaps must be confirmed within the quote expiration time.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
rfq_id
string
required
Example:

"1234567890"

from_asset
string
required
Example:

"BTC"

from_amount
integer
required
Example:

1000000

to_asset
string
required
Example:

"rgb:2dkSTbr-jFhznbPmo-TQafzswCN-av4gTsJjX-ttx6CNou5-M98k8Zd"

to_amount
integer
required
Example:

1000000

Response

Successful Response

swapstring
string
required
Example:

"30/rgb:2dkSTbr-jFhznbPmo-TQafzswCN-av4gTsJjX-ttx6CNou5-M98k8Zd/10/rgb:2eVw8uw-8G88LQ2tQ-kexM12SoD-nCX8DmQrw-yLMu6JDfK-xx1SCfc/1715896416/9d342c6ba006e24abee84a2e034a22d5e30c1f2599fb9c3574d46d3cde3d65a2"

payment_hash
string
required
Example:

"9d342c6ba006e24abee84a2e034a22d5e30c1f2599fb9c3574d46d3cde3d65a2"