What is the Injected Provider API (Testnet)?
The OKX Injected Provider API (Testnet) is a JavaScript-based interface embedded by OKX into websites. This powerful tool enables DApp developers to:
- Request user account information
- Read blockchain data
- Facilitate message and transaction signing
- Seamlessly integrate with extension wallets
Core Functionalities
Connect Wallet
okxwallet.bitcoinTestnet.connect()Description
Establishes a secure connection between the DApp and the user's wallet.
Parameters
None required
Returns
Promise<object>containing:address(string): Current account addresspublicKey(string): Current account public key
๐ Learn more about wallet connections
Sign Messages
okxwallet.bitcoinTestnet.signMessage(signStr[, type])Description
Signs arbitrary messages for authentication or verification.
Parameters
signStr(string): Data requiring signaturetype(string, optional):"ecdsa"(default)"bip322-simple"
Returns
Promise<string>: Digital signature result
PSBT Signing
okxwallet.bitcoinTestnet.signPsbt(psbtHex[, options])Description
Signs Partially Signed Bitcoin Transactions (PSBT), automatically signing all inputs matching the current address.
Parameters
psbtHex(string): Hex representation of PSBToptions(object, optional):autoFinalized(boolean): Auto-finalize after signing (default: true)toSignInputs(array): Specific inputs to signdisableTweakSigner(boolean): Bypass Taproot tweaking
Returns
Promise<string>: Signed PSBT hex string
๐ Advanced PSBT signing techniques
Multi-PSBT Operations
okxwallet.bitcoinTestnet.signPsbts(psbtHexs[, options])Description
Batch signing for multiple PSBT transactions simultaneously.
Parameters
psbtHexs(string[]): Array of PSBT hex stringsoptions(object[], optional): Per-PSBT signing options
Returns
Promise<string[]>: Array of signed PSBT hex strings
FAQ Section
What's the difference between Testnet and Mainnet APIs?
The Testnet API provides identical functionality but operates on Bitcoin's test network, ideal for development and testing without real fund risk.
How secure are wallet connections?
All connections use end-to-end encryption and require explicit user approval for each transaction, ensuring enterprise-grade security.
Can I use this API with hardware wallets?
Yes, the API supports integration with major hardware wallets through the extension interface.
What's the advantage of PSBT over raw transactions?
PSBT enables secure multi-party signing workflows and better supports complex transaction types like CoinJoin.
How do I handle errors during signing?
The API returns detailed error messages including signature rejection reasons, with comprehensive documentation for troubleshooting.
Is there a rate limit for API calls?
While no hard limits exist, excessive requests may trigger security protections. Implement reasonable request pacing.