# INTRODUCTION

Using [aiis.dev](https://aiis.dev) creating and even deploying your own token on the blockchain takes less than a minute! It requires no technical or coding experience at all, thanks to the powers of artificial intelligence.

<figure><img src="/files/lYiCACFfuCYvga7zo4DP" alt=""><figcaption></figcaption></figure>

The user is prompted to fill in info about how exactly they want their token parameters to be generated, and AI will respond with parameters ready to deploy!

<figure><img src="/files/IFOFJM0VDvOlkthKLzbV" alt=""><figcaption></figcaption></figure>

Once hitting "Generate," a series of API calls are made to the AI model selected, and it will use billions of different parameters to provide the best possible responses.

<figure><img src="/files/DqniiHfrLrQ3iycS4VWb" alt=""><figcaption></figcaption></figure>

If happy with everything, users can proceed to generate an image for the token based on its name, connect their wallet, hit deploy and it will be deployed on the blockchain!


# REQUIREMENTS

These are some things you should bring/understand trying to navigate the app...

The app doesn't require much, but here are a few necessary guidelines to get started deploying...

-If you don't already have a wallet, you will need one in order to get the token deployed

-you will also need ETH/SOL for deployment and fees on the network you want to deploy the token on

-lastly, bring your utmost creativity and prompting skills


# TOKEN NAME

On aiis.dev, you'll be greeted with a user interface asking for three crucial parameters, each instrumental in shaping the characteristics of the ai token.

The name query serves a three-pronged purpose: The input for the name not only captures user preferences naming, but also plays into its corresponding visual representation and ticker generation.

After populating the name input field and invoking the "Generate" function, the system triggers a sequence of API interactions with the ai models to process your parameters...

<figure><img src="/files/Omo8hcX30SdsftGByfTy" alt=""><figcaption></figcaption></figure>

Designed with a focus on user-driven customization, the app offers the flexibility to either guide the ai models toward specific outcomes or relinquish control and allow the AI to exercise its full creative latitude.&#x20;

To fine-tune the generative process further, the application's user interface provides a "temperature" adjustment slider.

<figure><img src="/files/xWrvulyAyTcvlKMCx6Ms" alt=""><figcaption></figcaption></figure>

Manipulating this allows you to control the model's randomness. For instance, to constrain model to generate more deterministic outputs, lower the "temperature" and phrase your prompt in a directive manner, such as "the token should be named...".&#x20;

Opting for higher temperature settings will yield more divergent and unpredictable results.

Of course, you can also write your own token name if you already had one in mind, and just toggle the "ai" switch off above, like seen below.

<figure><img src="/files/Li2aLIlU9OiWVBd6pBhr" alt=""><figcaption></figcaption></figure>


# TOKEN SYMBOL

When the user supplies a prompt for the name generation, ai models utilize this input as a foundation to algorithmically construct the token's ticker symbol.

To adhere to optimal practices, it's a good idea to formulate your prompt in a direct manner that explicitly states the AI's computational logic.

<figure><img src="/files/D1Ei06LcxBEcjsBbvgdw" alt=""><figcaption></figcaption></figure>

For instance, phrasing your instruction as "make it based on the name..." serves as a targeted heuristic, ensuring that the resultant ticker symbol is congruent with the previously generated token name.

Or if you already know what ticker you want, just switch off the "ai" setting like seen below!

<figure><img src="/files/FloFhyY84pjp1B70JSty" alt=""><figcaption></figcaption></figure>


# TOKEN SUPPLY

When you feed a prompt into the supply section, it will trigger the machine learning algorithms to interpret your instruction to determine the total supply of tokens.

For those aiming for precise control over the token supply, you can guide the ai models by framing your prompt in a directive manner, such as "69420000000."

This instructs the model to adhere strictly to your specified value, minimizing any randomness in the output.

<figure><img src="/files/1ANDDLeaUjeyZywNUmnP" alt=""><figcaption></figcaption></figure>

On the other end of the spectrum, the ai model can creatively surprise you with very creative numbers.

By loosening the "temperature" setting and formulating a more open-ended prompt, you can receive suggestions as intricate as mathematical constants like π for your token's total supply.

<figure><img src="/files/dzCkY0pSrkA1uczpzOOE" alt=""><figcaption></figcaption></figure>

Thus, whether you prefer a deterministic supply number or wish to venture into more creative numerical territories, the system offers the flexibility to cater to both ends of the spectrum.

If you know exactly what you want for supply, you can also directly write the response wanted without the use of ai. (toggle the ai switch off)

<figure><img src="/files/cQgrDOwLLtsId9Vfke1n" alt=""><figcaption></figcaption></figure>

NOTE: ALL SOLANA TOKENS, REGARDLESS OF GENERATED SUPPLY WILL HAVE 1,000,000,000 TOKENS TO ADHERE TO BONDING CURVE REQUIREMENTS.


# TOKEN IMAGE

The "Create Image" feature marks the final phase in the holistic creation of your token. It becomes available post-token name generation.

With the generated token name as baseline input, the text model crafts a nuanced and creative description. This descriptive output serves as the textual blueprint for the image model, which transmutes the prompt into a high-quality, visually captivating token image.&#x20;

<figure><img src="/files/DqniiHfrLrQ3iycS4VWb" alt=""><figcaption></figcaption></figure>

If the generated image doesn't exactly resonate with what you envisioned, just click the "Create Image" button again to initiate another round of generations.

You can also write your own exact prompts to be used for token image generation, with the "edit" icon button.

<figure><img src="/files/ywZ33zhmNIRqsPCp1rPD" alt=""><figcaption></figcaption></figure>

This intricate synergy of text and image ai models not only ensures that your token is furnished with a unique and aesthetically pleasing image but also encapsulates the power and flexibility of AI-driven design.


# LFG

Alright, the generation is ready, and the token is ready to go to the blockchain!

Tokens are free to deploy, just requiring a small amount of gas to cover the transaction. This is only a couple of bucks on Solana.

You can deploy the previous undeployed generations of other users, or make/deploy your very own.

<figure><img src="/files/Bicmw4KpjAb9kLjG1Fi9" alt=""><figcaption></figcaption></figure>

Just hit deploy on a generation, sign the transaction in your wallet, and the token will be ready to trade on the aiis.dev bond curve with its own designated token page.

<figure><img src="/files/ib6BxsaZvv7F0z5fkzdZ" alt=""><figcaption></figcaption></figure>

The bond curve was built to align with the battle tested standard offered by pump.fun, with a few small but very notable improvements.

Unlike pump.fun, aiis.dev uses the new CPMM programs from Raydium, which allows tokens to migrate at exactly 79 SOL with no additional fees attached.

Directly upon migration, the CPMM lock instruction is invoked, locking liquidity permanently and minting an NFT which retains the ability to claim fees from trading volume on the pair.&#x20;


# BOND CURVE

**Dynamic Pricing Model:**\
The bonding curve sets token prices automatically based on supply and demand using a smooth, non-linear polynomial function. This function determines the cumulative cost in SOL to mint tokens as more of the total supply is issued.

<figure><img src="/files/wmQEcZwIyjibBBFGeBj0" alt=""><figcaption></figcaption></figure>

**Virtual and Real Reserves:**

* **Virtual Reserves:** Used to simulate the current state of token issuance and calculate the price.
* **Real Reserves:** Actual tokens and SOL held in the pool. Initially, 80% of tokens go into the bonding curve while 20% are reserved for liquidity.

**How It Works:**

* **Buying Tokens:**\
  When a user buys tokens, their SOL increases the cumulative cost needed to mint new tokens. The program calculates how many tokens to issue based on this increase while applying a 1% fee. If the SOL amount rises above 79 SOL, only the necessary amount is used to fill the curve and any excess is refunded.

<figure><img src="/files/YjaYV54Edv3KtzPgzxyO" alt=""><figcaption></figcaption></figure>

* **Selling Tokens:**\
  Selling tokens reduces the minted fraction, and the system calculates the SOL to return based on the difference in cumulative cost before and after the sale—again charging a 1% fee.

### Migration

Once the 79 SOL threshold is reached, migration begins immediately.  Depending on trading activity, a small buffer of tokens may remain in the bonding curve even after migration, which can be considered burnt. Migration is executed by a Cross-Program Invocation (CPI) that transfers the underlying liquidity pool to Raydium.

* Necessary Associated Token Accounts (ATAs) are created if they don’t already exist.
* The CPI instruction is then executed to migrate the pool to Raydium.

Finally, once the liquidity pool has been created on Raydium, the migration authority on the program calls the CPMM lock instruction, effectively locking liquidity and minting an NFT which retains the ability to claim fees from trading volume on the pair.


# API

Our API provides a set of endpoints to interact with ai and the blockchain:

* Generate Endpoints: `https://api.aiis.dev/v2/generations/generate`\
  (This endpoint combines text and image generation into a single call and automatically creates a generation record.)
* List Shared Generations: `https://api.aiis.dev/v2/generations/list`
* Get Generation by ID: `https://api.aiis.dev/v2/generations/:id`
* **Deploy Endpoint:**\
  Deploy a new SPL token with associated metadata and bonding curve initialization.
  * **Deploy Token:** `https://api.aiis.dev/v2/deploy`
* **Swap Endpoint:**\
  Prepare unsigned transactions for token swaps on Solana using the bonding curve.
  * **Swap Transaction:** `https://api.aiis.dev/v2/swap/prepare`
* **Token Endpoint:**\
  Manage and retrieve token data recorded on the blockchain.

  * **Token Count:**&#x20;

  `https://api.aiis.dev/v2/token/count`

  * **Token List:**&#x20;

  `https://api.aiis.dev/v2/token/list`

These endpoints encapsulate all necessary blockchain logic, allowing any user to provide a few basic parameters and receive unsigned transactions on the client and deployment-ready ai token parameters.


# Generate

## Generate Endpoints

These endpoints accept inputs and return generated content based on the chosen model. The server handles the heavy lifting (e.g., calling GPT, DALL·E, or other LLM/image models) and returns a simple JSON response.

### Generation Endpoint

This endpoint combines text and image generation into a single streamlined request. Instead of using separate endpoints for text and image generation, the items are generated concurrently and automatically create a generation record. The endpoint calls the appropriate AI models and returns a JSON response containing the generated content along with the record ID.

**Endpoint URL:**\
`https://api.aiis.dev/v2/generations/generate`

**Request Payload:**\
The endpoint expects a JSON payload with the following fields:

* **name** (string): The token name.
* **prompt** (string): The prompt for image generation.
* **symbol** (string): The token symbol.
* **supply** (string): The token supply.
* **namePrompt** (string): Prompt for generating a token name.
* **symbolPrompt** (string): Prompt for generating a token symbol.
* **supplyPrompt** (string): Prompt for generating a token supply description.
* **temperature** (number): Required for most text generation models.
* **textModel** (string): Specifies which text generation model to use. Options include:
  * GPT-3.5 (use "GPT-3.5")
  * GPT-4 (use "GPT-4")
  * Claude
  * Gemini
  * Llama
  * Bittensor
  * AstroPepeX
* **model** (string): Specifies the image generation model to use. Options include:
  * DALLE-2 (use "DALLE-2")
  * DALLE-3 (use "DALLE-3")
  * Bittensor
  * Flux
  * CUSTOM
* **with\_ai** (boolean):
  * **true:** The endpoint applies additional AI-based enhancements to generate creative and refined outputs.
  * **false:** The endpoint bypasses AI generation and returns the provided prompt values as the output. This allows clients to use their own values without triggering extra processing.

**How It Works:**

1. **Input Validation:** The endpoint validates and casts the incoming request using a DTO.
2. **API Keys & Context:** It extracts the necessary API keys and configuration from the request context.
3. **Model-Specific Generation:**
   * **Image Generation:**\
     The endpoint selects the appropriate function (e.g., `genDalle2Image`, `genDalle3Image`, etc.) based on the `model` parameter. This function produces an image URL and returns the final prompt used for generation.
   * **Text Generation:**\
     Based on the `textModel` parameter (and ensuring that `temperature` is provided when required), the corresponding function (e.g., `generateGPT3Text`, `generateGPT4Text`, etc.) is invoked to generate text outputs such as the token name, supply, and symbol.
4. **with\_ai Parameter Behavior:**
   * If **with\_ai** is set to **true**, the endpoint calls the AI generation functions to produce enhanced, creative outputs.
   * If **with\_ai** is set to **false**, the endpoint will bypass the AI generation step and simply return the input values provided in the payload. This allows for a deterministic or fallback behavior on the client side.
5. **Record Creation:** The endpoint automatically creates a new generation record on [aiis.dev](https://aiis.dev) using the generated data.

   * **Response:** A JSON response is returned that includes the generation record ID, the generated image details, and text outputs.

   **Example Request:**

   ```bash
   curl -X POST https://api.aiis.dev/v2/generations/generate \
   -H "Content-Type: application/json" \
   -d '{
     "name": "MyToken",
     "prompt": "A futuristic cityscape at sunset",
     "symbol": "MTK",
     "supply": "1000000",
     "namePrompt": "Generate a catchy token name",
     "symbolPrompt": "Generate a short token symbol",
     "supplyPrompt": "Generate a token supply description",
     "temperature": 0.75,
     "textModel": "GPT-4",
     "model": "DALLE-2",
     "with_ai": true
   }'
   ```

   **Example Response:**

   ```json
   {
     "genId": "cm7pf0dsa0003n20fyimyos92",
     "image": {
       "url": "https://aiisdev.mypinata.cloud/ipfs/QmTJuM3wbMRPeFqWnckJwXqbe5Lty6LHgCWuta6fJG1b55",
       "prompt": "A futuristic cityscape at sunset"
     },
     "text": {
       "name": "DankShibeCoin",
       "supply": "1000000",
       "symbol": "DSC"
     }
   }
   ```

   \
   **List Generations:**

   `https://api.aiis.dev/v2/generations/list`\
   Returns a paginated list of shared generation records. Query parameters include:

   * **page:** The page number.
   * **pageSize:** The number of records per page.
   * **sortBy:** Sorting criteria (e.g., "latest", "mostUpvoted", "deployed", "mcap", or "bumps").
   * **tokensOnly:** (Optional) If true, only generations with an associated token are returned.
   * **chain:** (Optional) Filter by blockchain network.

   **Example Request:**

   ```bash
   curl -X GET "https://api.aiis.dev/v2/generations/list?page=1&pageSize=10&sortBy=latest"
   ```

   **Example Response:**

   ```json
   {
     "generations": [
       {
         "id": "cm7mjki5o001gn20faca9on1p",
         "name": "PepeChain",
         "symbol": "PEPE",
         "supply": "1000000000",
         "image_url": "https://aiisdev.mypinata.cloud/ipfs/QmSpFXJHp72Tz87oyrkZm9xjVMSBMDdSj42GpDTpTWVB47",
         "thumbnail_image_url": "https://aiisdev.mypinata.cloud/ipfs/QmYjjSdkBkLADLYCG6Hirs4StkrPY9FwGGkntZkFKB8ym3",
         "name_prompt": "make a token based on pepe...",
         "symbol_prompt": "make it funny...",
         "supply_prompt": "pi...",
         "image_prompt": "A radiant Pepe the Frog character is whimsically morphed into an enchanting chain link...",
         "temperature": 0.75,
         "llm_model": "Claude",
         "image_model": "Flux",
         "with_ai": true,
         "createdAt": "2025-02-26T23:23:31.692Z",
         "upvotes": 0,
         "token": null
       }
     ],
     "totalPages": 1313,
     "currentPage": 1
   }
   ```

**Get Generation by ID:** Fetches detailed information for a single generation record by its unique ID.

**Example Request:**

```bash
curl -X GET https://api.aiis.dev/v2/generations/cm7mfh3cs000zn20frerj7ahe
```

**Example Response:**

```json
{
  "id": "cm7mfh3cs000zn20frerj7ahe",
  "name": "StonksBrahMemeFi",
  "symbol": "STONK",
  "supply": "1000000000",
  "image_url": "https://aiisdev.mypinata.cloud/ipfs/QmZRW9zbDnoQawwr8UxFDuduG43N7p4iQn3jpHKNBBZ5yf",
  "thumbnail_image_url": "https://aiisdev.mypinata.cloud/ipfs/QmRn76B8vJvfmsQAQLHvmcbn23wRAvcCuPRASFjF32Bkyq",
  "name_prompt": "@WallStreetMav @deploybrah",
  "symbol_prompt": "@WallStreetMav @deploybrah",
  "supply_prompt": "1000000000",
  "image_prompt": "@WallStreetMav @deploybrah",
  "temperature": 0.85,
  "llm_model": "GPT-4",
  "image_model": "Flux",
  "with_ai": true,
  "createdAt": "2025-02-26T21:28:54.077Z",
  "upvotes": 0,
  "token": null
}
```

────────────────────────────\
**Note:** The separate text and image generation endpoints have been merged into the single Generation Endpoint, which both generates content and creates a corresponding record. This simplifies integration and ensures consistency across generation requests.

1. **Response:** A JSON response is returned that includes the generation record ID, the generated image details, and text outputs.

**Example Request:**

```bash
curl -X POST https://api.aiis.dev/v2/generations/generate \
-H "Content-Type: application/json" \
-d '{
  "name": "MyToken",
  "prompt": "A futuristic cityscape at sunset",
  "symbol": "MTK",
  "supply": "1000000",
  "namePrompt": "Generate a catchy token name",
  "symbolPrompt": "Generate a short token symbol",
  "supplyPrompt": "Generate a token supply description",
  "temperature": 0.75,
  "textModel": "GPT-4",
  "model": "DALLE-2",
  "with_ai": true
}'
```

**Example Response:**

```json
{
  "genId": "cm7pf0dsa0003n20fyimyos92",
  "image": {
    "url": "https://aiisdev.mypinata.cloud/ipfs/QmTJuM3wbMRPeFqWnckJwXqbe5Lty6LHgCWuta6fJG1b55",
    "prompt": "A futuristic cityscape at sunset"
  },
  "text": {
    "name": "DankShibeCoin",
    "supply": "1000000",
    "symbol": "DSC"
  }
}
```

\
**List Generations:**

`https://api.aiis.dev/v2/generations/list`\
Returns a paginated list of shared generation records. Query parameters include:

* **page:** The page number.
* **pageSize:** The number of records per page.
* **sortBy:** Sorting criteria (e.g., "latest", "mostUpvoted", "deployed", "mcap", or "bumps").
* **tokensOnly:** (Optional) If true, only generations with an associated token are returned.
* **chain:** (Optional) Filter by blockchain network.

**Example Request:**

```bash
curl -X GET "https://api.aiis.dev/v2/generations/list?page=1&pageSize=10&sortBy=latest"
```

**Example Response:**

```json
{
  "generations": [
    {
      "id": "cm7mjki5o001gn20faca9on1p",
      "name": "PepeChain",
      "symbol": "PEPE",
      "supply": "1000000000",
      "image_url": "https://aiisdev.mypinata.cloud/ipfs/QmSpFXJHp72Tz87oyrkZm9xjVMSBMDdSj42GpDTpTWVB47",
      "thumbnail_image_url": "https://aiisdev.mypinata.cloud/ipfs/QmYjjSdkBkLADLYCG6Hirs4StkrPY9FwGGkntZkFKB8ym3",
      "name_prompt": "make a token based on pepe...",
      "symbol_prompt": "make it funny...",
      "supply_prompt": "pi...",
      "image_prompt": "A radiant Pepe the Frog character is whimsically morphed into an enchanting chain link...",
      "temperature": 0.75,
      "llm_model": "Claude",
      "image_model": "Flux",
      "with_ai": true,
      "createdAt": "2025-02-26T23:23:31.692Z",
      "upvotes": 0,
      "token": null
    }
  ],
  "totalPages": 1313,
  "currentPage": 1
}
```

**Get Generation by ID:**\
`GET https://api.aiis.dev/v2/generations/:id`\
Fetches detailed information for a single generation record by its unique ID.

**Example Request:**

```bash
https://api.aiis.dev/v2/generations/cm7mfh3cs000zn20frerj7ahe
```

**Example Response:**

```json
{
  "id": "cm7mfh3cs000zn20frerj7ahe",
  "name": "StonksBrahMemeFi",
  "symbol": "STONK",
  "supply": "1000000000",
  "image_url": "https://aiisdev.mypinata.cloud/ipfs/QmZRW9zbDnoQawwr8UxFDuduG43N7p4iQn3jpHKNBBZ5yf",
  "thumbnail_image_url": "https://aiisdev.mypinata.cloud/ipfs/QmRn76B8vJvfmsQAQLHvmcbn23wRAvcCuPRASFjF32Bkyq",
  "name_prompt": "@WallStreetMav @deploybrah",
  "symbol_prompt": "@WallStreetMav @deploybrah",
  "supply_prompt": "1000000000",
  "image_prompt": "@WallStreetMav @deploybrah",
  "temperature": 0.85,
  "llm_model": "GPT-4",
  "image_model": "Flux",
  "with_ai": true,
  "createdAt": "2025-02-26T21:28:54.077Z",
  "upvotes": 0,
  "token": null
}
```

────────────────────────────\
**Note:** The separate text and image generation endpoints have been merged into the single Generation Endpoint, which both generates content and creates a corresponding record. This simplifies integration and ensures consistency across generation requests.


# Deploy

The deploy route prepares an unsigned versioned transaction to deploy a new SPL token along with its associated metadata and bonding curve initialization. It combines several steps—fetching ephemeral signing keys and metadata URIs, building token creation instructions via Umi builders, and initializing the bonding curve via Anchor—into a single transaction that anyone can sign.

**How It Works**

1. **Tip Transfer:**\
   The route adds a jio tip instruction to send a small amount of lamports for faster transaction landing. This is similar to the swap route.
2. **Umi Setup & External API Calls:**
   * A Umi instance is created and configured with the mpl-token-metadata and wallet adapter identity plugins.
   * Two external API calls are made concurrently:
     * **Vanity/Pop:** Returns an ephemeral keypair (for token minting) so that the server does not use a persistent key.
     * **Pin-Body:** Uploads metadata (name, image, description, and custom attributes like textModel and generationId) and returns a metadata URI.
3. **Building Token Instructions (Branch A):**\
   Using Umi builders, the route:

* Creates a fungible token with the provided name, symbol, and metadata URI.
* Ensures that an associated token account (ATA) exists for the token.
* Mints a fixed supply of tokens.
* Removes the mint authority, freeze authority, and update authority so that the token is fully decentralized post-deployment.
* Converts the Umi instructions to Web3.js TransactionInstructions.

4. **Bonding Curve Initialization (Branch B):**\
   In parallel, the route builds an Anchor instruction to initialize the bonding curve for the token. This instruction sets up the pairing between the token and wrapped SOL (WSOL) so that further actions can be performed.

* **Combining & Signing:**\
  The instructions from both branches (plus the tip transfer) are combined into a single list. A versioned transaction is then built from these instructions. Before returning the transaction, it is signed with the ephemeral key (generated from the vanity API call).
* **Response:**\
  The final output is a base64-encoded unsigned transaction along with the token mint’s public key. Clients can then sign this transaction using their wallet and submit it to the blockchain.

#### Example Request:

```json
curl -X POST https://api.aiis.dev/v2/deploy \
-H "Content-Type: application/json" \
-d '{
  "name": "MyToken",
  "symbol": "MTK",
  "supply": "1000000",
  "description": "A test token for deployment.",
  "imageUri": "https://aiisdev.mypinata.cloud/ipfs/QmZRW9zbDnoQawwr8UxFDuduG43N7p4iQn3jpHKNBBZ5yf",
  "textModel": "GPT4",
  "generationId": "cm7mfh3cs000zn20frerj7ahe",
  "walletPublicKey": "YourWalletPublicKeyHere"
}'

```

#### Example Response:

```json
{
  "transaction": "BASE64_ENCODED_TRANSACTION_STRING",
  "mint": "NewTokenMintPublicKey"
}
```

#### How It Works on the Client

1. **Send Request:**\
   The client sends the above payload to the deploy endpoint.
2. **Receive Transaction & Mint:**\
   The server responds with a base64-encoded unsigned transaction and the token mint’s public key.
3. **Sign and Submit:**\
   The client deserializes the transaction, signs it using their wallet, and then submits the signed transaction to the blockchain (for example, via a bundler like Jito).


# Swaps

This explains how to use the aiis.dev swap endpoint for preparing unsigned Solana transactions to swap tokens using our bonding curve. The route supports two operations: a **buy** swap (wrapping SOL into WSOL and executing a buy instruction) and a **sell** swap (executing a sell instruction and cleaning up WSOL).

***

### How It Works

1. **Account Setup and Preparation**
   * **Associated Token Accounts**: The route derives and, if necessary, creates the user’s WSOL and target token accounts.
   * **WSOL Account Top-Up and Sync**: For buy operations, the code calculates whether additional lamports (including a fee buffer) are needed to top up the WSOL account and then syncs the account to update its wrapped SOL balance.
   * **Tip Transfer**: A jito tip transfer instruction is added at the start to send a small fee for faster landing.
   * **Bonding Curve Instruction**: Depending on the route ("buy" or "sell"), the corresponding bonding curve instruction is appended.
   * **Cleanup**: For sell operations, the WSOL account is closed after the swap.
2. **Transaction Building**
   * All instructions are assembled into a versioned transaction.
   * The transaction is serialized to a base64-encoded string and returned to the client for signing. The server never signs transactions, ensuring that private keys remain secure on the client side.

***

### How to Use

#### Endpoint

* **Method:** POST
* **Path:** `/swap/prepare`

#### Request Payload Schema

```json
{
  "route": "buy" or "sell",
  "lamports": "<amount as string>",
  "mint": "<token mint address>",
  "userPublicKey": "<user's wallet public key>"
}
```

* **route**: Specifies the swap type. Use `"buy"` for buying tokens or `"sell"` for selling.
* **lamports**: The amount (in lamports) involved in the swap, provided as a string.
* **mint**: The mint address of the token being swapped.
* **userPublicKey**: The user's wallet public key.

#### Example Request:

```json
curl -X POST https://api.aiis.dev/v2/swap/prepare \
-H "Content-Type: application/json" \
-d '{
  "route": "buy",
  "lamports": "1000000",
  "mint": "So11111111111111111111111111111111111111112",
  "userPublicKey": "YourPublicKeyHere"
}'
```

#### Example Response:

```json
{
  "unsignedTx": "BASE64_ENCODED_TRANSACTION_STRING"
}
```

* **unsignedTx**: This is the unsigned versioned transaction encoded in base64. The client is expected to sign this transaction before submitting it to the blockchain.

### Integration:

```javascript
import axios from "axios";
import { Connection, VersionedTransaction, Keypair, clusterApiUrl } from "@solana/web3.js";
import { readFileSync } from "fs";

(async () => {
  // Load private key from file (ensure this file is secured!)
  const secret = JSON.parse(readFileSync("path/to/secret-key.json", "utf8"));
  const keypair = Keypair.fromSecretKey(new Uint8Array(secret));

  // Define parameters for the swap
  const API_URL = "https://api.aiis.dev/v2/swap/prepare"; // Your swap route endpoint
  const params = {
    route: "buy",
    lamports: "1000000", // Amount in lamports as a string
    mint: "TokenMintPublicKeyHere",
    userPublicKey: keypair.publicKey.toBase58(),
  };

  // Fetch unsigned transaction from the swap route
  const { data: { unsignedTx } } = await axios.post(API_URL, params);
  if (!unsignedTx) throw new Error("No unsigned transaction returned");

  // Deserialize and sign the transaction
  const tx = VersionedTransaction.deserialize(Buffer.from(unsignedTx, "base64"));
  await keypair.signTransaction(tx);

  // Send the signed transaction
  const connection = new Connection(clusterApiUrl("devnet"), "processed");
  const txId = await connection.sendRawTransaction(tx.serialize());
  console.log("Transaction sent, txid:", txId);
})();
```


# Tokens

### GET /count

**Description:**\
Returns a JSON object containing the total number of tokens recorded.

**Example Request:**

```json
curl -X GET https://api.aiis.dev/v2/token/count
```

**Example Response:**

```json
{
  "totalRecorded": 1234
}
```

### GET /list

**Description:**\
Returns a paginated list of tokens. Query parameters include:

* `page` (required): The page number (e.g., 1).
* `pageSize` (required): The number of tokens per page (e.g., 10).
* `sortBy` (optional): Sorting criteria (e.g., "latest", "mcap", "upvotes", "network").

**Example Request (cURL):**

```json
curl -X GET "https://api.aiis.dev/v2/token/list?page=1&pageSize=10&sortBy=latest"
```

**Example Response:**

```json
[
  {
    "address": "ELx3q1i5pbBihJp1fJe1yy8cBvHdBAHFaRrNVGiZx5Ai",
    "chain": "Solana",
    "name": "ip",
    "symbol": "IP20",
    "supply": "1000000000",
    "model": "Bittensor",
    "pool_address": "2jQdQ8cFKRZVPiKAVb3SMa4BKPFL8ZkqtBgRosHqbFV5",
    "locker_address": "",
    "deployer": "F9Wsf78trw9eMZDzwGNWhFmm4uwEzzFP57HrRwoiwpCG",
    "created_at": "2025-02-26T07:34:26.621Z",
    "generationId": "cm7llmi4b000nn20fstmgchhd",
    "is_migrated": null,
    "website": null,
    "twitter": null,
    "discord": null,
    "coinGeckoId": null,
    "coinMarketCapId": null,
    "token_stats": {
      "token_address": "ELx3q1i5pbBihJp1fJe1yy8cBvHdBAHFaRrNVGiZx5Ai",
      "chain": "Solana",
      "volume1": "0",
      "volume4": "0",
      "volume12": "0",
      "volume24": "40.446",
      "liquidity": "0",
      "priceUSD": "0.000004103982260227859",
      "change1": "0",
      "change4": "0",
      "change12": "0",
      "change24": "0",
      "mcap": 4103.982260227859
    }
  }
]
```

These endpoints allow users to efficiently retrieve token data without needing to manage the underlying database or caching logic. The minimal examples above demonstrate how to interact with these endpoints using simple GET requests.


