Out of box integrations help you build custom processors faster

Remember custom processors are fully-fledged Javascript runtime, so you can build any integration to any third-party with no limits. Sometimes you need an even easier way to integrate with a service; that's why we're going to add more ready-made integrations continuously.

🤑 Token Prices

Get current or historical USD value of any ERC20 token amount of any contract address on any chain, powered by CoinGecko, CoinMarketCap and Moralis.

You don't need an API Key from these providers, but if you need you can set your own API Key; for example if you have a larger plan with these providers.

1️⃣ prices.getUsdAmountByAddress(...)

This method tries to get the USD value of any token amount of a ERC20, if price data is available on any of the providers mentioned above.

It can optionally accept a block number (and/or timestamp) if you need historical data. It is highly recommended to provide these values based on the event data so that during backfills you get accurate data when loading historical data for the first time.

import { integrations } from 'flair-sdk';

await integrations.prices.getUsdAmountByAddress({
    // Chain ID of the ERC20 token
    chainId: number,
    // Address of ERC20 token (must have decimals() method)
    // If not provided or zero-address provided then it will consider
    // the native token e.g. ETH if chainId is 1
    tokenAddress?: string,
    // Raw (big number) representation of the amount you want to convert
    // For example 10000000000000000000 (which could mean 10 $ETH or $WBTC)
    // Default value is "1" meaning price of this token in USD.
    tokenAmount?: string,
    // Ideally try to get the price on this block number
    // Recommended to set it as "transaction.blockNumber"
    idealBlockNumber?: number,
    // Ideally try to get the price on this block timestamp
    // Recommended to set it as "transaction.blockTimestamp"
    idealTimestamp?: number,

// This method returns:
type PriceData = {
  isNativeToken: boolean; // If token is native (i.e. 0x000000)
  amountUsd: number; // USD value of the tokenAmount passed above.
  timestamp: number; // Exact timestamp where this price was captured
  granularity: 'minute' | 'hour' | 'day';
  timeBucket: string; // e.g. 2023-05-13T20:00 or 2023-05-13 based on granularity
  source: 'coingecko' | 'coinmarketcap' | 'moralis';

💫 Example Usage:

This example assumes each event has a token argument that has the ERC20 address and a feeAmount argument that is raw amount.

import { EventHandlerInput } from 'flair-sdk';

interface FetchUsdPriceParams {
  event: EventHandlerInput
  token: string
  amount: number

export async function processEvent({ event: EventHandlerInput }) {
  const usdValue = await fetchUsdPrice({
      token: event.parsed.args?._token,
      amount: event.parsed.args?._amount,
  console.log('My usdValue is:', {

export async function fetchUsdPrice({
}: FetchUsdPriceParams): Promise<number | null> {
  if (token && amount) {
    const price = await integrations.prices.getUsdAmountByAddress({
      chainId: event.chainId,
      tokenAddress: token,
      tokenAmount: amount,
      idealBlockNumber: event.blockNumber,
      idealTimestamp: event.blockTimestamp,

    return price ? price.amountUsd : null

  return null

🤖 Discord Bot

Send Discord messages right from your custom processor using already-configured Flair Bot.

1️⃣ discord.sendMessage(...)
  1. Add Flair Bot to your server using this authentication link.

  2. Use integrations global variable for the Discord integration:

await integrations.discord.sendMessage({
  guildId: process.env.DISCORD_GUILD_ID,
  channelName: process.env.DISCORD_CHANNEL_NAME,
  embeds: [embed],

Need a fully working example?

Checkout https://github.com/flair-sdk/examples

➕ More integrations

Are you looking for more out-of-box integrations? Reach out to our engineers 🙂

Last updated