Fund the Account
Fund the account before trading. Every trade and quote tutorial assumes "test USDC deposited into the safe". This page shows how that USDC gets there and how it leaves: the faucet grants it, deposit posts it, and a signed intent releases it.
NoteThis is the first mile, not the trade. Funding moves collateral between the wallet and the safe. It opens no agreement and posts no margin to a trade. That is Trade: Get Started (~5 min).
How to get test funds
Call POST /api/faucet with the wallet address. The faucet hands over a one-time grant — 100,000 test USDC plus 0.001 ETH of native gas — enabling deposit and trade without first holding gas. The contract enforces one claim per address.
Request the grant using the following command:
curl -X POST https://app.crxfx.com/api/faucet \
-H "Content-Type: application/json" \
-d '{ "address": "0xYourWallet" }'The response is similar to the following:
{ "ok": true, "alreadyClaimed": false, "txHash": "0x…" }A repeat claim returns { "ok": true, "alreadyClaimed": true } with no txHash: the grant is not re-sent. The server route signs the register call, leaving no gas spent to claim.
Verify the grant directly. Do not trust the txHash alone — read the balance on-chain. The network is Base Sepolia: call balanceOf(yourWallet) on the test USDC token (expect 100,000) and check the native balance on the explorer (expect 0.001 ETH). The table below shows the network details:
| Network | Base Sepolia: chain ID 84532 |
| RPC | https://sepolia.base.org |
| Explorer | https://sepolia.basescan.org |
| Test USDC token | 0x12B94aC496d2F7058f0ac72a32393CB515af8797 (18 decimals) |
| Faucet contract | 0x3F393534Eb58e6E07042026847F0e202622efEdf |
How to deposit collateral
Approve the settlement token, then call deposit(token, amount). The USDC lands in the safe — the free, multi-token margin, shared across every agreement held. USDC is 18 decimals on this network; amount is in the native token unit. Make the two calls in order:
// 1. Approve the core to pull your USDC.
await usdc.write.approve([CRX, amount]);
// 2. Deposit: credits your safe.
await crx.write.deposit([USDC, amount]);deposit pulls the native amount into the core and credits the safe. Nothing is allocated to a trade yet; the balance is free until the bind posts margin.
Read the balance back with generalBalance(party, token). See Read the Data (~4 min).
How to withdraw free collateral
Take free collateral out the gasless way: sign an EIP-712 WithdrawIntent, then call POST /collateral/withdraw. The relayer verifies the signature, pays the gas, and releases the free balance in the safe to a whitelisted destination. The party signs; it never sends a transaction.
Build the signed intent first; the field order matches the on-chain typehash exactly:
const intent = {
party, // your address
token, // USDC
amount, // native units, as a bigint
recipient, // a WHITELIST_ADMIN-approved route
nonce, // per-party, single-use
deadline, // unix seconds; expires after
};
const signature = await wallet.signTypedData({
domain: { name: "CRX", version: "1", chainId: 84532, verifyingContract: CRX },
types: WITHDRAW_INTENT_TYPES,
primaryType: "WithdrawIntent",
message: intent,
});The request body sends the same fields plus the signature (amounts and nonce as decimal strings):
await fetch(`${RELAYER}/collateral/withdraw`, {
method: "POST",
headers: { "Content-Type": "application/json", "X-CRX-Address": party },
body: JSON.stringify({
party, token,
amount: amount.toString(),
recipient,
nonce: nonce.toString(),
deadline,
signature,
}),
}).then((r) => r.json());
// → { tx_hash: "0x…" }The response returns the tx_hash of the release transaction.
WarningThe recipient must be a whitelisted route. A withdraw releases only to a destination already approved on-chain viaPOST /admin/withdraw-route, an operator-only,OPERATOR_TOKEN-gated action. An un-whitelisted recipient is rejected before any gas is spent.
Warning/collateral/withdrawreturns 500 if the relayer has no gas key. The gasless path needsWITHDRAW_GAS_KEYconfigured to pay the gas. It is environment-gated. On a deployment without that key, withdraw on-chain directly.
The non-gasless alternative is the on-chain withdraw(token, amount), or withdrawSigned(party, token, amount, recipient, nonce, deadline, sig) submitted by any relayer. Both live on the second engine and release from the safe; the caller pays its own gas on withdraw.
This is a withdrawal from the safe to the wallet. It is not deallocation, which moves margin out of an agreement's SCA back into the safe. Deallocation is the two-phase path in Quote: Get Started (~2 min).
What the funded safe provides, and the branch
- Funded safe. Faucet USDC deposited, free and unallocated, shared across every agreement opened later.
- A way back out. Free collateral leaves through a signed
WithdrawIntentto a whitelisted route, or the on-chainwithdraw.
From here, bind a first hedge: Trade: Get Started (~5 min). To quote instead, see Quote: Get Started (~2 min).