sBTC Integration

source: Hiro blog

Clarinet can automatically wire up the official sBTC contracts so you can build and test SIP-010 flows locally.

What you'll learn

  • Add sBTC smart contracts to your Clarinet project

  • Test contracts with automatic sBTC funding in devnet

  • Work with sBTC as a SIP-010 fungible token

  • Deploy sBTC contracts to testnet and mainnet

Prerequisites

  • Clarinet 2.15.0 or later required for automatic sBTC integration.

Quickstart

1

Add sBTC to your project

Add the sBTC contracts to your project requirements:

This pulls in:

  • sbtc-token – SIP-010 fungible token contract

  • sbtc-registry – configuration registry

  • sbtc-deposit – deposit and withdrawal logic

Clarinet auto-funds devnet wallets with sBTC when these are present.

2

Create an sBTC-enabled contract

Example NFT marketplace that accepts sBTC payments:

3

Test in the Clarinet console

Launch the console and try the contract using auto-funded wallets:

4

Write unit tests

Sample Vitest test for sBTC payments:

5

Deploy to testnet

Generate a plan to confirm remapped addresses for official sBTC contracts:

Deploy when ready:

Common patterns

Working with sBTC addresses

Clarinet handles sBTC contract address mapping across networks:

Network
sBTC Contract Address

Simnet/Devnet

SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token

Testnet

ST1F7QA2MDF17S807EPA36TSS8AMEFY4KA9TVGWXT.sbtc-token

Mainnet

Contract address remains unchanged

Your contract code always references the simnet address. Clarinet automatically remaps during deployment.

Manual sBTC minting in unit tests

While Clarinet 2.15.0+ automatically funds wallets with sBTC in devnet, you may need to manually mint sBTC in unit tests for specific scenarios.

Minting sBTC using the deployer address

The sBTC token contract allows the deployer (multisig) address to mint tokens. Use this approach in your tests:

Testing with mainnet execution simulation

When using mainnet execution simulation, you can mint sBTC using the actual mainnet multisig:

This approach is useful for:

  • Testing specific sBTC amounts

  • Simulating different wallet balances

  • Testing edge cases with precise token amounts

  • Integration testing with mainnet contracts

Last updated

Was this helpful?