# Testnet bridge API Swap shielded Zcash testnet coins (TAZ) for test dollars (tUSD) on Ethereum Sepolia. The reference CLI runs the wallet locally and shields the payout into that wallet’s Railgun address. The relayer pays the Ethereum gas. ## Connect to testnet The public gateway is `https://zecswap-testnet.pepeman931.workers.dev`. Use `/maker` for quotes and `/relayer` for fees and settlement. Discovery and quotes are public. Keep the wallet seed and swap state on the machine running the CLI. Run the examples in one Bash session. On Linux or macOS, install Git, curl, jq, rustup and a native C/C++ build toolchain. ```bash set -euo pipefail export ZECSWAP_MAKER_URL=https://zecswap-testnet.pepeman931.workers.dev/maker export ZECSWAP_RELAYER_URL=https://zecswap-testnet.pepeman931.workers.dev/relayer export EVM_RPC_URL=https://ethereum-sepolia-rpc.publicnode.com export ZECSWAP_CONTRACT=0x62ce626c5a30528b8ee33145d491785082a6cf8a export ZECSWAP_TOKEN=0x64c4a5cb09fe0b706d4cf24dc0a45fff275d727c info=$(curl -fsS "$ZECSWAP_MAKER_URL/v1/info") terms=$(curl -fsS "$ZECSWAP_RELAYER_URL/v1/terms") jq -e --arg c "$ZECSWAP_CONTRACT" --arg t "$ZECSWAP_TOKEN" ' .apiVersion == 1 and .zcashNetwork == "testnet" and .chainId == 11155111 and .contract == $c and .token == $t ' <<< "$info" jq -e --arg c "$ZECSWAP_CONTRACT" ' .chainId == 11155111 and .contract == $c ' <<< "$terms" ``` Both checks must print `true`. The pinned addresses identify this testnet deployment. Stop on a mismatch and check for a deployment update. [Sepolia swap contract](https://sepolia.etherscan.io/address/0x62ce626c5a30528b8ee33145d491785082a6cf8a) · [Sepolia tUSD token](https://sepolia.etherscan.io/token/0x64c4a5cb09fe0b706d4cf24dc0a45fff275d727c) ## Preview a quote Ask the maker for a price before funding a wallet. This example uses a nonzero placeholder payout address for a disposable quote. Leave that quote to expire. The CLI requests a fresh quote bound to its own payout when you run a swap. ```bash units=1000000 quote=$(curl -fsS -H 'Content-Type: application/json' \ --data "{\"units\":$units,\"payout\":\"0x0000000000000000000000000000000000000001\"}" \ "$ZECSWAP_MAKER_URL/v1/quote") jq '{amount, depositZat, openFeeZat: (.openFee.zat // 0), expiresAt}' <<< "$quote" jq '{fee, feeExpiresAt}' <<< "$terms" ``` | Field | How to read it | | --- | --- | | `units` | Number of maker denominations. Read the resulting token amount from the quote. | | `amount` | Gross tUSD payout as a decimal string in base units. 1,000,000 base units = 1 tUSD. | | `depositZat` | Shielded TAZ required for the swap. 100,000,000 zatoshis = 1 TAZ. | | `openFee.zat` | Optional, nonrefundable TAZ fee paid to the maker before opening. Budget it separately from the deposit and Zcash transaction fees. | | `fee` | Relayer fee in token base units, deducted from the payout. It must be below the gross amount. | | `expiresAt`, `feeExpiresAt` | Unix times in seconds. Refresh the quote or terms after expiry. | ## Fund a test wallet Build the public CLI from the revision used by this guide. `init` creates the wallet and prints its Zcash testnet address. Run it once per wallet. ```bash git clone https://github.com/ChinmayGopal931/zecSwap.git cd zecSwap git checkout --detach 2470b7cf535185e837bfe5af5e641ea2c964a23f cargo build --locked -p zecswap-cli cli="$PWD/target/debug/zecswap-cli" umask 077 export ZECSWAP_CLI_DIR="$HOME/.veylor/bridge-testnet" "$cli" --network testnet init ``` Send TAZ to the printed address from another test wallet or a testnet faucet. Wait for the spendable balance to cover the quoted deposit, the open fee, and Zcash transaction fees. [Valar testnet faucet](https://faucet.testnet.valargroup.dev/) ```bash "$cli" --network testnet status ``` ## Run a shielded swap Use the same wallet directory for the whole swap. The example caps the open fee at 20,000 zatoshis and the relayer fee at 100,000 token base units (0.1 tUSD). Check the fresh terms against your budget before starting. The CLI quotes again and can pay the open fee as soon as it starts. ```bash terms=$(curl -fsS "$ZECSWAP_RELAYER_URL/v1/terms") jq -e --argjson amount "$(jq -r .amount <<< "$quote")" ' (.fee | tonumber) as $fee | $fee <= 100000 and $fee < $amount and .feeExpiresAt > now ' <<< "$terms" "$cli" --network testnet swap --units "$units" \ --relayer "$ZECSWAP_RELAYER_URL" \ --max-open-fee 20000 --max-fee 100000 ``` The CLI builds the acceptance proof, checks the opened swap on Sepolia, funds the joint Zcash address, and follows the claim or refund. A successful payout prints `claimed; shielded … into …` with the net token amount and the destination. A cancellation or refund has its own output. A successful process exit alone does not identify which outcome occurred. Run one swap at a time per wallet directory. If interrupted, restore the same settings and rerun the swap command with the same directory to resume an **unfinished** swap. Running it again after completion starts another swap. Preserve the seed, wallet database, and swap state together. ## Forward API reference Append the paths below to the public gateway. POST requests use JSON. For a custom wallet, use the public Rust client to construct proofs, check the contract and determine when to reveal the user share. | Method and path | Purpose | | --- | --- | | `GET /maker/v1/info` | Read the Zcash network, chain ID, swap contract and token. | | `GET /relayer/v1/terms` | Read the relayer address, fee and expiry for this deployment. | | `POST /maker/v1/quote` | Send `units` and a nonzero Ethereum `payout`. A shielded payout also binds the wallet-generated `payoutNote`. | | `POST /maker/v1/quote/{quoteId}/accept` | Send the wallet’s `userShare`, `userProof` and `viewingKeys`. Save the returned `swapId`, deadlines and `ticket` before depositing. | | `POST /relayer/v1/claim` | Submit the claim prepared by the client when the contract permits it. Send the accepted swap’s `ZecSwap-Ticket` header. | | `POST /relayer/v1/payout` | Submit the client’s signed payout and shield data for a claimed swap, with the same ticket. | On `402 feeRequired` after broadcasting the open fee, wait for the existing payment to be mined and retry the same acceptance after `Retry-After`. On `503`, respect `Retry-After` when supplied. Keep the original state across retries so a timeout cannot trigger a second payment. [Request and response types](https://github.com/ChinmayGopal931/zecSwap/tree/2470b7cf535185e837bfe5af5e641ea2c964a23f/crates/zecswap-api/src) · [Wallet client](https://github.com/ChinmayGopal931/zecSwap/tree/2470b7cf535185e837bfe5af5e641ea2c964a23f/crates/zecswap-client) · [Open fee protocol](https://github.com/ChinmayGopal931/zecSwap/blob/2470b7cf535185e837bfe5af5e641ea2c964a23f/docs/open-fee.md)