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",});// Productionconst 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 DualClientsandbox = 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
// TypeScriptawait client.webhooks.test(webhookId, {event: "object.created",payload: { object_id: "obj_test_123" },});# Pythonclient.webhooks.test(webhook_id, {"event": "object.created","payload": {"object_id": "obj_test_123"},})
Environment Variables Best Practice
Code
# .env.developmentDUAL_API_KEY=sandbox_key_xxxxxxDUAL_BASE_URL=https://sandbox.api-testnet.dual.network# .env.productionDUAL_API_KEY=prod_key_xxxxxxDUAL_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
- Production Readiness, checklist before going live
- API Keys, key management reference
- Set Up Webhooks, webhook tutorial