getAddresses - SDK

Get all addresses tracked for the provided AddressActivityWebhook.An Address Activity Webhook tracks ETH, ERC20, ERC721, and ERC1155 transfers for the provided addresses. This can be used to notify your app of real-time state changes when your tracked addresses send or receive tokens.

Don’t have an API key?

Start using this method in your app today.

Description

Get all addresses tracked for the provided AddressActivityWebhook.

An Address Activity Webhook tracks ETH, ERC20, ERC721, and ERC1155 transfers for the provided addresses. This can be used to notify your app of real-time state changes when your tracked addresses send or receive tokens.

Parameters

NameTypeDescription
addressWebhookstringThe Address Activity webhook. Available options are: MINED_TRANSACTION,
DROPPED_TRANSACTION, ADDRESS_ACTIVITY, NFT_ACTIVITY.
optionsobjectOptional Pagination options when fetching addresses.

Parameters include:

1. limit - number Number of addresses to fetch.

2. pageKey - string Page cursor for the next page.

Response

PropertyTypeDescription
Promise<AddressActivityResponse>array of objectsList of addresses and pagination info.

AddressActivityResponse parameters

PropertyTypeDescription
addressesarray of stringsList of addresses associated with given webhook.
totalCountnumberThe total number of addresses.
pageKeystringOptional Page key used to fetch the remaining addresses.

Example Request and Response

Prerequisite: You will need to install the Alchemy SDK before making requests with it.

The commands for installing it using npm or yarn are given below:

npm install alchemy-sdk@latest
yarn add alchemy-sdk@latest

Request

// Imports the Alchemy SDK
const { Alchemy, Network} = require("alchemy-sdk");

// Configures the Alchemy SDK
// authToken is required to use Notify APIs. Found on the top right corner of
// https://dashboard.alchemy.com/notify.
const config = {
    authToken: "your-auth-token                                                                                                                                                                                                            ", // Replace with your API key
    network: Network.ETH_MAINNET, // Replace with your network
};

// Creates an Alchemy object instance with the config to use for making requests
const alchemy = new Alchemy(config);

const main = async () => {
    //Define the webhooks by fetching all the Webhooks
    const hooks = await alchemy.notify.getAllWebhooks();

    //Call the method to return the addresses by ID using the webhookId.
    const addressesById = await alchemy.notify.getAddresses("wh_qv16bt12wbj9kax4", {
        limit: 3,
    });

    // Get the addresses by webhooks
    const addressesByWebhook = await alchemy.notify.getAddresses(
        hooks.webhooks[3],
        { limit: 3, pageKey: 1 }
    );

    //Logging the response to the console
    console.log(addressesById, addressesByWebhook)
}

main();

Response

[
  {
    "addresses": [
      "string"
    ],
    "totalCount": 0,
    "pageKey": "string"
  }
]

Use Cases

Here are some potential use cases for the getAddresses method:

  • Monitoring User Balances: Developers can use Alchemy Notify to monitor user balances for specific Ethereum addresses. getAddresses can be used to retrieve the addresses currently being monitored and ensure that the balances of these addresses are up-to-date.

  • Monitoring Smart Contract Events: Alchemy Notify can also be used to monitor events on smart contracts. Developers can use getAddresses to retrieve the addresses currently being monitored and ensure that events from these addresses are being properly received and processed.

  • Tracking Transactions: Developers can use Alchemy Notify to track transactions on the Ethereum network.getAddresses can be used to retrieve the addresses of the wallets or contracts involved in a particular transaction and ensure that the transaction is being tracked properly.

Related Methods

ReadMe