Skip to main content

Wrap & Swap (BTC → EVM/TON)

wrapAndSwap takes BTC on Bitcoin and delivers a token on a target network (an ERC-20 on EVM, or a Jetton on TON).

1. Estimate the output

Quote the output amount and fees before building anything.

const amountInBTC = 0.001;
const networkName = 'optimism';
const outputTokenAddress = undefined; // undefined → native token

const estimate = await sdk.wrapAndSwapEstimate(
amountInBTC,
networkName,
outputTokenAddress,
);

console.log(estimate.outputAmount, estimate.teleswapFee);

See Estimating output & fees for the full response shape.

2. Build the unsigned transaction

Provide the recipient EVM address and the Bitcoin signer info to get an unsigned Bitcoin transaction back.

const amountInBTC = 0.001;
const evmAddress = '0x...';
const networkName = 'ethereum';
const exchangeTokenAddress = '0x...'; // undefined → native token

const signerInfo = {
addressType: 'p2wpkh', // 'p2wpkh' | 'p2pkh' | 'p2sh-p2wpkh'
publicKey: '...',
address: '...',
};

const unsigned = await sdk.wrapAndSwapUnsigned(
evmAddress,
amountInBTC,
signerInfo,
networkName,
exchangeTokenAddress,
);

3. Sign & broadcast

Sign the returned transaction with your Bitcoin wallet and broadcast it to the Bitcoin network. Once it's seen by the protocol, track it with getRequestStatusByTxId.

REST equivalents

StageEndpoint
EstimatePOST /api/v2/teleswap/utils/wrap-and-swap-estimate
BuildPOST /api/v2/teleswap/utils/wrap-and-swap-unsigned

See the API reference.