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 getTokenByAddress = createAction({
  name: 'get_token_by_address',
  classification: 'READ',
  displayName: 'Get Token by Address',
  description: 'Get token info by its contract address',
  audience: 'both',
  aiMetadata: { description: 'Look up the metadata for a single token by its contract address (name, symbol, decimals, type, total supply). Read-only. Use this when you have a specific token contract address; to discover tokens without an address use Get Tokens, and for holder or transfer detail use the dedicated token actions.', idempotent: true },
  // category: 'Tokens',
  props: {
    addressHash: Property.ShortText({
      displayName: 'Token Address',
      description: 'Contract address of the token to fetch info 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}`,
    });
    if (response.status !== 200) {
      throw new Error(`Blockscout API request failed with status ${response.status}`);
    }
    return response.body;
  },
});