Sandbox
Complete guide to testing in the TransX402 sandbox environment — fund wallets, make test payments, and validate your integration.
What is the Sandbox?
The sandbox is a testing environment that lets you test your TransX402 integration without using real money. The sandbox uses Anvil — a local fork of the Base mainnet — so the IDRX and Permit2 contracts used are exactly the same as production, but all transactions are free.
Sandbox vs Production
| Aspect | Sandbox | Production |
|---|---|---|
| API key prefix | ipk_sandbox_ | ipk_live_ |
| Chain | Anvil fork of Base | Base mainnet |
| IDRX | Real contract (forked state), free test tokens | Real IDRX |
| Gas | Free (Anvil) | Real ETH (sponsored by facilitator) |
| Payments | Simulated, not real money | Real settlement |
| Dashboard | Shows sandbox transactions | Shows real transactions |
| Webhooks | Fires to merchant's webhook URL | Same |
| Facilitator URL | sandbox.transx402.com | api.transx402.com |
Getting Started
1. Get a Sandbox API Key
When you register at dashboard.transx402.com, a sandbox API key is automatically created. You can also create additional sandbox keys on the API Keys page:
2. Fund a Test Wallet
Before making test payments, you need to fund a wallet with test IDRX. There are two ways:
Via API
Response:
Via Dashboard
Go to the Sandbox page in the dashboard, enter the wallet address and the amount of IDRX you want to fund, then click the Fund button.
3. Use Built-in Test Wallets
The sandbox provides pre-funded test wallets. Get the wallet list:
Response:
These are Anvil's deterministic accounts with 10,000 ETH and plenty of test IDRX. The private keys are safe to use in sandbox since they only work on the Anvil chain.
Testing Payments
Basic Testing Flow
- Install integration — Use a sandbox API key in the JS library or WordPress plugin
- Fund wallet — Fill a test wallet with IDRX via the
/sandbox/fundendpoint - Access content — Open a paywalled page
- Pay — Click "Pay with IDRX", connect wallet, and sign
- Verify — Check the payment in the dashboard or via the
/paymentsAPI
Testing with the JS Library
Testing with cURL
Resetting the Sandbox
If you need to start fresh (e.g., after intensive testing), you can reset the sandbox state:
This will re-fork the Anvil chain from the latest Base mainnet block. All previous sandbox transactions will be lost, but the IDRX and Permit2 contracts remain available.
Differences from Production
Your integration code is exactly the same for sandbox and production. The only difference:
The library automatically detects the environment from the API key prefix and routes to the correct facilitator URL.
Local Development with Anvil
For local development, you can run your own Anvil instance using Docker Compose:
This will start:
- TransX402 API at
http://localhost:3402 - PostgreSQL at
localhost:5432 - Redis at
localhost:6379 - Anvil (Base fork) at
http://localhost:8545
Why Anvil Fork?
| Anvil Fork | Base Sepolia Testnet | |
|---|---|---|
| Real IDRX contract | Yes (forked state) | No (need to deploy mock) |
| Real Permit2 contract | Yes | Yes |
| Gas cost | Free | Free (testnet ETH) |
| Speed | Instant blocks | ~2s per block |
| Reproducible | Yes (fork from specific block) | No (shared state) |
| CI-friendly | Yes | Depends on RPC availability |
| Offline | Yes (after initial fork) | No |
Testing Tips
- Always test in sandbox first before switching to production
- Use webhooks to verify payment notifications are sent correctly
- Test error scenarios — try paying with insufficient balance, expired deadline, etc.
- Check the dashboard — make sure payments appear on the Payments page
- Test across wallets — MetaMask, Coinbase Wallet, etc.