Skip to content

Bitcoin apps on ICP

ICP brings smart contract functionality to Bitcoin and opens up new possibilities for Bitcoin DeFi application development through a direct integration with the Bitcoin network. Bitcoin applications deployed on ICP can query Bitcoin state and send transactions directly to Bitcoin without needing:

  • Bridges or oracles
  • Wrapped tokens
  • Custom signer infrastructure

How is this made possible?

The Internet Computer Protocol (ICP) is a fully decentralized, open, and secure blockchain where users have ownership and control over their data and applications. Every application deployed on ICP consists of one or more smart contracts. These smart contracts can host both the frontend and backend, allowing full-stack applications to run entirely onchain. They can also integrate with existing web services and tools.

ICP provides a native Bitcoin API, implemented as a smart contract, that facilitates communication between ICP applications and the Bitcoin networks (mainnet and testnet v4). Bitcoin applications interact with this API to create, sign, and submit transactions. The API then forwards each transaction to the target Bitcoin network.

Before a transaction can be sent to the Bitcoin network, it must be signed. ICP supports multiple threshold signature schemes, including ECDSA and Schnorr, to accommodate various types of Bitcoin transactions and address formats. On ICP, threshold signatures are fundamental to chain-key cryptography. They allow smart contracts to control assets from other blockchains. Each smart contract can generate unlimited Bitcoin addresses derived from these schemes and then sign transactions accordingly.

How Bitcoin Apps Work on ICP

Canister smart contracts

Smart contracts on ICP are called canisters, an advanced form of smart contract that encapsulates both the application code and its associated state. Canisters can be used to perform advanced functions, such as:

  • Listening to the Bitcoin network and reacting to transactions
  • Signing Bitcoin transactions
  • Storing application and user state
  • Holding BTC and other digital assets natively

Canister smart contracts can host both the frontend and backend of an application for an onchain full-stack deployment.

Learn more about canisters.

Application backends

Canister smart contracts can be written in several supported languages like Rust, TypeScript, or Motoko. ICP smart contracts encapsulate both logic and state, enabling fully programmable Bitcoin backends that run entirely onchain.

Each language has an associated Canister Development Kit (CDK), which provides methods for interacting directly with the Bitcoin network using ICP's native Bitcoin API—without relying on any external API or RPC services. Canisters are compiled to WebAssembly and executed by the ICP runtime.

rust
use crate::{common::DerivationPath, ecdsa::get_ecdsa_public_key, BTC_CONTEXT};
use bitcoin::{Address, PublicKey};
use ic_cdk::update;

#[update]
pub async fn get_p2pkh_address() -> String {
    let ctx = BTC_CONTEXT.with(|ctx| ctx.get());

    // Unique derivation paths are used for every address type generated, to ensure
    // each address has its own unique key pair.
    let derivation_path = DerivationPath::p2pkh(0, 0);

    // Get the ECDSA public key of this smart contract at the given derivation path
    let public_key = get_ecdsa_public_key(&ctx, derivation_path.to_vec_u8_path()).await;

    // Convert the public key to the format used by the Bitcoin library
    let public_key = PublicKey::from_slice(&public_key).unwrap();

    // Generate a legacy P2PKH address from the public key.
    // The address encoding (Base58) depends on the network type.
    Address::p2pkh(public_key, ctx.bitcoin_network).to_string()
}

Creating a legacy P2PKH (Pay-to-PubKey-Hash) address from the ECDSA key of a smart contract running on ICP. See full example.

Application frontends

Frontends for Bitcoin applications on ICP can be developed using familiar frameworks like React, Vue, or Svelte. These frontends can be deployed onchain as canister smart contracts and accessed via a unique ICP-hosted URL, removing the need for traditional domain or hosting infrastructure.

ICP also supports certified assets, which cryptographically prove the integrity and source of frontend content—providing users with a verifiable guarantee that the frontend has not been tampered with.

For developers who prefer traditional hosting, frontends can be served from Web2 platforms while still integrating seamlessly with onchain backend canisters. Communication between frontend and backend occurs over HTTPS via boundary nodes that connect external clients to the Internet Computer network.

This hybrid hosting model gives developers the flexibility to design frontends according to their preferences while benefiting from verifiable, tamper-proof backend logic.

Learn more about deploying frontends onchain.

HTTP Gateway

The HTTP Gateway is the primary bridge between traditional web browsers and canister smart contracts on the Internet Computer. It enables seamless interaction between end-users and onchain applications without requiring browser extensions or custom clients.

When a user visits an ICP-hosted application, the HTTP Gateway routes the incoming request from the browser to the appropriate canister smart contract that serves the frontend assets. These assets—HTML, JavaScript, CSS, and others—are returned just like in any standard web application, enabling a familiar user experience while maintaining the trustless guarantees of onchain hosting.

Because the gateway supports serving certified assets, users can cryptographically verify that the frontend was served directly from the canister and not modified in transit. This mechanism is critical for preserving content integrity in decentralized applications.

Bitcoin API

ICP includes a built-in Bitcoin API that enables smart contracts to interact directly with the Bitcoin network. This API is implemented as a system canister and supports operations on Bitcoin mainnet, testnet (v4), and regtest (local development), including querying UTXOs, retrieving balances, fetching recent fee estimates, and submitting signed transactions.

Under the hood, this integration relies on ICP’s chain-key ECDSA functionality, which allows canisters to derive their own Bitcoin addresses and request secure transaction signatures without exposing private keys. Combined with direct network-level integration, Internet Computer replicas connect to multiple Bitcoin nodes via a dedicated Bitcoin adapter, ensuring broad, redundant connectivity to the Bitcoin peer-to-peer network. This adapter fetches new blocks, keeps the Bitcoin blockchain state up to date inside the system canister, and broadcasts transactions from canisters to the Bitcoin network.

Smart contracts use the API to construct Bitcoin transactions, retrieve blockchain data, and perform validation checks without relying on any offchain infrastructure or third-party services. By providing a programmatic interface to native BTC from within ICP, the Bitcoin API enables developers to build decentralized applications—such as wallets, payment processors, and Bitcoin DeFi protocols—in a secure, trust-minimized, and fully onchain environment.

Explore the Bitcoin API docs

ICP Learn Hub: Bitcoin Integration

Threshold signatures

A canister smart contract can securely sign Bitcoin transactions using chain-key cryptography, ICP's decentralized key management system. Bitcoin uses ECDSA at the base layer of the network and implemented Schnorr signatures as part of the Taproot upgrade. Both ECDSA and Schnorr signing capabilities are available to canister smart contracts, enabling a wide range of Bitcoin operations, including:

  • Generating legacy (P2PKH, P2SH), SegWit, or P2TR addresses
  • Signing transactions with either signature scheme
  • Constructing and signing Taproot scripts with conditions like time-locks or multi-sig

Learn more about threshold signatures.

Example applications

  • Basic Bitcoin – This example demonstrates how to deploy a smart contract on the Internet Computer that can receive and send bitcoin, including support for legacy (P2PKH), SegWit (P2WPKH), and Taproot (P2TR) address types. The example also includes how to work with Bitcoin assets such as Ordinals, Runes, and BRC-20 tokens.
  • Bitcoin Wallet – A multiuser Bitcoin wallet that allows the user to generate a Bitcoin address by logging in with the ICP authentication service (Internet Identity). The user can then send and receive Bitcoin using this address. The backend canister uses the ICP Bitcoin API to interact with the Bitcoin blockchain.

Internet Computer and ICP are trademarks of the DFINITY Foundation. Bitcoin is a trademark of its respective holders. All other product names, logos, and brands are property of their respective owners. This site supports the development of Bitcoin DeFi on ICP; build responsibly and follow all applicable guidelines and safety practices.