Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.3 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';

export const getTokenCounters = createAction({
  name: 'get_token_counters',
  classification: 'READ',
  displayName: 'Get Token Counters',
  description: 'Get token counters (holders count, transfers count, etc.)',
  audience: 'both',
  aiMetadata: { description: 'Get aggregate counts for one token by its contract address, such as total number of holders and total transfers. Read-only. Use this when you just need the summary numbers; to enumerate the actual holders or transfers use Get Token Holders or Get Token Transfers instead.', idempotent: true },
  // category: 'Tokens',
  props: {
    addressHash: Property.ShortText({
      displayName: 'Token Address',
      description: 'Contract address of the token to fetch counters for',
      required: true,
    }),
  },
  async run(context) {
    const response = await httpClient.sendRequest({
      method: HttpMethod.GET,
      url: `https://eth.blockscout.com/api/v2/tokens/${context.propsValue.addressHash}/counters`,
    });
    if (response.status !== 200) {
      throw new Error(`Blockscout API request failed with status ${response.status}`);
    }
    return response.body;
  },
});