Skip to main content
This guide walks through submitting a TWAP order to the Tachyon TWAP service. The service is separate from the relayer, it has its own HTTP API and its own ECIES public key.
The TypeScript SDK is WIP. The flow below shows the raw steps you can implement today; the SDK will wrap them.

Prerequisites

  • A wallet on the source chain (any wallet that can sign EIP-191 personal_sign messages)
  • The source asset approved to the TWAP service’s enclave address (see GET /address below)
  • The eciesEncrypt helper and endpoint URLs from endpoints and helpers
Base URL for the TWAP service is https://twap.tachyon.pe (replace ${TWAP_URL} in the snippets below).

1. Fetch the TWAP service’s ECIES public key

This pubkey is distinct from the relayer’s ECIES pubkey. Orders must be encrypted to this key so only the TWAP service (inside the TEE) can decrypt them.

2. Fetch the TEE wallet address (for approval)

The user must approve their source asset to this address so the service can pull funds on order creation.

3. Build the order

Constraints enforced by the service:
  • period ≥ 5 seconds
  • endTime > startTime
  • recipients.length === amounts.length, both > 0
  • amountPerPeriod > 0
  • totalAmountInamountPerPeriod
  • chainIn / chainOut must match the service’s configured chain names

4. Encrypt the order

Serialize to JSON and encrypt with the service’s ECIES pubkey:

5. Sign the matching personal-sign message

Pick any canonical message, the service verifies that the personal-sign recovery matches order.user. A common pattern:

6. Submit

The service:
  1. Verifies the signature recovers to order.user
  2. Decrypts the order
  3. Pulls totalAmountIn in a single on-chain transferFrom from order.user to its TEE wallet
  4. Schedules the first tranche (either immediately if startTime has passed, or at startTime)

7. Poll order status

Each tranche is a BridgeIntent on the source chain bridge contract. Track individual tranche settlement through the relayer’s GET /intent-details/:intentId using each intentId from order.intentIds.

8. Cancel (optional)

No further tranches fire. Tranches already fired continue to their own BridgeIntent settlement; they are not reversed.

Solver reward and expected output

Per tranche, the service:
  • Deducts 5% of amountPerPeriod as the solver reward (included as reward on the BridgeIntent)
  • Sets expectedAmountB on the BridgeIntent to the sum of order.amounts[] (your minimum acceptable output on destination)
  • Sets auction duration to period / 2 (minimum 20 seconds)
These are not currently configurable per-order.

Recipients on destination

Recipients are stored encrypted in the relayer via POST /store-recipients after each createIntent call. The winning solver fetches them via GET /get-recipients/:intentId (which only returns the decrypted list to the auction winner) and delivers to those addresses on the destination chain.

Open the hosted TWAP app

Walk through this flow without writing code.