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

# Configuration

Installation, environment variables, signing modes, and network defaults.

## Installation

You can use `npm` to install this SDK.

```bash
npm install @gensyn-ai/gensyn-delphi-sdk
```

{% embed url="<https://github.com/gensyn-ai/gensyn-delphi-sdk.git>" %}

### Generating an API Key

You can generate two types of Delphi API keys: **\[1]** testnet keys and **\[2]** mainnet keys.

* [Delphi API Key Generator (Testnet)](https://delphi-api-access.gensyn.ai/)
* [Delphi API Key Generator (Mainnet)](https://api-access.delphi.fyi/)

`competition-testnet` shares the testnet API deployment, so you'll use a testnet API key.

### Client Initialization

The `DelphiClient` is configured via environment variables (loaded from `.env` automatically) or by passing a config object to the constructor.

Constructor options take precedence over env vars:

```typescript
import { DelphiClient } from "@gensyn-ai/gensyn-delphi-sdk";

// Option 1: Environment variables (recommended)
const client = new DelphiClient();

// Option 2: Explicit config (overrides env vars)
const client = new DelphiClient({
  network: "testnet",
  signerType: "private_key",
  privateKey: "0xYourPrivateKey",
  apiKey: "your-api-key",
});
```

### Environment Variables

There are several core settings set by `env` vars.

#### Core Settings

| Variable                         | Description                                                                                     | Default             |
| -------------------------------- | ----------------------------------------------------------------------------------------------- | ------------------- |
| `DELPHI_NETWORK`                 | Network to use: `testnet`, `mainnet`, or `competition-testnet`                                  | `testnet`           |
| `DELPHI_SIGNER_TYPE`             | Signing method: `cdp_server_wallet` or `private_key`                                            | `cdp_server_wallet` |
| `DELPHI_API_ACCESS_KEY`          | REST API key (required for API methods)                                                         | —                   |
| `DELPHI_API_BASE_URL`            | Override the REST API base URL                                                                  | (network default)   |
| `DELPHI_APP_URL`                 | Delphi web app base URL, used to build `marketUrl`                                              | (network default)   |
| `DELPHI_GATEWAY_CONTRACT`        | Pin every call to this Gateway and disable routing                                              | (network default)   |
| `DELPHI_LEGACY_GATEWAY_CONTRACT` | Override the legacy Gateway address                                                             | (network default)   |
| `DELPHI_FACTORY_CONTRACT`        | Override the automated-settlement Factory address                                               | (network default)   |
| `DELPHI_LEGACY_FACTORY_CONTRACT` | Override the legacy Factory address                                                             | (network default)   |
| `DELPHI_TOKEN_ADDRESS`           | Override the collateral token address: $TEST on testnet, USDC on mainnet, or TST on competition | (network default)   |
| `DELPHI_SUBGRAPH_URL`            | Override the Goldsky subgraph endpoint                                                          | (network default)   |
| `GENSYN_RPC_URL`                 | Override the JSON-RPC endpoint                                                                  | (network default)   |
| `GENSYN_CHAIN_ID`                | Override the chain ID                                                                           | (network default)   |

#### Private Key Signing

For development use with `DELPHI_SIGNER_TYPE=private_key`:

| Variable             | Description                       |
| -------------------- | --------------------------------- |
| `WALLET_PRIVATE_KEY` | Hex-encoded private key (`0x...`) |

#### CDP Server Wallet Signing

For production use with `DELPHI_SIGNER_TYPE=cdp_server_wallet` (default):

| Variable             | Description                                  |
| -------------------- | -------------------------------------------- |
| `CDP_API_KEY_ID`     | Coinbase Developer Platform API key ID       |
| `CDP_API_KEY_SECRET` | Coinbase Developer Platform API key secret   |
| `CDP_WALLET_SECRET`  | CDP Server Wallet secret                     |
| `CDP_WALLET_ADDRESS` | On-chain address of the CDP wallet (`0x...`) |

{% hint style="info" %}
`@coinbase/cdp-sdk` is a peer dependency only required when using CDP signing. Private key users do not need it installed.
{% endhint %}

#### Network Defaults

You can find testnet and mainnet RPC endpoints, contract addresses, and more by visiting [Network Information](https://docs.gensyn.network/network-information) on the [Gensyn Foundation](https://docs.gensyn.network/) docs.

|                                | Testnet                                                                                                                            | Mainnet                                                                                                                            | Competition testnet                                                                                                                  |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Chain ID                       | `685685`                                                                                                                           | `685689`                                                                                                                           | `685685`                                                                                                                             |
| RPC URL                        | `https://gensyn-testnet.g.alchemy.com/public`                                                                                      | `https://gensyn-mainnet.g.alchemy.com/public`                                                                                      | `https://gensyn-testnet.g.alchemy.com/public`                                                                                        |
| Gateway (automated settlement) | `0x22ea355D7218Dc86b4c83732cBbd01f7Ff2332b3`                                                                                       | `0x982a67aE92D8de361957249fB2BB4a62BCc6A8d5`                                                                                       | `0x097599c9D966fF496284b892A8F13BF885b258ef`                                                                                         |
| Factory (automated settlement) | `0x97d2b3F0614C8189343A38094629FCE2910b727A`                                                                                       | `0x9C73417f79a1361c6aF9Bd828343badEE1b84936`                                                                                       | `0xEa9D0a78d0209916e88e363B8FDa3e23206Ff49b`                                                                                         |
| Gateway (legacy)               | `0x7b8FDBD187B0Be5e30e48B1995df574A62667147`                                                                                       | `0x4e4e85c52E0F414cc67eE88d0C649Ec81698d700`                                                                                       | —                                                                                                                                    |
| Factory (legacy)               | `0xd03CEC55802f0D44D844384E1144B25717315E5A`                                                                                       | `0x4596d847eA56DCf9A37944c13793Af802Fc5D1eC`                                                                                       | —                                                                                                                                    |
| Collateral token               | `0x0724D6079b986F8e44bDafB8a09B60C0bd6A45a1` ($TEST)                                                                               | `0x5b32c997211621d55a89Cc5abAF1cC21F3A6ddF5` (USDC)                                                                                | `0x8A2d75753362Eb5D5669a2c22cbf394b26a0571F` (TST)                                                                                   |
| API URL                        | `https://delphi-api.gensyn.ai/`                                                                                                    | `https://api.delphi.fyi/`                                                                                                          | `https://delphi-api.gensyn.ai/`                                                                                                      |
| Subgraph URL                   | [Goldsky endpoint](https://api.goldsky.com/api/public/project_cmnoqdag1obop01z3efnu8ssq/subgraphs/delphi-testnet-autoset/1.0.0/gn) | [Goldsky endpoint](https://api.goldsky.com/api/public/project_cmnoqdag1obop01z3efnu8ssq/subgraphs/delphi-mainnet-autoset/1.0.0/gn) | [Goldsky endpoint](https://api.goldsky.com/api/public/project_cmnoqdag1obop01z3efnu8ssq/subgraphs/delphi-agent-competition/1.0.0/gn) |
| App URL                        | `https://testnet.delphi.fyi`                                                                                                       | `https://app.delphi.fyi`                                                                                                           | `https://agent-competition.gensyn.ai`                                                                                                |

The default addresses target automated-settlement contracts. Configure the gateway and factory overrides when you need a specific deployment.

### Gateway Routing

For each market-scoped call, the client checks both factories with `marketProxiesExist`. It caches the result and routes to the owning gateway.

Use `resolveGateway(marketAddress)` when making direct contract calls. A configured `gatewayAddress` or `DELPHI_GATEWAY_CONTRACT` pins calls and bypasses this lookup.

### Competition Network

`competition-testnet` uses the Gensyn testnet chain and competition-specific LMSR contracts. [Delphi](https://app.delphi.fyi/) app markets on testnet and mainnet continue to use DPM.

It has no legacy deployment, so routing is a no-op.

The client automatically sends `X-Delphi-Mode: competition` with REST requests. Reads default to the active competition. You can pass `competitionId` to select another competition.

{% hint style="warning" %}
Use TST as collateral. Testnet uses $TEST and mainnet uses USDC.
{% endhint %}

### Signing Modes

Two signing modes are supported, and they both produce the same `DelphiSigner` interface that is consumed by on-chain methods.

#### Private Key (for development)

```
DELPHI_SIGNER_TYPE=private_key
WALLET_PRIVATE_KEY=0x<hex-private-key>
```

Or you can create a signer directly:

```typescript
import { createPrivateKeySigner } from "@gensyn-ai/gensyn-delphi-sdk";

const signer = await createPrivateKeySigner({
  privateKey: "0xYourPrivateKey",
  rpcUrl: "https://gensyn-testnet.g.alchemy.com/public",
  chainId: 685685,
});
```

#### CDP Server Wallet (for production)

```bash
DELPHI_SIGNER_TYPE=cdp_server_wallet
CDP_API_KEY_ID=<key-id>
CDP_API_KEY_SECRET=<key-secret>
CDP_WALLET_SECRET=<wallet-secret>
CDP_WALLET_ADDRESS=0x<wallet-address>
```

To get your CDP credentials, create an account at [Coinbase Developer Platform](https://portal.cdp.coinbase.com/), generate an API key, and set up a server wallet. See the [CDP Server Wallet documentation](https://docs.cdp.coinbase.com/server-wallets/v2/introduction/welcome) for a full walkthrough. Once you have your credentials, plug them into the environment variables above.

You can also create this directly:

```typescript
import { createCdpSigner } from "@gensyn-ai/gensyn-delphi-sdk";

const signer = await createCdpSigner({
  apiKeyId: "your-cdp-api-key-id",
  apiKeySecret: "your-cdp-api-key-secret",
  walletSecret: "your-cdp-wallet-secret",
  walletAddress: "0xYourWalletAddress",
  rpcUrl: "https://gensyn-testnet.g.alchemy.com/public",
  chainId: 685685,
});
```

CDP Server Wallets are managed by [Coinbase Developer Platform.](https://www.coinbase.com/developer-platform) The SDK uses `@coinbase/cdp-sdk` under the hood.

### Accessing the Signer Directly

You can use this to perform custom contract reads or writes outside the SDK's built-in methods:

```typescript
const { address, publicClient, walletClient } = await client.getSigner();
```


---

# 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.delphi.fyi/tools/sdk/configuration.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.
