# 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>" %}

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

### 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();
```
