Automatic Refunds
Trails has an automatic refund mechanism built in to protect your assets in the event of a transaction failure. The protocol handles refunds automatically without requiring user intervention:| Failure Scenario | Refund Action |
|---|---|
| Failure on the Source Chain | If the transaction fails before your funds leave the initial blockchain, the user receives a full refund (minus gas fees) on the source chain to the sender address. |
| Failure on the Destination Chain | If the funds successfully bridged but the final step fails on the destination chain, the assets are refunded to your sender address on the destination chain. |
For more details on how refunds work within the Trails architecture, see the How Trails Works documentation.
User Control & Ownership
Trails is non-custodial by design. Only the user always retains control over their account and funds:- Intent-Scoped Authorization: Intent addresses only authorize the specific transaction calldata the user has explicitly permitted—nothing more
- User Control: Users can take direct action over their funds at any time, even in emergencies
- Non-Custodial: Trails never takes custody; execution happens via the user’s wallet permissions, preserving full control and auditability
The user’s wallet is the only party with control over the intent address. This cryptographic guarantee ensures the funds are always recoverable.
Manual Fund Recovery with useTrailsRefund
While Trails automatically refunds upon transaction failures, there may be edge cases where funds are stuck without an explicit revert. TheuseTrailsRefund hook provides utilities to manually sign and execute refund transactions to recover funds from intent addresses if you’d like to add to your own app.
Basic Usage
When to Use Manual Refunds
Automatic Refunds
Most common scenario — Trails automatically handles refunds when transactions explicitly fail or revert. No user action required.
Manual Recovery
Edge cases only — Use
useTrailsRefund when funds are stuck without an explicit revert, or when you want to proactively recover funds from a pending intent.Security Guarantees
The refund mechanism maintains Trails’ security principles:- Only the original sender can authorize refunds via wallet signature
- Cryptographic verification ensures refund transactions are valid
- Non-custodial — Trails cannot access or move your funds without your signature
- Onchain execution — All refund operations are verifiable onchain
- Hooks Reference — Full documentation for
useTrailsRefund - How Trails Works — Architecture overview including refund mechanisms
- Protocol Architecture — Deep dive into security and trust model