APIs

Developer Docs

getAddresses API method

May 14, 2025

Disclaimer: Leather does not store or validate how these addresses are used externally. Developers must handle user data securely and with privacy considerations.

Request the Bitcoin addresses (Native SegWit and Taproot) and Stacks addresses for the active account of the user's wallet.

Method name

getAddresses

Parameters

None

Accounts

The number of the account connected by the user can be inferred using the derivationPath returned in the response. Note:

  • Derivation paths are zero-indexed internally.

  • For example, a derivation path of m/84'/0'/1'/0/0 corresponds to Account 2 in the UI.

This account value can be used in subsequent method calls (e.g. sendTransfer, signMessage, etc.). If not specified, the currently active account is used by default.

Examples

Example request

function accountFromDerivationPath(path) {
  const segments = path.split("/");
  const account = parseInt(segments[3].replaceAll("'", ""), 10);
  if (isNaN(account)) throw new Error("Cannot parse account number from path");
  return account;
}

const response = await window.LeatherProvider?.request("getAddresses");

console.log("Addresses:", response.result.addresses);
console.log("Account:", accountFromDerivationPath(response.result.addresses[0].derivationPath));

Example response

{
  "jsonrpc": "2.0",
  "id": "288a4a32-899b-47da-ac43-b6adbb8caec2",
  "result": {
    "addresses": [
      {
        "symbol": "BTC",
        "type": "p2wpkh",
        "address": "bc1qetcn9fdtzq3wez6vrljjyry225ml7j52h3kwgl",
        "publicKey": "0328e268de2bd09f703b379d20b8a53fdc9c599a09a8c2fcd9c35e7b3cc48d0ece",
        "derivationPath": "m/84'/0'/1'/0/0"
      },
      {
        "symbol": "BTC",
        "type": "p2tr",
        "address": "bc1ph65ywff65f0nl84xaxwdxgc2rc2gpr70tptllffktt3qzyx859zsp3zvwl",
        "publicKey": "03482aa14965b71358082b110a30b91ef8dfbe6fbae3b18f5b841323f599b954f8",
        "tweakedPublicKey": "482aa14965b71358082b110a30b91ef8dfbe6fbae3b18f5b841323f599b954f8",
        "derivationPath": "m/86'/0'/1'/0/0"
      },
      {
        "symbol": "STX",
        "address": "SPY0682ZM7VGPMVGQP99Z05J3QWMVV83RA6N42SA"
      }
    ]
  }
}

Use case

You can use the returned address to query third-party APIs like mempool.space:

const response = await window.LeatherProvider?.request("getAddresses");

const usersNativeSegwitAddress = response.result.addresses.find(
  address => address.type === "p2wpkh"
);
const addressDetails = await fetch("https://mempool.space/api/address/" + usersNativeSegwitAddress);

Sandbox

Try the getAddresses method live in this CodeSandbox testing environment: 👉 Open Sandbox