Skip to main content

Function Signature

Description

Builds an unsigned Bitcoin P2WPKH transaction via the Portal backend. The returned transaction 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:
  1. buildBitcoinP2wpkhTransaction — build the PSBT.
  2. rawSign — sign every entry of transaction.signatureHashes.
  3. broadcastBitcoinP2wpkhTransaction — submit the signed transaction.
If you do not need control over the individual steps, 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 a PortalException 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

  • amount is the human-readable value. Pass "0.0001" for 0.0001 BTC, not "10000" satoshis.
  • token must 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.