Token Management

This section details API endpoints for managing the lifecycle of SPL tokens on Solana, including creation, transfer, and burning.

Create Tokens (POST /api/tokens/create)

Mints a new SPL token on the Solana network. You define its name, symbol, decimals, initial supply, and the owner wallet which will have mint authority.

Request Endpoint: POST /api/tokens/create

Request Body: application/json

{
  "name": "My Solana Token",
  "symbol": "MST",
  "decimals": 6, // Number of decimal places
  "initialSupply": 100000000, // Total initial tokens (consider decimals)
  "ownerAddress": "wallet_address_for_mint_authority"
}

Success Response (200 OK): Provides the new token's mint address and the creation transaction signature.

{
  "success": true,
  "tokenAddress": "new_token_mint_address",
  "tx": "creation_transaction_signature",
  "metadata": {} // Optional field, structure may vary
}

Common Errors:

  • 500 Internal Server Error: On-chain creation failed (e.g., insufficient funds for rent).

Transfer Tokens (POST /api/tokens/transfer)

Moves a specified amount of an existing SPL token from one wallet address to another.

Request Endpoint: POST /api/tokens/transfer

Request Body: application/json

Success Response (200 OK): Returns the transaction signature.

Common Errors:

  • 500 Internal Server Error: Insufficient token balance, invalid wallet addresses.

Burn Tokens (POST /api/tokens/burn)

Permanently destroys (burns) a specified amount of an SPL token held by a wallet. Request Endpoint: POST /api/tokens/burn

Request Body: application/json

Success Response (200 OK): Returns the burn transaction signature.

Common Errors:

  • 500 Internal Server Error: Insufficient token balance.

Fetch Token Info (GET /api/tokens/{tokenAddress}/info)

Note: Confirm this endpoint exists and verify its exact path and response structure.

Retrieves on-chain details about a specific SPL token, such as its name, symbol, decimals, and current total supply.

Request Endpoint: GET /api/tokens/{tokenAddress}/info

Path Parameter:

  • tokenAddress (string, required): The mint address of the token.

Request Example:

Success Response (200 OK - Example Structure):

Common Errors:

  • 404 Not Found: If the token address is invalid or not found on-chain.

  • 500 Internal Server Error: RPC node issues fetching data.

Last updated