Guide
Overview
This guide helps users understand how to use the OneKey Provider API to easily build web applications that can interact with BTC.
Install
1. Download OneKey Wallet
Download the OneKey Wallet. Install the OneKey browser extension.
2. API Injection Explanation
The OneKey browser extension injects
Provider APIinto visited websites.Two types of APIs are provided:
window.unisatandwindow.$onekey.btc.It is recommended to use
window.$onekey.btc.
Both APIs have the same functionality, just different names.
Detecting Provider API support
Before you start using Provider Api you need to check for browser support by checking if the variable window.unisat is defined:
const provider = (window.$onekey && window.$onekey.btc) || window.unisat;
if (!provider) {
alert("OneKey Not installed.");
}Connecting to OneKey
Before using the following API, you first need to use the provider.requestAccounts method to request the user to access the relevant BTC account.
provider.requestAccounts()Other APIs can be called only after user authorization.
API
Clarify Needs: Identify required functionalities, call relevant interfaces
Get user's account information:
provider.getAccountsSend a payment:
provider.sendBitcoinRequest signature for any message:
provider.signMessage
More Interfaces: View Details
Event
Key Operations: Such as account switching
More Information: View More
Last updated
Was this helpful?