Skip to main content
In this guide, you’ll learn how to retrieve the total lifetime fees earned by a Solana token using the Bags TypeScript SDK with Node.js. This is useful for tracking token performance and earnings over time.

Prerequisites

Before starting, make sure you have:

1. The Token Lifetime Fees Script

Here is a simple script to fetch token lifetime fees. Save this as get-token-lifetime-fees.ts. This script uses the updated SDK API to retrieve lifetime fees for any token and displays them in a user-friendly format.

Endpoint Used Under the Hood

This guide uses:

2. Run Your Script

To analyze a token’s lifetime fees, edit the getTokenLifetimeFees function call at the bottom of the script with the actual mint address you want to analyze. Then, run the script from your terminal:

What You’ll See

The script will output the total lifetime fees earned by the token in SOL, formatted with proper number localization for easy reading. Example output:

Alternative: Using the Bags CLI

This section requires the Bags CLI. See Install and Set Up the Bags CLI to get started.
Get lifetime fees for a token directly from the terminal:
To display the result in raw lamports instead of SOL:

Use Cases

This information is valuable for:
  • Token Performance Analysis: Track how much revenue a token has generated
  • Investment Research: Evaluate token success based on fee generation
  • Portfolio Management: Monitor earnings from tokens you’ve created or invested in
  • Market Analysis: Compare performance across different tokens
For more advanced token analytics, check out our Get Token Creators guide.