Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.train.tech/llms.txt

Use this file to discover all available pages before exploring further.

1

Derive secret and hashlock

Using the recoverable secret generation mechanism, derive a secret from the user’s wallet signature, source chain, destination chain, and timelock parameters. Hash the secret to create the hashlock.
2

Lock funds on source chain

Call the lock() function to lock funds with the derived hashlock and a timelock of T+ΔT + \Delta.
3

Monitor the destination chain

  • Watch for the TokenLocked event or use the Id on the destination chain by calling getDetails().
  • Verify that the hashlock of the HTLC on the destination chain matches your derived hashlock and provides sufficient time, ensuring it is at least T+2ΔT + 2\Delta.
The state of the destination chain should be read from a Light Client if one exists; if not, it should be read from multiple RPC providers.
4

Transmit signature with secret to Solver

Sign a message containing the derived secret and transmit this signed message to the Solver or any available actor. This allows them to use the secret to unlock funds on both chains without requiring further user interaction.
This signature transmission can happen via off-chain channels (WebSocket, API, etc.). The signature includes the actual secret, which the Solver can now use.
5

Solver uses secret to release funds

The Solver reveals the secret on the destination chain to unlock the user’s funds and on the source chain to claim their own funds. Both the user and Solver can now complete their side of the transaction.
Edge Case: Solver Fails to Act on the User’s Commitment/Intent
  • Wait for the timelock to expire.
  • Call refund() on the source chain to reclaim your funds.
Edge Case: Solver Fails to Release Any Funds
  • Wait for the timelock to expire.
  • Call refund() on the source chain to reclaim your funds.
Edge Case: Solver Fails to Release the User’s Funds
  • If funds are not released on the destination chain, watch the source chain for the TokenRedeemed event (or getDetails() function).
  • Once detected, capture the secret and call redeem() on the destination chain.