Function Signature
Description
Builds an unsigned Bitcoin P2WPKH transaction via the Portal backend. The returnedtransaction
is a Partially Signed Bitcoin Transaction (PSBT) as hex, together with the list of signature
hashes — one per input — that must be signed before the transaction can be broadcast.
This is the first step of a three-step flow:
buildBitcoinP2wpkhTransaction— build the PSBT.rawSign— sign every entry oftransaction.signatureHashes.broadcastBitcoinP2wpkhTransaction— submit the signed transaction.
sendAsset performs all
three for you and returns the transaction hash directly.
Parameters
Supported chainId values
Any other
bip122: reference is rejected. See
Chain ID formatting for the full CAIP-2 reference.
Returns
PortalBuildBitcoinP2wpkhTransactionResponse — the unsigned PSBT plus metadata.
PortalBitcoinP2wpkhTransaction
See
buildEip155Transaction for the
PortalBuildTransactionMetadata shape. For Bitcoin, tokenDecimals is always 8 and
tokenSymbol is always "BTC".
Examples
Build a testnet BTC transfer
Build, then sign and broadcast
Errors
Throws aPortalException on failure:
Backend failures are thrown on both platforms. On iOS and Android alike, a failed build
(insufficient balance, invalid recipient, unsupported chain ID) is thrown as a
PortalException
with code BUILD_BITCOIN_P2WPKH_TRANSACTION_ERROR, so response.error is normally null.
Checking response.error is optional and only a defensive measure.Implementation Notes
amountis the human-readable value. Pass"0.0001"for 0.0001 BTC, not"10000"satoshis.tokenmust be"NATIVE". Bitcoin has no token contracts, so there is no other valid value.- Only P2WPKH (native SegWit) is supported. There is no P2TR/taproot, P2SH, or legacy P2PKH support.
- Sign all of
signatureHashes, in the order returned — there is one per transaction input, and the broadcast call expects the signatures in matching order. - Bitcoin chains need no entry in
rpcConfig. Raw signing does not use an RPC provider. - Bitcoin uses the SECP256K1 curve, the same key share as EVM chains.
Related
- broadcastBitcoinP2wpkhTransaction
- rawSign
- sendAsset
- getClient — where the wallet’s Bitcoin addresses live
- buildEip155Transaction
- buildSolanaTransaction