spark_getAddresses

This method is coming ๐Ÿ”œ

Your application can request to connect to the userโ€™s Spark wallet with the spark_getAddresses method, which prompts them to share their Spark address.

Your app must have first connected to the wallet and obtained account read permissions.

No request parameters are required:

import { request } from "sats-connect";

try {

  const response = await request("spark_getAddresses", {});

    if (response.status === "success") {
      alert("Success getting accounts. Check console for results.");
      console.log("Accounts:", response.result);
    } else {
      alert("Error getting accounts. Check console for details.");
      console.error(response);
    }
}

The method returns a Promise that resolves to return GetAddressesResult: an array of the userโ€™s wallet address objects, defined as:

address field
Description

address

the userโ€™s connected Spark wallet address

network

string - the network where the address is being used:

  • mainnet for Spark Mainnet

  • regtest for Spark Regtest

You can use these addresses to make further Stacks requests such as sending Spark Bitcoin or sending Spark BTKN.

If your app has not yet obtained account read permissions, the spark_getAddresses will prompt the user with a Connection Request in their wallet. The prompt will display:

  • your app logo, if it is specified in your app manifest

  • the Spark wallet addresses that your app required

If the user declines the request or closes the pop-up, the promise will reject (throw when awaited).

Last updated