Skip to main content
This tutorial walks you through the steps to test your StableFX integration as a maker, covering successful trade creation, signature registration, and funding. For failure scenarios, see Magic numbers for testing StableFX.

Prerequisites

Before you begin, ensure that you have:
  • Generated a StableFX API key. See Generate a StableFX API key.
  • Enabled your sandbox account as a registered maker by contacting Circle Support
  • Obtained testnet USDC and EURC in a supported wallet on Arc
  • Installed cURL on your development machine
This guide provides API requests in cURL format, along with example responses. In all examples, replace ${YOUR_API_KEY} with your actual API key and any other placeholder values with the appropriate data for your test.

Part 1: Create a test trade

In sandbox, you create test trades by submitting a taker trade request using your API key. This gives you a trade to sign and fund in the subsequent parts of this tutorial.

1.1. Request a tradable quote

Request a quote for a trade from USDC to EURC using the create a quote endpoint. Set type to tradable to receive an executable quote. Include a recipientAddress for the wallet that receives EURC after the trade settles:
Response The response includes the quote details and a typedData object containing the Permit2 EIP-712 typed data you must sign before creating the trade.

1.2. Sign the typed data

Using a Permit2 compliant, EIP-712 compatible wallet or signing library, sign the typedData object returned in the quote response. Use the domain, types, primaryType, and message fields to construct the EIP-712 signature. After signing, you have a hex-encoded signature string (for example, 0x1234...).

1.3. Create the trade

Submit the quote acceptance using the create a trade endpoint. Provide the quote ID, your wallet address, the message from typedData.message, the signature from the previous step, and a randomly generated idempotency key in UUIDv4 format:
After the trade is submitted and confirmed, it appears in the maker trade list with the confirmed status.

Part 2: Query for trades

After the trade you created in Part 1 is confirmed, query for maker trades with the confirmed status using the get all trades endpoint. The following is an example request:
Response

Part 3: Register your signature

Decide which trades to take from the maker side, and register your signature for those trades.

3.1. Get the typed data for the trade

Using the id field from the response in the previous step, get the typed data for the trade using the generate trade presign data endpoint. Include the required recipientAddress query parameter, which is the address of the recipient of the settlement tokens. The following is an example request:
Response

3.2. Sign the typed data

Using your wallet, sign the typed data returned from the previous step.

3.3. Submit the signed data

Submit the signed data to the submit a trade signature endpoint. The following example submits the signed data from the previous step:

Part 4: Fund the taker side

Because you created the trade in Part 1 using your own API key, you are also the taker. You must fund the taker side of the trade before you can fund the maker side in Part 5.

4.1. Get the taker funding signature data

Call the generate funding presign data endpoint with "type": "taker" and the contractTradeId from the Part 2 response:

4.2. Sign the taker funding data

Using a Permit2 compliant, EIP-712 compatible wallet or signing library, sign the typedData object from the response.

4.3. Submit the taker funding

Submit the signed data to the fund trades endpoint with "type": "taker":
If the signed data is accepted, the API returns a blank 200 response and the trade moves to the taker_funded status.

Part 5: Fund the maker side

Use the following steps to fund the maker side of the trade onchain.

5.1. Get trades that are ready for funding

Before you send funds onchain, you should confirm that the trade is ready for funding. To do this, call the get all trades endpoint. You should filter the response by the taker_funded status.

5.2. Get the funding signature data

To use the StableFX API to deliver the funds onchain, you must first sign the funding typed data with an EIP-712 signature. To get the data to sign, call the generate funding presign data endpoint. Your request must include the contract ID of the trade and the side of the trade that you are taking ("type": "maker"). The following is an example request:
Response

5.3. Fund the trade with the StableFX API

The StableFX API can handle the onchain transaction for you through the fund trades endpoint. You must submit the maker-specific funding data along with your signature.
If the signed data is accepted, the API returns a blank 200 response.
It’s not required to submit the funding transaction through the StableFX API. You can submit the transaction onchain using your own web3 provider or wallet by calling the appropriate maker contract methods directly.

Testing trade batches

Note that the query for trades endpoint returns multiple trades. This can be useful for testing a batch integration. If you are testing batching, you need to get the contractTradeId for each trade that you’d like to fund. You should complete part 3 for each trade that you’d like to fund. Once you have the array of IDs, and your signature is submitted for each trade, you can use the same fund trades endpoint to fund multiple trades by submitting the permit2 data for each trade along with the appropriate signatures.