# Interlay Bridge API

## **Interlay Bridge API: Seamlessly Transfer Assets Between Polkadot and Bitcoin**

**Interlay** provides a secure, efficient, and decentralized bridge between the **Polkadot** network and **Bitcoin**. By leveraging the **Interlay Bridge API**, developers can easily transfer assets across blockchain ecosystems, enabling **Bitcoin** liquidity on **Polkadot**. This bridge is designed to offer low fees, high security, and rapid cross-chain transactions.

Whether you're building decentralized applications (dApps), creating decentralized finance (DeFi) solutions, or simply looking to trade assets across chains, the **Interlay Bridge API** gives you the tools to transfer Bitcoin seamlessly onto the Polkadot network and vice versa.

### **Why Use the Interlay Bridge API for Cross-Chain Transfers?**

The **Interlay Bridge API** is ideal for developers and traders who want to access Bitcoin’s liquidity within the **Polkadot ecosystem**. The Interlay Bridge enables cross-chain communication and asset transfer, utilizing Bitcoin’s security while leveraging Polkadot’s high throughput and scalability.

**Key Features of the Interlay Bridge API:**

* **Secure Cross-Chain Transfers**: Transfer assets from Bitcoin to Polkadot and vice versa with the highest levels of security.
    
* **Low Fees**: Benefit from low transaction costs, especially when compared to traditional cross-chain bridges.
    
* **Fast and Scalable**: The Interlay Bridge ensures fast, reliable transfers without the bottlenecks often seen in other bridges.
    
* **Decentralized Control**: Interlay uses a decentralized oracle and validator set, ensuring that all transactions are verified without relying on a single entity.
    
* **No Rate Limits**: The API allows unlimited usage, making it perfect for both high-frequency traders and large-scale dApp developers.
    

### **How the Interlay Bridge API Works**

The **Interlay Bridge** works by wrapping Bitcoin (BTC) on the Polkadot network as **interBTC**, a trustless, 1:1 pegged asset. Developers can interact with this bridge through a series of API endpoints that manage token transfers, balance checks, and transaction status.

**API Endpoints:**

* **Transfer Bitcoin to Polkadot (BTC to interBTC)**:
    

* ```plaintext
    https://dot-api.pro/api/interlay/transfer_to_polkadot
    ```
    

* **Transfer Polkadot to Bitcoin (interBTC to BTC)**:
    

* ```plaintext
    https://dot-api.pro/api/interlay/transfer_to_bitcoin
    ```
    

### **How to Transfer Bitcoin to Polkadot Using the Interlay Bridge API**

To transfer Bitcoin to Polkadot, you can use the **Interlay Transfer API**. This API allows you to lock Bitcoin on the Bitcoin blockchain and mint **interBTC** on the Polkadot network.

#### **Example API Request for Bitcoin to Polkadot Transfer:**

To initiate the transfer, send a POST request with the following parameters:

* `private_key`: Your private key associated with the **Bitcoin** wallet to authorize the transaction.
    
* `amount`: The amount of **BTC** you wish to transfer.
    
* `to_address`: The **Polkadot address** where the **interBTC** tokens will be minted.
    
* `slippage`: Set your desired slippage tolerance to avoid large price fluctuations during transfer.
    
* `units`: Default is set to 1,000,000 for transaction precision.
    

**Transfer Bitcoin to Polkadot API Endpoint:**

```plaintext
https://dot-api.pro/api/interlay/transfer_to_polkadot
```

#### **Example Python Code for Bitcoin to Polkadot Transfer**

```plaintext
import requests

# Replace with your test values
private_key = 'your_private_key'  # Your private Bitcoin wallet key
amount = 0.05  # Amount in BTC to transfer
to_address = 'Polkadot_wallet_address'  # Your Polkadot wallet address
slippage = 1  # 1% slippage tolerance
units = 1000000  # Precision units

def transfer_btc_to_polkadot():
    url = 'https://dot-api.pro/api/interlay/transfer_to_polkadot'  # Interlay Bridge endpoint
    payload = {
        "private_key": private_key,
        "amount": amount,
        "to_address": to_address,
        "slippage": slippage,
        "units": units
    }

    try:
        response = requests.post(url, json=payload)
        response.raise_for_status()
        print('Response:', response.json())
    except requests.exceptions.RequestException as e:
        if e.response:
            print('Error:', e.response.json())
        else:
            print('Error:', e)

# Run the function
transfer_btc_to_polkadot()
```

#### **Example Successful Response:**

```plaintext
{
  "status": "success",
  "txid": "abc12345xyz67890"
}
```

#### **Example Error Response:**

```plaintext
{
  "status": "failed",
  "message": "Insufficient BTC balance",
  "error": "Not enough BTC in wallet for the transfer"
}
```

### **How to Transfer Polkadot to Bitcoin Using the Interlay Bridge API**

If you want to redeem **interBTC** for actual **BTC** on the Bitcoin network, you can use the **Polkadot to Bitcoin Transfer API**. This allows users to burn **interBTC** on the Polkadot network and unlock **BTC** on the Bitcoin blockchain.

#### **Example API Request for Polkadot to Bitcoin Transfer:**

To redeem **interBTC** for **BTC**, send a POST request with the following parameters:

* `private_key`: Your private key associated with your **Polkadot wallet** for authorization.
    
* `amount`: The amount of **interBTC** you wish to transfer back to Bitcoin.
    
* `to_address`: The **Bitcoin address** where you want to receive the BTC.
    
* `slippage`: Desired slippage tolerance.
    

**Transfer Polkadot to Bitcoin API Endpoint:**

```plaintext
https://dot-api.pro/api/interlay/transfer_to_bitcoin
```

#### **Example Python Code for Polkadot to Bitcoin Transfer**

```plaintext
import requests

# Replace with your test values
private_key = 'your_private_key'  # Your private Polkadot wallet key
amount = 0.05  # Amount in interBTC to transfer
to_address = 'Bitcoin_wallet_address'  # Your Bitcoin wallet address
slippage = 1  # 1% slippage tolerance

def transfer_polkadot_to_btc():
    url = 'https://dot-api.pro/api/interlay/transfer_to_bitcoin'  # Interlay Bridge endpoint
    payload = {
        "private_key": private_key,
        "amount": amount,
        "to_address": to_address,
        "slippage": slippage
    }

    try:
        response = requests.post(url, json=payload)
        response.raise_for_status()
        print('Response:', response.json())
    except requests.exceptions.RequestException as e:
        if e.response:
            print('Error:', e.response.json())
        else:
            print('Error:', e)

# Run the function
transfer_polkadot_to_btc()
```

#### **Example Successful Response:**

```plaintext
{
  "status": "success",
  "txid": "def67890xyz12345"
}
```

#### **Example Error Response:**

```plaintext
{
  "status": "failed",
  "message": "Invalid amount or address",
  "error": "Check the transfer amount or recipient address"
}
```

### **Real-Time Cross-Chain Transfer Status**

To track the status of your cross-chain transfer, you can use the **Transfer Status API**. This allows you to monitor the progress of your transaction and receive updates on completion.

**Transfer Status API Endpoint:**

```plaintext
https://dot-api.pro/api/interlay/status/<TXID>
```

#### **Example Python Code for Checking Transfer Status:**

```plaintext
import requests

def get_transfer_status(txid):
    url = f'https://dot-api.pro/api/interlay/status/{txid}'
    
    try:
        response = requests.get(url)
        response.raise_for_status()
        print('Transfer Status:', response.json())
    except requests.exceptions.RequestException as e:
        print('Error fetching status:', e)

# Replace with the transaction ID you want to check
get_transfer_status('abc12345xyz67890')
```

#### **Example Response:**

```plaintext
{
  "status": "pending",
  "message": "Transaction is being processed"
}
```

### **Why Choose Interlay for Cross-Chain Asset Transfers?**

* **Security**: Interlay leverages a decentralized validator network to ensure that all transfers are validated and secure.
    
* **Scalability**: The platform takes advantage of **Polkadot's scalability**, ensuring that cross-chain transfers are processed quickly and efficiently.
    
* **Low Fees**: Interlay’s fees are much lower than traditional cross-chain solutions, making it an affordable option for transferring assets.
    
* **No Rate Limits**: The API allows you to perform unlimited transactions, making it suitable for both high-frequency users and developers.
    
* **Decentralized Control**: No single entity controls the transfer process, ensuring a more secure and trustless system.
    

### **Conclusion**

The **Interlay Bridge API** is an essential tool for developers, traders, and liquidity providers looking to transfer Bitcoin (BTC) to the **Polkadot ecosystem** and vice versa. With its low fees, fast transactions, and robust security features, the Interlay Bridge provides seamless cross-chain communication between Bitcoin and Polkadot. Start using the **Interlay Bridge API** today to leverage Bitcoin liquidity within the **Polkadot ecosystem** and expand your blockchain capabilities.
