Connect to Xverse Wallet
Last updated
Last updated
Your application can request to connect to the user’s Xverse wallet with the wallet_connect
method.
The user will be prompted to connect their desired wallet account to your app, and share the account's Bitcoin and Stacks addresses.
You can optionally specify:
which wallet addresses you require from the wallet account: Bitcoin ordinals address, Bitcoin payment address or Stacks address, using the optional addresses
request parameter.
a custom connection message to show the user. You can use it to present your app and state the purpose of the connection request.
request parameters | Description |
---|---|
If the user is not connected to your app yet, their Xverse wallet will display a Connection Request prompt with:
your app url & your app logo (if it is specified in your app manifest)
the wallet addresses that your app required
the message which you specified. Note that this message will be cut beyond 80 characters.
the permissions that your app is requesting from their wallet
The user can select which of their Xverse account they wish to connect to your app.
The connect
method returns a Promise that resolves once the user approves the connection request or if they are already connected to your app.
Once resolved, the method returns connectResult
: 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:
After approving the connection request, the user can track the active connection with your app directly from their Xverse wallet, and revoke the connection from the wallet.
Note that if your app is referenced on Xverse Explore, Sats Connect will automatically display your app name & logo as they appear on Explore.
If the user has already granted permissions, no connection request popup will appear, ensuring a smooth user experience.
address field | Description |
---|---|
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
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.
a custom message to show to the user during the connection request
addresses
Optional
message
Optional