Sandbox & Environments

How to use Dual's sandbox environment for development and testing before going to production.

Environment Overview

Dual provides two environments:

Sandbox Characteristics

  • All actions execute instantly, no Sequencer batching delay
  • No gas fees or DUAL token costs
  • On-chain settlement is simulated (no real Ethereum transactions)
  • Data is reset periodically, do not store production data here
  • Rate limits are more generous to support rapid iteration

Switching Environments

TypeScript SDK

Code
import { DualClient } from "dual-sdk";
// Sandbox (development)
const sandbox = new DualClient({
token: process.env.DUAL_SANDBOX_KEY,
authMode: "api_key",
baseUrl: "https://sandbox.api-testnet.dual.network",
});
// Production
const production = new DualClient({
token: process.env.DUAL_API_KEY,
authMode: "api_key",
baseUrl: "https://api-testnet.dual.network", // default
});

Python SDK

Code
from dual_sdk import DualClient
sandbox = DualClient(
token=os.environ["DUAL_SANDBOX_KEY"],
auth_mode="api_key",
base_url="https://sandbox.api-testnet.dual.network",
)
production = DualClient(
token=os.environ["DUAL_API_KEY"],
auth_mode="api_key",
# base_url defaults to https://api-testnet.dual.network
)

API Keys Per Environment

Sandbox and production use separate API keys. You can generate sandbox keys from the API Keys management page. Never use a production key in sandbox or vice-versa, the platform will reject the request.

Testing Webhooks in Sandbox

Use the Webhooks API test endpoint to simulate events without creating real objects:

Code
// TypeScript
await client.webhooks.test(webhookId, {
event: "object.created",
payload: { object_id: "obj_test_123" },
});
# Python
client.webhooks.test(webhook_id, {
"event": "object.created",
"payload": {"object_id": "obj_test_123"},
})

Environment Variables Best Practice

Code
# .env.development
DUAL_API_KEY=sandbox_key_xxxxxx
DUAL_BASE_URL=https://sandbox.api-testnet.dual.network
# .env.production
DUAL_API_KEY=prod_key_xxxxxx
DUAL_BASE_URL=https://api-testnet.dual.network

Use your framework's environment variable loading (e.g. dotenv, Next.js .env.local) to automatically switch between environments.

Further Reading