Skip to main content

Swap & Unwrap (EVM/TON → BTC)

swapAndUnwrap takes a token on a target network and delivers BTC on Bitcoin.

1. Estimate the output​

import BigNumber from "bignumber.js";

const networkName = "optimism";
const exchangeInfo = {
inputToken: "Token Contract Address",
inputAmount: new BigNumber("50").multipliedBy(10 ** 18).toFixed(0), // 50 tokens, 18 decimals
};

const estimate = await sdk.swapAndUnwrapEstimate(exchangeInfo, networkName);
console.log(estimate.outputAmountBTC, estimate.teleswapFee);

For TON, use swapAndUnwrapEstimateTon(exchangeInfo) (TON amounts use 9 decimals).

2. Get the contract-call inputs​

swapAndUnwrap settles by calling a contract on the source network. Get the inputs, then call the contract directly from your wallet/app.

const exchangeInfo = {
inputToken: "Token Contract Address",
inputAmount: new BigNumber("50").multipliedBy(10 ** 18).toFixed(0),
};
const network = "optimism";
const minimumExpectedBTCAmount = "0"; // tx fails if received BTC < this

const inputs = await sdk.swapAndUnwrapInputs(
exchangeInfo,
btcAddress,
network,
minimumExpectedBTCAmount
);

For TON, use swapAndUnwrapInputsTon(...).

Which contract do I call?
  • Base networks (Polygon, BNB) → call the BurnRouter contract.
  • Cross-chain networks (Ethereum, Optimism, Arbitrum, Base, Unichain) → call the EthConnector contract.

You must first approve the contract to spend an amount equal to your input.

Contract ABIs & addresses​

import { ABI } from "@teleportdao/contracts-helper";
import { teleswap } from "@teleportdao/configs";

const ccBurnABI = ABI.CCBurnRouterABI; // BurnRouter
const connectorABI = ABI.TeleswapEthConnectorABI; // EthConnector

// BurnRouter addresses (base networks)
const polygonCCBurn = teleswap.contracts.polygon.mainnet.ccBurnAddress;
const bscCCBurn = teleswap.contracts.bsc.mainnet.ccBurnAddress;

// Connector addresses (cross-chain networks)
const ethConnector = teleswap.connectors.ethereum.mainnet.connectorAddress;
const opConnector = teleswap.connectors.optimism.mainnet.connectorAddress;
// ...arbitrum, base, unichain

REST equivalents​

StageEVM endpointTON endpointSolana endpoint
EstimatePOST .../swap-and-unwrap-estimatePOST .../swap-and-unwrap-estimate-tonPOST .../swap-and-unwrap-estimate-solana
BuildPOST .../swap-and-unwrap-inputsPOST .../swap-and-unwrap-inputs-tonPOST .../swap-and-unwrap-inputs-solana

See the API reference.

Solana → BTC​

The SDK has no Solana method for this direction yet — use the two REST endpoints above. The build endpoint returns unsignedTx, a hex-encoded Solana transaction: deserialize it, have the user's wallet sign it, and send it. userAddress is the user's Solana address.