# Configuration

## Installation

You can use `npm` to install this SDK.&#x20;

```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.&#x20;

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

### Client Initialization

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

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` or `mainnet`               | `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` | Override the Gateway contract address                | (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.&#x20;

|              | Testnet                                                                                                                    | Mainnet                                                                                                                    |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Token (USDC) | `0x0724D6079b986F8e44bDafB8a09B60C0bd6A45a1`                                                                               | `0x5b32c997211621d55a89Cc5abAF1cC21F3A6ddF5`                                                                               |
| Subgraph URL | [Goldsky endpoint](https://api.goldsky.com/api/public/project_cmnoqdag1obop01z3efnu8ssq/subgraphs/delphi-testnet/1.0.0/gn) | [Goldsky endpoint](https://api.goldsky.com/api/public/project_cmnoqdag1obop01z3efnu8ssq/subgraphs/delphi-mainnet/1.0.0/gn) |
| App URL      | `https://testnet.delphi.fyi`                                                                                               | `https://app.delphi.fyi`                                                                                                   |

### 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: 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:

```
GET https://docs.gensyn.ai/tech/delphi-sdk/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
