Connect to the BitPocket Wallet
"Connecting" or "logging in" to BitPocket Wallet effectively means "to access the user's Bitcoin account(s)".
You should only initiate a connection request in response to direct user action, such as clicking a button. You should always disable the "connect" button while the connection request is pending. You should never initiate a connection request on page load.
We recommend that you provide a button to allow the user to connect BitPocket Wallet to your dapp. Clicking this button should call the following method:
Methods
requestAccounts
window.bitpocket.unisat.requestAccounts()
Connect the current account.
Parameters
none
Returns
Promisereturnsstring[]: Address of current account.
try {
let accounts = await window.bitpocket.unisat.requestAccounts();
console.log('connect success', accounts);
} catch (e) {
console.log('connect failed');
}
> connect success ['tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz']
disconnect
window.bitpocket.unisat.disconnect()
Disconnect the current account.
Parameters
none
Returns
Promisereturnsvoid
window.bitpocket.unisat.disconnect();