
getAddresses
Request the Bitcoin addresses (Native SegWit and Taproot) and Stacks addresses for the active account of the user's wallet
Method name
getAddresses
Parameters
chains
Chains to request addresses for: bitcoin, stacks, or both. Defaults to both
❌
string[]
network
Network identifier
❌
string
Accounts
The number of the account connected by the user can be inferred by the derivationPath property for addresses returned in the response.
Account values as indicated by derivation paths are one less than account values as represented in the wallet for users (i.e. the account value 6 corresponds to "Account 7").
In the example response below, the user has connected "Account 2" in their wallet (i.e. account value 1 per the derivation path).
This account number can be used for the account parameter on the Bitcoin methods (signMessage, sendTransfer, signPsbt) to indicate the account for which to request them.
The Stacks methods do not take an account parameter. To indicate a Stacks request to a specific account, pass the address parameter with the STX address returned in the getAddresses response. This applies to stx_callContract, stx_transferStx and stx_deployContract.
If neither parameter is specified, the user's currently active account is used for fulfillment. That may not be the account your app is connected with.
getAddresses is a connection request, not a query
Every call to getAddresses re-runs the connection approval flow and opens a Connect app prompt. Leather does not resolve the call against a previous approval for the same origin, so the prompt is populated with the wallet's currently active account, which may not be the account your app is already connected with.
Call getAddresses once, on an explicit user action, and persist the returned addresses in your own app state. Do not call it to test whether a user is still connected, and do not call it immediately before a signing method.
Example request
Example response
Do not read addresses by index e.g. result.addresses[2]
Developers must not rely on elements being at a fixed index. Ledger users may not have all keys, and more may be added in future. Accessing by index is not safe.
Create a helper function using Array.find instead
Example use case
You can use response data to store and retrieve data associated with any of the user's addresses.
For example, you can query mempool.space API with a Bitcoin address for on-chain address details:
Sandbox
Install the Leather extension then try out this method below:
Preview

Last updated
Was this helpful?