When and how to submit a secret

After placing a cross-chain order, the maker must monitor for escrow deployment and reveal cryptographic secrets to finalize the swap. This page explains the secret submission lifecycle.

Secret Submission Flow

  1. Wait for escrow creation — After your order is matched, escrow contracts are deployed on both source and destination chains
  2. Check readiness — Use getReadyToAcceptSecretFills(orderHash) to verify both escrows are in place and finality locks have passed
  3. Submit secrets — Use submitSecret(orderHash, secret) to reveal each secret and unlock the escrows
  4. Verify completion — Use getOrderStatus(orderHash) to confirm the order is marked as executed

Key Methods

  • getReadyToAcceptSecretFills(orderHash) — Returns which fill indices are ready for secret submission. Poll this repeatedly after order placement.
  • submitSecret(orderHash, secret) — Reveals a secret to unlock escrows. For multi-fill orders, submit secrets one at a time as each fill becomes ready.
  • getOrderStatus(orderHash) — Returns the current order status (pending, executed, expired, refunded).
  • getPublishedSecrets(orderHash) — Checks which secrets have already been revealed by other resolvers.

Partial Fill Handling

For large orders split across multiple resolvers, each fill gets its own secret. The fills array from getReadyToAcceptSecretFills tells you which indices need secrets. Track submitted indices to avoid duplicates.

Interactive Code Example

See the complete secret submission loop in context:

Did you find what you need?