> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inkyswap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API Examples

> Copyable server-side reads and deployment-aware contract snippets.

All InkyPump REST examples include `chainId`. Run them on your server unless the endpoint states that third-party browser access is supported.

## Discover the active Ink hook

```ts theme={null}
const response = await fetch(
  "https://inkypump.com/api/capabilities?chainId=57073",
  { cache: "no-store" },
)
if (!response.ok) throw new Error(`Capabilities failed: ${response.status}`)

const capabilities = await response.json()
if (!capabilities.flags.create) throw new Error("Creation is disabled")

const deployment = capabilities.activeCreationDeployment
const hook = deployment.hook
```

Do not replace an existing token's hook with this value. It is for new native launches.

## Fetch one token

```ts theme={null}
const address = "0x5fc71b21bd8c7e76fa7514d9fec1f91898a86c7f"
const response = await fetch(
  `https://inkypump.com/api/token?chainId=57073&address=${address}`,
  { cache: "no-store" },
)

if (response.status === 404) return null
if (!response.ok) throw new Error(`Token lookup failed: ${response.status}`)

const token = await response.json()
console.log(token.hook_address, token.launch_id, token.lifecycle_state)
```

## Fetch recent launches

```bash theme={null}
curl "https://inkypump.com/api/tokens/recent-v2?chainId=57073&limit=10&offset=0"
```

## Batch lookup

```ts theme={null}
const addresses = [tokenA, tokenB].join(",")
const response = await fetch(
  `https://inkypump.com/api/tokens/batch?chainId=57073&addresses=${addresses}`,
)
const { tokens } = await response.json()

const tokenARecord = tokens[tokenA.toLowerCase()] // Token or null
```

## List launchable xStocks assets

```ts theme={null}
const response = await fetch(
  "https://inkypump.com/api/xstocks/quote-assets?chainId=57073&pageSize=100",
  { cache: "no-store" },
)
const data = await response.json()

const launchable = data.assets.filter(
  (asset) => asset.canCreate && asset.deployment?.active,
)
```

The returned asset set can change. Use the exact wrapper, hook, decimals, and raw limits from the selected record.

## Read launch state

```ts theme={null}
const state = await publicClient.readContract({
  address: token.hook_address,
  abi: HOOK_READ_ABI,
  functionName: "getLaunchState",
  args: [BigInt(token.launch_id)],
})

console.log({
  finalized: state.finalized,
  sold: state.sold,
  saleSupply: state.saleSupply,
  targetRaise: state.targetRaise,
})
```

There is no `state.tokensRemaining` field. Compute `state.saleSupply - state.sold`.

## Watch the correct Trade event

```ts theme={null}
import { parseAbiItem } from "viem"

const tradeEvent = parseAbiItem(
  "event Trade(uint256 indexed launchId, address indexed trader, uint8 tradeType, (uint256 price, uint128 sold, uint40 timestamp) priceData, (address trader, uint256 tokenAmount, uint256 ethAmount) tradeData, uint256 refund)",
)

const unwatch = publicClient.watchEvent({
  address: token.hook_address,
  event: tradeEvent,
  onLogs: (logs) => logs.forEach((log) => console.log(log.args)),
})
```

## Read the exact post-bond pool

First match the token's hook to its deployment. Corrected native hooks and current xStocks hooks expose:

```ts theme={null}
const poolKey = await publicClient.readContract({
  address: token.hook_address,
  abi: HOOK_READ_ABI,
  functionName: "getLaunchPoolKey",
  args: [BigInt(token.launch_id)],
})
```

For `hookAbi: "ink-legacy"`, do not call that selector. Require the complete `pool_currency0`, `pool_currency1`, `pool_fee`, `pool_tick_spacing`, `pool_hook`, and `pool_id` fields from the token response. Validate the currency pair, original hook, fee, tick spacing, and computed pool ID as shown in [Post-Bond Pool](/trading/post-bond-pool).

Do not replace native ETH with WETH, substitute a current hook, or guess a missing legacy field.

## Launch a token

Use the complete receipt-safe browser-wallet example in [Launchpad Quickstart](/integrations/launchpad-quickstart). It discovers the current hook, simulates the write, validates `LaunchCreated`, and handles indexing delay without duplicate submission.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.