spark_getAddress

This method is coming 🔜

Your application can request to connect to the user’s Spark wallet with the spark_getAddress 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

publicKey

A hex string representing the bytes of the public key of the Spark account

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