Skip to main content
These four endpoints cover the full active lifecycle of an intent: getting a route, locking it in, executing, and canceling if needed. For authentication and base URL, see the API overview.

QuoteIntent

Get a route and fee estimate for a payment. The quote is valid for 5 minutes. Endpoint: POST /QuoteIntent

Request parameters

FieldTypeRequiredDescription
ownerAddressstringYesThe customer’s wallet address
originChainIdnumberYesChain ID of the source network
originTokenAddressstringYesToken contract address on the source network
destinationChainIdnumberYesChain ID of the destination network
destinationTokenAddressstringYesToken contract address at the destination
tradeType"EXACT_INPUT" | "EXACT_OUTPUT"YesWhether the fixed amount is on the input or output side
originTokenAmountstringIf EXACT_INPUTAmount to send, in the origin token’s smallest unit
destinationTokenAmountstringIf EXACT_OUTPUTAmount to receive, in the destination token’s smallest unit
destinationToAddressstringYesWallet or contract address to receive funds
destinationCalldatastringNoABI-encoded calldata for a destination action (see programmable destinations)
options.slippageTolerancenumberNoMaximum acceptable slippage as a decimal (e.g. 0.005 for 0.5%)

Response fields

FieldDescription
intentThe full intent object, including depositAddress: the address to send funds to
feeOptionsArray of fee payment options; pass your chosen option to ExecuteIntent

Example

import { TrailsApi } from "@0xtrails/api";

const trails = new TrailsApi({
  baseUrl: "https://trails-api.sequence.app/rpc/Trails/",
  accessKey: process.env.TRAILS_ACCESS_KEY,
});

const { intent, feeOptions } = await trails.quoteIntent({
  ownerAddress: "0xCUSTOMER_ADDRESS",
  originChainId: 1,
  originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
  destinationChainId: 137,
  destinationTokenAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", // USDC on Polygon
  destinationToAddress: "0xPRODUCT_WALLET",
  tradeType: "EXACT_INPUT",
  originTokenAmount: "1000000", // 1 USDC (6 decimals)
  options: {
    slippageTolerance: 0.005,
  },
});

console.log("Send funds to:", intent.depositAddress);
console.log("Available fee options:", feeOptions);

CommitIntent

Lock in a quoted intent. After committing, the route and fees are fixed. The intent must be executed within 10 minutes or it expires. Endpoint: POST /CommitIntent

Request parameters

FieldTypeRequiredDescription
intentobjectYesThe full intent object returned by QuoteIntent

Response fields

FieldDescription
intentIdUnique identifier for the committed intent; use this in all subsequent calls

Example

const { intentId } = await trails.commitIntent({ intent });

console.log("Intent committed:", intentId);

ExecuteIntent

Initiate execution of a committed intent. Two execution methods are available. Endpoint: POST /ExecuteIntent

Method A: Transfer

Send funds to intent.depositAddress from your wallet or on-ramp, then submit the source transaction hash.
FieldTypeRequiredDescription
intentIdstringYesThe intent ID from CommitIntent
depositTransactionHashstringYesTransaction hash of the transfer to depositAddress
// After sending funds to intent.depositAddress onchain:
await trails.executeIntent({
  intentId,
  depositTransactionHash: "0xSOURCE_TX_HASH",
});

Method B: Permit (gasless, ERC-2612)

For tokens that support ERC-2612 permit signatures, execute without a separate approval transaction. The customer signs an off-chain permit instead of sending a transaction.
FieldTypeRequiredDescription
intentIdstringYesThe intent ID from CommitIntent
feeOptionobjectYesThe selected fee option from QuoteIntent
permitSignaturestringYesERC-2612 permit signature authorizing the transfer
intentSignaturestringYesCustomer’s signature over the intent
depositSignaturestringYesSignature authorizing the deposit
noncenumberYesNonce used in the permit signature
deadlinenumberYesUnix timestamp deadline used in the permit signature
await trails.executeIntent({
  intentId,
  feeOption: feeOptions[0],
  permitSignature,
  intentSignature,
  depositSignature,
  nonce,
  deadline,
});

AbortIntent

Cancel a QUOTED or COMMITTED intent. Intents that are EXECUTING, SUCCEEDED, or FAILED cannot be aborted. Endpoint: POST /AbortIntent

Request parameters

FieldTypeRequiredDescription
intentIdstringYesThe intent ID to cancel

Example

await trails.abortIntent({ intentId });