> For the complete documentation index, see [llms.txt](https://stonkfun.gitbook.io/stonkfun-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stonkfun.gitbook.io/stonkfun-docs/developer-api/fee-endpoints.md).

# Fee claim endpoints

Three calls, in the same shape as launching: read, prepare, sign locally, submit.

Standard launches only. Reward coins have no creator position and answer `403`.

***

## `GET /tokens/{mint}/fees`

Trading fees currently claimable by the creator of a standard launch, in both the base and quote token.

This needs no wallet, so a dashboard can show what is waiting before anyone connects.

| Parameter | In   | Required | Description        |
| --------- | ---- | -------- | ------------------ |
| `mint`    | path | Yes      | Token mint address |

Reward coins return `claimable: null` with a reason rather than an error.

```bash
curl 'https://www.stonkfun.xyz/api/public/v1/tokens/<mint>/fees'
```

***

## `POST /tokens/{mint}/fees/claim/prepare`

Returns an unsigned transaction that pays the creator their claimable trading fees, plus the amounts it will collect.

Rate limit: 20 per minute, per IP.

| Parameter       | In   | Required | Description                                                                               |
| --------------- | ---- | -------- | ----------------------------------------------------------------------------------------- |
| `mint`          | path | Yes      | Token mint address                                                                        |
| `creatorWallet` | body | Yes      | The wallet holding the Fee Key NFT. It must be the fee payer of the transaction you sign. |

Sign the returned transaction with the wallet holding this launch's Fee Key NFT and post it to `/fees/claim/submit`.

The harvest is only valid signed by that wallet and pays that wallet's own token accounts, so no platform key signs anything, and a claim prepared for a token you do not own is unusable. That is why this endpoint needs no credential.

| Status | Meaning                                                        |
| ------ | -------------------------------------------------------------- |
| `200`  | An `intentId` and a base64 `transaction`, valid for 90 seconds |
| `403`  | A reward coin, so no creator position exists                   |
| `409`  | Nothing is claimable yet                                       |

Expiring costs nothing. Prepare again, since fees keep accruing.

***

## `POST /tokens/{mint}/fees/claim/submit`

Relays the signed claim, waits for confirmation, and answers with the transaction signature. Fees land directly in the creator's token accounts.

| Parameter           | In   | Required | Description                                                   |
| ------------------- | ---- | -------- | ------------------------------------------------------------- |
| `mint`              | path | Yes      | Token mint address                                            |
| `creatorWallet`     | body | Yes      | The same wallet passed to `/prepare`                          |
| `intentId`          | body | Yes      | From `/fees/claim/prepare`                                    |
| `signedTransaction` | body | Yes      | The transaction from `/prepare`, signed by the creator wallet |

Only the exact transaction issued by `/prepare` is relayed, and its instructions are checked against what was built before anything is broadcast.

It is idempotent per `intentId`. An intent already relayed returns its original signature with `alreadySubmitted: true`, so a retry after a timeout cannot claim twice.

***

## Complete example

```js
import { Keypair, Transaction } from '@solana/web3.js';
import fs from 'node:fs';

const API = 'https://www.stonkfun.xyz/api/public/v1';
const mint = 'YOUR_TOKEN_MINT';
const creator = Keypair.fromSecretKey(            // the wallet holding the Fee Key NFT
  Uint8Array.from(JSON.parse(fs.readFileSync('creator.json', 'utf8')))
);

const headers = { 'Content-Type': 'application/json' };
const call = async (path, init) => {
  const response = await fetch(API + path, init);
  const body = await response.json();
  if (!response.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
  return body.data;
};

// 1. What is waiting? A plain read, no wallet involved.
const { claimable } = await call(`/tokens/${mint}/fees`);
if (!claimable) throw new Error('Nothing claimable on this launch');
console.log('Waiting:', claimable.quote.amountTokens, claimable.quote.symbol);

// 2. Prepare. Returns an UNSIGNED claim transaction, valid for 90 seconds.
const wallet = creator.publicKey.toBase58();
const prepared = await call(`/tokens/${mint}/fees/claim/prepare`, {
  method: 'POST',
  headers,
  body: JSON.stringify({ creatorWallet: wallet }),
});

// 3. Sign locally. Your key never leaves this process, and this transaction can only ever
//    pay you: sign it as-is, since altering the instructions invalidates the claim.
const tx = Transaction.from(Buffer.from(prepared.transaction, 'base64'));
tx.sign(creator);

// 4. Submit. The fees land straight in your own token accounts.
const claimed = await call(`/tokens/${mint}/fees/claim/submit`, {
  method: 'POST',
  headers,
  body: JSON.stringify({
    creatorWallet: wallet,
    intentId: prepared.intentId,
    signedTransaction: tx.serialize().toString('base64'),
  }),
});

console.log('Claimed:', claimed.signature);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://stonkfun.gitbook.io/stonkfun-docs/developer-api/fee-endpoints.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
