|
| 1 | +--- |
| 2 | +title: CommitIntent |
| 3 | +openapi: ../trails-api.gen.json post /rpc/Trails/CommitIntent |
| 4 | +--- |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +The `CommitIntent` endpoint commits an intent to the Trails system, reserving the quote and preparing it for execution. This is a required step between getting a quote and executing the transaction. |
| 9 | + |
| 10 | +## Use Cases |
| 11 | + |
| 12 | +- Lock in a quote before execution |
| 13 | +- Reserve liquidity for the transaction |
| 14 | +- Prepare the intent for signing and execution |
| 15 | +- Transition from quoted to committed state |
| 16 | + |
| 17 | +## Request Parameters |
| 18 | + |
| 19 | +### Required Fields |
| 20 | + |
| 21 | +- **intent** (Intent): The complete intent object returned from `QuoteIntent` |
| 22 | + |
| 23 | +## Response |
| 24 | + |
| 25 | +The response includes: |
| 26 | + |
| 27 | +- **intentId** (string): Unique identifier for the committed intent |
| 28 | + |
| 29 | +## Intent Lifecycle |
| 30 | + |
| 31 | +``` |
| 32 | +QuoteIntent → CommitIntent → ExecuteIntent → Receipt |
| 33 | +``` |
| 34 | + |
| 35 | +The `CommitIntent` step is crucial because it: |
| 36 | +1. Reserves the quoted rates |
| 37 | +2. Locks in the gas fee estimates |
| 38 | +3. Validates the intent parameters |
| 39 | +4. Creates a unique intent ID for tracking |
| 40 | + |
| 41 | +## Example |
| 42 | + |
| 43 | +```typescript |
| 44 | +// First, get a quote |
| 45 | +const quoteResponse = await fetch('https://api.trails.sequence.app/rpc/Trails/QuoteIntent', { |
| 46 | + method: 'POST', |
| 47 | + headers: { |
| 48 | + 'Content-Type': 'application/json', |
| 49 | + 'X-Access-Key': 'YOUR_ACCESS_KEY' |
| 50 | + }, |
| 51 | + body: JSON.stringify(quoteRequest) |
| 52 | +}); |
| 53 | + |
| 54 | +const { intent, gasFeeOptions } = await quoteResponse.json(); |
| 55 | + |
| 56 | +// Then commit the intent |
| 57 | +const commitResponse = await fetch('https://api.trails.sequence.app/rpc/Trails/CommitIntent', { |
| 58 | + method: 'POST', |
| 59 | + headers: { |
| 60 | + 'Content-Type': 'application/json', |
| 61 | + 'X-Access-Key': 'YOUR_ACCESS_KEY' |
| 62 | + }, |
| 63 | + body: JSON.stringify({ intent }) |
| 64 | +}); |
| 65 | + |
| 66 | +const { intentId } = await commitResponse.json(); |
| 67 | +console.log('Intent committed:', intentId); |
| 68 | +``` |
| 69 | + |
| 70 | +## Important Notes |
| 71 | + |
| 72 | +<Warning> |
| 73 | +Committed intents have an expiration time. Make sure to execute the intent before it expires, or you'll need to get a new quote. |
| 74 | +</Warning> |
| 75 | + |
| 76 | +<Info> |
| 77 | +The intent object from `QuoteIntent` can be modified before committing if you need to adjust parameters, but be aware that this may invalidate the quote. |
| 78 | +</Info> |
| 79 | + |
| 80 | +## Next Steps |
| 81 | + |
| 82 | +After committing an intent: |
| 83 | +1. Prepare the transaction signature using the provided intent details |
| 84 | +2. Execute the transaction with `ExecuteIntent` |
| 85 | +3. Monitor the transaction status with `GetIntentReceipt` |
| 86 | + |
0 commit comments