Skip to content
CertadocsGet a sandbox key

Quickstart

In about ten minutes: a customer, test funds, a guaranteed rate for 3 USDC, a lock, settlement, and the lock.settled event. Everything runs in the sandbox on Arc testnet with test tokens.

1. Get a key

Get a sandbox key, then set two variables:

export CERTA_API_URL=https://sandbox-api.13-140-25-211.sslip.io
export CERTA_API_KEY=sk_test_…

2. Run the whole flow

Each sample does the same steps. The sandbox holds a test wallet for the customer (managed execution), so you sign nothing. Time travel moves the lock to maturity, so you do not wait an hour.

#!/bin/sh
# Quickstart: from a sandbox key to a settled lock, with curl and jq.
# Run: CERTA_API_URL=https://… CERTA_API_KEY=sk_test_… sh quickstart.sh
set -eu
API="$CERTA_API_URL"
KEY="$CERTA_API_KEY"

post() { # post PATH JSON
  curl -sS --fail-with-body -X POST "$API$1" \
    -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
    -H "Idempotency-Key: $(uuidgen)" -d "$2"
}
get() { curl -sS --fail-with-body "$API$1" -H "Authorization: Bearer $KEY"; }
wait_until() { # wait_until PATH JQ_TEST
  i=0
  until [ "$(get "$1" | jq -r "$2")" = true ]; do
    i=$((i + 1)); [ "$i" -lt 60 ] || { echo "timed out on $1" >&2; exit 1; }; sleep 2
  done
}

# 1. A customer, with a test wallet Certa holds for them (sandbox only).
CUSTOMER=$(post /v1/customers '{"name":"Acme GmbH","country":"DE","managedWallet":true}' | jq -r .id)
post "/v1/customers/$CUSTOMER/kyb" '{"company":"Acme GmbH","country":"DE"}' >/dev/null
wait_until "/v1/customers/$CUSTOMER" '.kybStatus == "approved"'

# 2. Test USDC for the wallet, once a day. The grant depends on the deployment:
#    5 USDC in the hosted sandbox.
post /v1/sandbox/faucet "{\"customerId\":\"$CUSTOMER\"}" >/dev/null

# 3. A quote: sell 3 USDC for EURC in one hour, at a guaranteed rate.
QUOTE=$(post /v1/quotes "{\"pair\":\"USDC/EURC\",\"side\":\"sell_base\",\"usdcNotional\":\"3000000\",\"tenorSeconds\":3600,\"customerId\":\"$CUSTOMER\"}")
echo "$QUOTE" | jq '{rate, receiveAmount, fee}'

# 4. Lock it. "managed" signs with the customer's sandbox wallet.
LOCK=$(post /v1/locks "{\"quoteId\":\"$(echo "$QUOTE" | jq -r .id)\",\"execution\":\"managed\"}" | jq -r .id)
wait_until "/v1/locks/$LOCK" '.status == "active"'

# 5. Skip the hour: time travel to maturity, then settle.
post "/v1/sandbox/locks/$LOCK/advance" '{"to":"maturity"}' >/dev/null
post "/v1/locks/$LOCK/settle" '{"execution":"managed"}' >/dev/null

# 6. Listen for lock.settled (here by polling events; see "Handle webhooks safely").
wait_until "/v1/events?type=lock.settled&limit=100" "[.data[].data.id] | index(\"$LOCK\") != null"
echo "Settled: lock $LOCK"

Install

The faucet funds each organisation once per 24 hours. A second run with the same key stops at the faucet with 429 RATE_LIMITED: get a new sandbox key, or change the sample to reuse the customer the first run funded.

What happened

  1. The customer passed sandbox KYB, which approves in about 5 seconds.
  2. The faucet sent test USDC to the customer's wallet (5 USDC in the hosted sandbox).
  3. The quote fixed the EURC the customer will receive. It is firm for 30 seconds; the lock made from it holds that amount until maturity.
  4. Creating the lock took a 5% deposit and the fee. With managed execution the lock is active as soon as its transaction is confirmed on Arc (its confirmedAt, a second or two); time travel and settle may take a few seconds more while the sandbox indexes it.
  5. Settlement took the 3 USDC, paid the EURC, and returned the deposit. If the sandbox's Settlement is ever short of EURC, the lock still settles and the EURC is owed to the wallet: the sandbox claims it for Certa-held wallets within a few minutes, and your own wallet claims it with Settlement.claim(token).
  6. The sample waited for lock.settled by polling GET /v1/events. In production you receive it by webhook: see Handle webhooks safely.

Next