🪙Bitcoin

LI.FI is live on Bitcoin!

LI.FI REST API offers seamless integration for native Bitcoin bridging and swaps through Thorswap.

NOTE: Thorswap is only supported for Bitcoin <> Ethereum, Avalanche, or BSC transfers

In this documentation, we will explore how to use the API for Bitcoin related requests, executing transactions, getting routes, and checking the status of transactions.

Currently only native SegWit addresses are supported which are addresses that start with “bc1q”

Requesting Bitcoin-specific information via the API

Chains

curl --request GET \
     --url 'https://li.quest/v1/chains?chainTypes=UTXO' \
     --header 'accept: application/json'

Tools

curl --request GET \
  --url 'https://li.quest/v1/tools?chains=20000000000001' \
  --header 'accept: application/json'

Tokens

curl --request GET \
     --url 'https://li.quest/v1/tokens?chains=BTC' \
     --header 'accept: application/json'

Token details

curl --request GET \
     --url 'https://li.quest/v1/token?chain=20000000000001&token=bitcoin' \
     --header 'accept: application/json'

Requesting a Quote

Bitcoin to Ethereum

To request a quote for a transaction between Bitcoin and Ethereum, Avalanche, or BSC, you can use the provided guide. Below is an example of a request to get a quote for transferring 0.5 BTC to USDC on Ethereum:

const request {
    fromAddress="YOUR_BTC_ADDRESS"
    fromAmount=50000000
    fromChain=20000000000001
    fromToken=bitcoin
    toAddress="YOUR_EVM_ADDRESS"
    toChain=1
    toToken=USDC
}

Ethereum to Bitcoin

To request a quote for a transaction between Ethereum and Bitcoin, you can use the provided guide. Below is an example of a request to get a quote for transferring 50 USDC on Ethereum to native BTC:

const request {
    fromAddress="YOUR_EVM_ADDRESS"
    fromAmount=50000000
    fromChain=1
    fromToken=bitcoin
    toAddress="YOUR_BTC_ADDRESS"
    toChain=20000000000001
    toToken=USDC
}

Executing the transaction

Transaction Data

BTC to Ethereum, Avalanche, or BNB Smart Chain (BSC)

After retrieving the quote, the funds need to be sent to the BTC vault address provided in the response, along with a memo.

  • Memo Functionality: Similar to Thorchain, LI.FI uses memos for BTC to EVM swaps. The memo in the BTC transaction specifies the swap's destination address and chain.

  • Transaction Handling: The transaction that leaves BTC and goes to EVM needs to be sent to an EVM address. The memo ensures that the swap details are correctly processed by the validators.

NOTE: Only send tx n a timely manner (30min), it is always recommended to request an up-to-date quote to ensure to get the latest information.

The following is an example of transaction data.

"transactionRequest": {
    "to": "bc1qawcdxplxprc64fh38ryy4crndmfgwrffpac743", //thorswap vault to send BTC to
    "data": "=:ETH.USDC:0x29DaCdF7cCaDf4eE67c923b4C22255A4B2494eD7::lifi:0|0x4977d81c2a5d6bd8",
    "value": "500000"
  }

Ethereum, Avalance, or BSC to BTC

EVM to native BTC transfers use the standard format specified here.

Last updated