Skip to content

Commit bfe222b

Browse files
cleanup (#48)
* cleanup * updated additional API ref docs and trailsContracts * updated dashboard link * remove trailsContracts references --------- Co-authored-by: James Lawton <[email protected]>
1 parent ca10b4d commit bfe222b

File tree

10 files changed

+5824
-4001
lines changed

10 files changed

+5824
-4001
lines changed

api-reference/endpoints/execute-intent.mdx

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,17 @@ First, deposit tokens to the intent address, then call ExecuteIntent with the tr
5454
import { encodeFunctionData } from 'viem';
5555

5656
// Step 1: Send tokens to the intent address
57-
const depositTx = await walletClient.sendTransaction({
58-
to: intent.depositTransaction.toAddress, // Intent address from quote
59-
value: 0n, // 0 for ERC20 tokens, or native ETH amount
60-
data: encodeFunctionData({
61-
abi: [{
62-
name: 'transfer',
63-
type: 'function',
64-
stateMutability: 'nonpayable',
65-
inputs: [
66-
{ name: 'to', type: 'address' },
67-
{ name: 'amount', type: 'uint256' }
68-
],
69-
outputs: [{ name: '', type: 'bool' }]
70-
}],
71-
functionName: 'transfer',
72-
args: [
73-
intent.depositTransaction.toAddress as `0x${string}`,
74-
BigInt(intent.depositTransaction.amount)
75-
]
76-
})
57+
const depositTx = await walletClient.sendTransaction({
58+
to: intent.depositTransaction.tokenAddress, // Intent address from quote
59+
value: 0n, // 0 for ERC20 tokens, or native ETH amount
60+
data: encodeFunctionData({
61+
abi: erc20Abi,
62+
functionName: 'transfer',
63+
args: [
64+
intent.depositTransaction.toAddress as `0x${string}`,
65+
BigInt(intent.depositTransaction.amount)
66+
]
67+
})
7768
});
7869

7970
// Step 2: Wait for confirmation
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
title: GetChains
3+
openapi: ../trails-api.gen.json post /rpc/Trails/GetChains
4+
---
5+
6+
## Overview
7+
8+
The `GetChains` endpoint retrieves a list of all blockchain networks supported by Trails. This is useful for building chain selection UIs, validating user inputs, and discovering which networks are available for cross-chain transactions.
9+
10+
## Use Cases
11+
12+
- Build chain selection dropdowns in your UI
13+
- Validate that user-selected chains are supported
14+
- Display chain metadata (name, logo, native token)
15+
- Filter chains by bridging support
16+
- Identify testnet vs mainnet networks
17+
- Get block explorer URLs for transaction links
18+
19+
## Request Parameters
20+
21+
### Optional Fields
22+
23+
- **routeProvider** (string): Filter chains by a specific route provider (e.g., "CCTP", "LIFI", "RELAY")
24+
25+
## Response
26+
27+
The response includes:
28+
29+
- **chains** (ChainInfo[]): Array of supported chain information
30+
31+
### ChainInfo Object Structure
32+
33+
Each chain object contains:
34+
- **id** (number): The chain ID
35+
- **name** (string): Human-readable chain name
36+
- **tokenName** (string): Native token name (e.g., "Ether")
37+
- **tokenSymbol** (string): Native token symbol (e.g., "ETH")
38+
- **tokenDecimals** (number): Native token decimals
39+
- **isTestnet** (boolean): Whether this is a testnet
40+
- **supportsBridging** (boolean): Whether bridging is supported on this chain
41+
- **logoUri** (string, optional): URL to chain logo
42+
- **blockExplorerUrl** (string, optional): Block explorer base URL
43+
44+
## Examples
45+
46+
### Get All Supported Chains
47+
48+
```typescript
49+
const response = await fetch('https://trails-api.sequence.app/rpc/Trails/GetChains', {
50+
method: 'POST',
51+
headers: {
52+
'Content-Type': 'application/json',
53+
'X-Access-Key': 'YOUR_API_KEY'
54+
},
55+
body: JSON.stringify({})
56+
});
57+
58+
const { chains } = await response.json();
59+
60+
console.log('Supported chains:', chains.length);
61+
chains.forEach(chain => {
62+
console.log(`${chain.name} (${chain.id}): ${chain.tokenSymbol}`);
63+
});
64+
```
65+
66+
### Filter by Route Provider
67+
68+
```typescript
69+
const response = await fetch('https://trails-api.sequence.app/rpc/Trails/GetChains', {
70+
method: 'POST',
71+
headers: {
72+
'Content-Type': 'application/json',
73+
'X-Access-Key': 'YOUR_API_KEY'
74+
},
75+
body: JSON.stringify({
76+
routeProvider: 'CCTP' // Get chains supported by Circle's CCTP
77+
})
78+
});
79+
80+
const { chains } = await response.json();
81+
82+
console.log('CCTP-supported chains:', chains.map(c => c.name));
83+
```
84+
85+
### Build Chain Selector UI
86+
87+
```tsx
88+
import { useEffect, useState } from 'react';
89+
90+
interface ChainInfo {
91+
id: number;
92+
name: string;
93+
tokenSymbol: string;
94+
logoUri?: string;
95+
isTestnet: boolean;
96+
supportsBridging: boolean;
97+
}
98+
99+
export const ChainSelector = ({
100+
onSelect,
101+
excludeTestnets = true
102+
}: {
103+
onSelect: (chainId: number) => void;
104+
excludeTestnets?: boolean;
105+
}) => {
106+
const [chains, setChains] = useState<ChainInfo[]>([]);
107+
const [loading, setLoading] = useState(true);
108+
109+
useEffect(() => {
110+
fetch('https://trails-api.sequence.app/rpc/Trails/GetChains', {
111+
method: 'POST',
112+
headers: {
113+
'Content-Type': 'application/json',
114+
'X-Access-Key': 'YOUR_API_KEY'
115+
},
116+
body: JSON.stringify({})
117+
})
118+
.then(res => res.json())
119+
.then(({ chains }) => {
120+
const filtered = excludeTestnets
121+
? chains.filter((c: ChainInfo) => !c.isTestnet)
122+
: chains;
123+
setChains(filtered);
124+
setLoading(false);
125+
});
126+
}, [excludeTestnets]);
127+
128+
if (loading) return <div>Loading chains...</div>;
129+
130+
return (
131+
<select onChange={(e) => onSelect(Number(e.target.value))}>
132+
<option value="">Select a chain</option>
133+
{chains.map(chain => (
134+
<option key={chain.id} value={chain.id}>
135+
{chain.name} ({chain.tokenSymbol})
136+
</option>
137+
))}
138+
</select>
139+
);
140+
};
141+
```
142+
143+
### Get Chains with Bridging Support
144+
145+
```typescript
146+
const response = await fetch('https://trails-api.sequence.app/rpc/Trails/GetChains', {
147+
method: 'POST',
148+
headers: {
149+
'Content-Type': 'application/json',
150+
'X-Access-Key': 'YOUR_API_KEY'
151+
},
152+
body: JSON.stringify({})
153+
});
154+
155+
const { chains } = await response.json();
156+
157+
// Filter to only chains that support bridging
158+
const bridgableChains = chains.filter(chain => chain.supportsBridging);
159+
160+
console.log('Chains with bridging support:');
161+
bridgableChains.forEach(chain => {
162+
console.log(`- ${chain.name} (${chain.id})`);
163+
});
164+
```
165+
166+
## Common Chain IDs
167+
168+
| Chain | Chain ID | Native Token |
169+
|-------|----------|--------------|
170+
| Ethereum | 1 | ETH |
171+
| Polygon | 137 | MATIC |
172+
| Arbitrum One | 42161 | ETH |
173+
| Optimism | 10 | ETH |
174+
| Base | 8453 | ETH |
175+
| Avalanche | 43114 | AVAX |
176+
| BNB Chain | 56 | BNB |
177+
178+
<Info>
179+
Chain support is continuously expanding. Use this endpoint to get the current list rather than hardcoding chain IDs.
180+
</Info>
181+
182+
## Next Steps
183+
184+
<CardGroup cols={2}>
185+
<Card title="GetTokenList" icon="coins" href="/api-reference/endpoints/get-token-list">
186+
Get available tokens for selected chains
187+
</Card>
188+
189+
<Card title="QuoteIntent" icon="dollar-sign" href="/api-reference/endpoints/quote-intent">
190+
Request a quote for cross-chain transactions
191+
</Card>
192+
</CardGroup>
193+

0 commit comments

Comments
 (0)