What is Injected Provider API?
The OKX Injected Providers API is a JavaScript-based interface embedded by OKX into websites. This powerful tool enables decentralized applications (DApps) to:
- Request user account information
- Retrieve blockchain data
- Facilitate message and transaction signing
- Manage wallet connections seamlessly
Wallet Connection Methods
Connect Wallet
👉 Connect your wallet with ease
okxwallet.bitcoin.connect()Parameters: None
Returns:
address: Current account addresspublicKey: Public key of current account
Request Accounts
okxwallet.bitcoin.requestAccounts()Parameters: None
Returns: Current account address
Account Management
Get Accounts
okxwallet.bitcoin.getAccounts()Returns: Current account address
Get Network
okxwallet.bitcoin.getNetwork()Returns: Active network name
Note: Testnet not supported
Transaction Operations
Send Bitcoin
okxwallet.bitcoin.sendBitcoin(toAddress, satoshis, {feeRate})Parameters:
toAddress: Recipient addresssatoshis: Amount to sendfeeRate: Optional custom fee rate
Send Transaction (with Memo Support)
okxwallet.bitcoin.send({from, to, value, satBytes, memo, memoPos})Supports OP_RETURN outputs for memos
Transfer NFT
okxwallet.bitcoin.transferNft({from, to, data})Supports batch transfers of Ordinals or Atomicals protocol NFTs
Balance and Asset Management
Get Balance
okxwallet.bitcoin.getBalance()Returns:
- Confirmed balance
- Unconfirmed balance
- Total balance
Get Inscriptions
okxwallet.bitcoin.getInscriptions({cursor, size})Retrieves detailed inscription information including:
- Inscription ID
- Content type
- Timestamp
- Location data
Advanced Features
Sign PSBT
okxwallet.bitcoin.signPsbt(psbtHex, {options})Supports complex signing scenarios with customizable options
Push PSBT
okxwallet.bitcoin.pushPsbt(psbtHex)Broadcasts signed PSBT to network
Inscribe Operations
okxwallet.bitcoin.inscribe({type, from, tick, tid})Supports BRC-20 token operations
Event Handling
Account Changed
okxwallet.bitcoin.on('accountChanged', (account) => {...})Monitors account switching events
FAQ Section
How do I connect my wallet to a DApp?
Simply call okxwallet.bitcoin.connect() and approve the connection request in your wallet interface.
What's the difference between sendBitcoin and send methods?
sendBitcoin is for basic BTC transfers, while send supports additional features like memos and custom OP_RETURN outputs.
Can I batch transfer multiple NFTs?
Yes, use the transferNft method with an array of NFT data for batch transfers.
How do inscription protocols differ?
Ordinals protocol is for general NFTs, while Atomicals supports additional token standards with different capabilities.
What PSBT signing options are available?
You can control finalization, specify inputs to sign, and set custom sighash types for advanced transaction scenarios.