> For the complete documentation index, see [llms.txt](https://docs.kyte.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kyte.sh/developers/integrating.md).

# Integrating with Kyte

Read Kyte data and build on top of its contracts.

{% hint style="success" %}
**In short.** Read through the indexer API or straight from the contracts; write through the Router with ETH. Route by the id tag (1–2 → v1, 3–4 → v2), always pass a sensible `maxPremium`, and simulate before sending.
{% endhint %}

**Read data:** use the indexer API ([Indexer API](/developers/indexer-api.md)) or read the contracts directly: `getPosition(id)` on the market for the id's tag, `OptionNFT.ownerOf(id)` for the holder, and the registry views for listings.

**Write (viem example: buy a call with ETH):**

```ts
import { createWalletClient, custom, defineChain, publicActions } from 'viem'
import { callMarketAbi, routerAbi } from './abis' // from the verified sources on Etherscan

const robinhood = defineChain({
  id: 4663,
  name: 'Robinhood Chain',
  nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
  rpcUrls: { default: { http: ['https://rpc.mainnet.chain.robinhood.com'] } },
  blockExplorers: { default: { name: 'Etherscan', url: 'https://robin.etherscan.io' } },
})

const ROUTER_V2 = '0xf1648a2cDE31A2F80cb5Ba8c544f7FC7af826BCd'
const CALLS_V2 = '0x15B5d324960234B193246B122C555e88E341eD72'
const client = createWalletClient({ chain: robinhood, transport: custom(window.ethereum) }).extend(publicActions)
const [account] = await client.requestAddresses()
const id = 0n // the Option NFT id of the open offer you want to buy

const p = await client.readContract({ address: CALLS_V2, abi: callMarketAbi, functionName: 'getPosition', args: [id] })
const { request } = await client.simulateContract({
  account, address: ROUTER_V2, abi: routerAbi, functionName: 'buyWithETH',
  args: [id, p.premium],      // maxPremium
  value: p.premium,           // any excess is refunded
})
await client.waitForTransactionReceipt({ hash: await client.writeContract(request) })
```

**Rules for integrators**

* Route by id tag: tags 1–2 → v1 contracts, tags 3–4 → v2.
* Always pass a sensible `maxPremium`, and simulate before sending.
* Treat `strike` and `premium` as totals in WETH (18 decimals); `amount` uses the token's decimals.
* Exercise well before `expiry`.

ABIs: take them from each contract's verified source on Etherscan ([Deployed addresses](/protocol/addresses.md)).


---

# 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://docs.kyte.sh/developers/integrating.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.
