Skip to content

Smart contract capabilities

ICP makes it possible to build fully onchain Bitcoin DeFi applications that interact directly with the Bitcoin network—without bridges, wrapped tokens, or external signers. These capabilities are made possible by protocol-level features like threshold signatures, HTTPS outcalls, certified state, and canister smart contracts. This section describes how these building blocks can be used to realize common Bitcoin use cases such as wallet functionality, transaction creation, asset issuance, and token indexing.

Addresses and transactions

Legacy and SegWit transactions

Legacy Bitcoin addresses (P2PKH) and SegWit addresses (P2WPKH, P2SH) are supported through threshold ECDSA signing. Each smart contract on ICP has an ECDSA key and use it to derive any number of Bitcoin addresses for the application. These addresses can then receive BTC, and the contract can sign transactions to spend those funds using the Bitcoin API.

  • Legacy (P2PKH): The original address format using Base58Check, commonly begins with 1. These addresses are widely supported but have higher transaction fees due to larger script sizes.
  • SegWit (P2WPKH/P2SH): Introduced in BIP141, SegWit reduces transaction size and fees. Native SegWit addresses (starting with bc1q) improve efficiency, while P2SH (starting with 3) wraps complex scripts for compatibility.

Learn more about threshold ECDSA.

Taproot support

Taproot (P2TR) is Bitcoin's latest upgrade, enabling more privacy-preserving and efficient smart contracts by combining Schnorr signatures with Merkle tree-based scripts. Taproot addresses start with bc1p and require support for Schnorr-based signing (BIP340).

ICP supports threshold Schnorr signatures, enabling canisters to generate Taproot addresses and sign Taproot-compatible transactions. This opens the door to advanced Bitcoin scripting capabilities like multisig, timelocks, and complex conditional logic—all programmable from within ICP canisters.

Learn more about threshold Schnorr.

Interacting with the Bitcoin blockchain

ICP provides a native Bitcoin API that allows smart contracts to read from and write to the Bitcoin blockchain directly—without relying on external signers, bridges, or centralized APIs. The API is implemented as a system canister that handles communication with the Bitcoin mainnet, testnet, and local regtest environments. All interactions are secure, decentralized, and validated by the Internet Computer's consensus mechanism.

Using the Bitcoin API, developers can build smart contracts that interact programmatically with Bitcoin. This enables fully onchain wallet functionality, asset issuance, and Bitcoin-native DeFi applications.

Reading from Bitcoin

  • Query the balance of Bitcoin addressesbitcoin_get_balance: Returns the total confirmed balance of a given Bitcoin address.
  • Query UTXOs of Bitcoin addressesbitcoin_get_utxos: Returns the set of unspent transaction outputs for a given Bitcoin address.
  • Query network fee percentilesbitcoin_get_current_fee_percentiles: Provides recent fee rate distribution percentiles for better transaction fee estimation.
  • Query recent block headersbitcoin_get_block_headers: Retrieves the headers of recent blocks for syncing or light client purposes.
  • Read Bitcoin metaprotocol state Use services like Maestro or Ominity to track Ordinals, Runes, and BRC-20 activity from ICP canisters via HTTPS outcalls.

Writing to Bitcoin

  • Submit Bitcoin transactionsbitcoin_send_transaction: Sends a signed transaction to the Bitcoin network from a smart contract.

These capabilities make it possible to build decentralized apps that use Bitcoin as their base asset and interact with its blockchain logic—without giving up decentralization or relying on external custodians.

Ordinals, Runes and BRC-20 tokens

ICP's threshold signature and Taproot support also enables full programmability around emerging Bitcoin-native asset standards.

  • Ordinals: Ordinals assign serial numbers to individual satoshis and enable onchain digital artifacts by embedding metadata in Taproot scripts. Canisters on ICP can monitor for incoming Ordinals, parse inscription data, and transfer satoshis embedded with content.
  • Runes: Runes are a fungible token standard proposed by Casey Rodarmor that live entirely on Bitcoin. They rely on Taproot and OP_RETURN encodings. ICP canisters can construct, parse, and validate Rune transactions using the Bitcoin API.
  • BRC-20: A fungible token standard built on top of Ordinals, using specific JSON-based inscriptions to track balances and transfers. Canisters can index and respond to BRC-20 operations directly on Bitcoin, enabling DeFi interactions with native BRC-20 assets.

Thanks to threshold signing and direct access to Bitcoin state, these Bitcoin-native assets can be indexed, transferred, and managed using ICP smart contracts.

Learn more about Bitcoin assets on ICP.

Accessing Bitcoin price feeds and network data

Bitcoin DeFi applications often need external data, such as the current BTC/USD price or the status of a Bitcoin transaction or UTXO. ICP provides a native feature called HTTPS outcalls, which allows smart contracts to securely make HTTP requests to off-chain APIs—without relying on oracles, bridges, or centralized intermediaries.

For example, a smart contract can call an exchange API to fetch real-time price data, or query an indexer to check whether a specific transaction has been confirmed. All HTTPS outcall responses are validated by the ICP consensus layer before being made available to the canister, ensuring the integrity of the data used onchain.

In addition to general-purpose outcalls, some data is already made available by smart contracts deployed on ICP. For instance, the exchange-rate-canister provides regularly updated BTC/USD price data that can be queried by any canister.

Authenticate using familiar Bitcoin wallets

One of the most powerful features of building Bitcoin apps on ICP is the ability to authenticate users directly with their existing Bitcoin wallets. Thanks to libraries like Sign-in with Bitcoin, developers can let users log in simply by signing a standardized message with a wallet they already use and trust—no need for passwords or external identity systems.

This creates a Bitcoin-native user experience, where authentication flows feel familiar to Bitcoin users. Applications can integrate with popular wallets such as Xverse, Leather, Unisat, OKX, and Magic Eden (via browser extensions or wallet APIs), allowing users to sign in, interact with canister smart contracts, and initiate transactions—all using their existing wallet infrastructure.

By enabling wallet-based authentication, developers can offer a secure and low-friction onboarding experience that aligns with Bitcoin principles of self-custody and user control.

Users don't pay gas

One of the most user-friendly features of the Internet Computer is its reverse gas model. Unlike Ethereum or many other smart contract platforms, users interacting with canister smart contracts on ICP are not required to pay gas fees. Instead, the cost of execution is covered by the application developer or service provider who funds the smart contract.

This model significantly lowers the barrier for onboarding new users, especially those unfamiliar with managing wallets, paying gas, or holding platform-specific tokens.

Developers can design apps where users simply sign messages or perform transactions using their Bitcoin wallet, without having to first acquire ICP tokens or understand fee mechanics. This stands in contrast to Ethereum and other account-based networks where users must maintain a balance of native gas tokens to perform any action.

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.