Skip to main content
This guide is for using Bitcoin with on-device execution. If your app is using TEE execution, see the Other chains guide for details on using Bitcoin, Tron, and a multitude of other chains in every platform.See the Bitcoin segwit recipe for specifics on codifying and signing a Segwit transaction.

Getting the wallets

Use the useEmbeddedBitcoinWallet hook from the @privy-io/expo package to get the user’s embedded Bitcoin wallets:
Each entry in the wallets array is an object with the following fields:
'bitcoin-taproot' | 'bitcoin-segwit'
required
The type of the wallet.
string
required
The address (base58-encoded public key) for the wallet.
string
required
The public key (hex encoded) for the wallet.
number
required
The HD index for the wallet.
Promise<EmbeddedBitcoinWalletProvider>
required
Method to get a provider for interacting with the wallet.
The create method returned by useEmbeddedBitcoinWallet also returns this same type of object.

Getting the address

Once a user has created their embedded Bitcoin wallet, you can get its address by inspecting the address field of the wallet object:

Getting a wallet provider

To send signature and transaction requests to a user’s Bitcoin wallet, you must first get a provider instance for their wallet. This serves as a standardized abstraction to communicate requests from your app to the user’s wallet.To get a provider for the user’s Bitcoin wallet, call the getProvider method on the wallet interface returned by useEmbeddedBitcoinWallet:

Signing a transaction

To sign a transaction using a Bitcoin wallet, call the signTransaction method on the wallet’s provider. This method will return an object with a signedTransaction field, containing a hex-encoded string for the signed transaction.

Parameters

string
required
A hex-encoded transaction in Partially Signed Bitcoin Transaction format.

Requesting a signature

To request a signature from a user’s Bitcoin wallet, call the sign method on the wallet’s provider. This method will return a signature over the provided hash, encoded as a base64 string.

Parameters

string
required
The hash of the transaction to sign.