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

# For Developers

Trench exposes on-chain interfaces for aggregators, trading terminals, bots, and wallets to interact with the bonding curve directly from Solidity or any EVM library.

All interactions go through the **TrenchManager** contract — the single entry point for creating tokens, buying, selling, and querying curve state.

| Chain                 | Contract                | Address                                      |
| --------------------- | ----------------------- | -------------------------------------------- |
| **Ethereum Mainnet**  | TrenchManagerV2 (Proxy) | `0x974B2d86d6353c62f19110127aF1A5df4c6370f0` |
| **MegaETH Mainnet**   | TrenchManagerV3 (Proxy) | `0x2978E15501C792152602eC85c299083aa61b1bd4` |
| **Robinhood Mainnet** | TrenchManager (Proxy)   | `0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d` |
| **Arc Mainnet**       | TrenchManager (Proxy)   | `0xA1F18086218CBC8e556f0AF035E8cFC2f18bA96F` |

## Quick start

{% tabs %}
{% tab title="Robinhood" %}

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ITrenchManager {
    function buy(
        uint256 amountIn,
        uint256 amountOutMin,
        address token,
        address to,
        uint256 deadline
    ) external payable returns (uint256 amountOut);
}

contract SimpleBuyer {
    ITrenchManager constant MANAGER =
        ITrenchManager(0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d);

    function buyTokens(address token, uint256 minTokens) external payable {
        MANAGER.buy{value: msg.value}(
            msg.value,
            minTokens,
            token,
            msg.sender,
            block.timestamp + 300
        );
    }
}
```

{% endtab %}

{% tab title="Arc" %}

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IERC20 {
    function approve(address spender, uint256 amount) external returns (bool);
}

interface ITrenchManager {
    function buy(
        uint256 amountIn,
        uint256 amountOutMin,
        address token,
        address to,
        uint256 deadline
    ) external returns (uint256 amountOut);
}

contract SimpleBuyer {
    // Arc quotes in USDC (6 decimals) — buy is NOT payable; approve USDC first
    ITrenchManager constant MANAGER =
        ITrenchManager(0xA1F18086218CBC8e556f0AF035E8cFC2f18bA96F);
    IERC20 constant USDC =
        IERC20(0x3600000000000000000000000000000000000000);

    function buyTokens(address token, uint256 usdcAmount, uint256 minTokens) external {
        USDC.approve(address(MANAGER), usdcAmount);
        MANAGER.buy(
            usdcAmount,          // 6-decimal USDC, e.g. 1 USDC = 1_000000
            minTokens,
            token,
            msg.sender,
            block.timestamp + 300
        );
    }
}
```

{% endtab %}

{% tab title="Ethereum" %}

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ITrenchManagerV2 {
    function buy(
        uint256 amountIn,
        uint256 amountOutMin,
        address token,
        address to,
        uint256 deadline
    ) external payable returns (uint256 amountOut);
}

contract SimpleBuyer {
    ITrenchManagerV2 constant MANAGER =
        ITrenchManagerV2(0x974B2d86d6353c62f19110127aF1A5df4c6370f0);

    function buyTokens(address token, uint256 minTokens) external payable {
        MANAGER.buy{value: msg.value}(
            msg.value,
            minTokens,
            token,
            msg.sender,
            block.timestamp + 300
        );
    }
}
```

{% endtab %}

{% tab title="MegaETH" %}

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ITrenchManagerV3 {
    function buy(
        uint256 amountIn,
        uint256 amountOutMin,
        address token,
        address to,
        uint256 deadline
    ) external payable returns (uint256 amountOut);
}

contract SimpleBuyer {
    ITrenchManagerV3 constant MANAGER =
        ITrenchManagerV3(0x2978E15501C792152602eC85c299083aa61b1bd4);

    function buyTokens(address token, uint256 minTokens) external payable {
        MANAGER.buy{value: msg.value}(
            msg.value,
            minTokens,
            token,
            msg.sender,
            block.timestamp + 300
        );
    }
}
```

{% endtab %}
{% endtabs %}

## In this section

* [Contract Reference](/trench-today/for-developers/contracts.md) — addresses, on-chain parameters, full ABI
* [Integration Guide](/trench-today/for-developers/integration-guide.md) — core concepts, patterns, security checklist
* [ABI Files](/trench-today/for-developers/abi-files.md) — downloadable JSON ABI files

## Support

For integration support or API key requests, reach us through the channels listed under [Resources → Links](/trench-today/resources/links.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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://trench-today.gitbook.io/trench-today/for-developers/api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
