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
BurnRoutercontract. - Cross-chain networks (Ethereum, Optimism, Arbitrum, Base, Unichain) → call the
EthConnectorcontract.
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
| Stage | EVM endpoint | TON endpoint | Solana endpoint |
|---|---|---|---|
| Estimate | POST .../swap-and-unwrap-estimate | POST .../swap-and-unwrap-estimate-ton | POST .../swap-and-unwrap-estimate-solana |
| Build | POST .../swap-and-unwrap-inputs | POST .../swap-and-unwrap-inputs-ton | POST .../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.