wallet_getAccount
Last updated
Last updated
Your app can fetch the user's active Xverse account with the wallet_getAccount
method.
The app must have first connected to the wallet and obtained account read permissions.
You can optionally specify which wallet addresses you require, Bitcoin ordinals address, Bitcoin payment address or Stacks address, using the optional addresses
request parameter.
an array of strings used to specify which address(es) to request from the user's Xverse wallet account:
'ordinals'
is preferably used to manage the user’s ordinals
'payment'
is preferably used to manage the user’s bitcoin
'stacks'
is used to interact with the stacks ecosystem
Example: ['ordinals', 'payment', 'stacks']
Will default to ['ordinals', 'payment', 'stacks']
if not specified.
The wallet_getAccount
method attempts to fetch the user's active Xverse account directly. You can use it to grant your connected user a smooth experience, without connection popups.
If your user has already connected their active Xverse account to your app, and granted your app the necessary account read permissions -> the method successfully return getAccountResult
: an array of the user’s wallet address objects, defined as:
You can use these addresses to make further requests such as signing a message, signing a transaction, etc.
Currently, you can retrieve two types of Bitcoin addresses, the user's Bitcoin payment address and the Ordinals address which is a taproot address.
An example response:
Where:
address
string - the user’s connected wallet address
publicKey
A hex string representing the bytes of the public key of the account. You can use this to construct partially signed Bitcoin transactions (PSBT).
purpose
string - The purpose of the address:
ordinals
is preferably used to manage the user’s ordinals
payment
is preferably used to manage the user’s bitcoin
stacks
is used to interact with the stacks ecosystem
addressType
string - the address’s format:
P2TR
for ordinals
P2SH
for payment
P2WPKH
for payment using Ledger
stacks
for Stacks
network
string - the network where the address is being used:
mainnet
for Bitcoin & Stacks mainnet
testnet
for Bitcoin & Stacks testnet
Signet
for Bitcoin Signet
walletType
string - the type of wallet used for the account
ledger
if the user's account is using a Ledger device
software
otherwise
If your user has not connected their active Xverse account to your app yet, and your app does not the necessary account read permissions -> the method will throw with
You can use the connect
or wallet_requestPermissions
methods to request a connection to your user's active Xverse account.
addresses
Optional