Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion references/sdk/actions/getQuote.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ description: Get a quote for a crosschain relay (bridge, swap, call, etc)
| Property | Description | Required |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
| **parameters** | Quote parameters defined below | ✅ |
| **includeDefaultParameters** | Setting this to true will include default parameters, which include user and recipient. These parameters are based on the wallet and fallback to the dead address if the wallet is missing. | ✅ |
| **includeDefaultParameters** | Setting this to true will include default parameters, which include user and recipient. These parameters are based on the wallet and fallback to the dead address if the wallet is missing. | ❌ |
| **headers** | Custom headers to pass along with the quote request, such as `x-api-key` for authentication. | ❌ |

<Warning>
**Warning**: Never pass `x-api-key` in headers from client-side code. Only use the `headers` parameter with API keys when calling `getQuote` entirely on the server.
</Warning>

### Quote Parameters

Expand Down Expand Up @@ -96,4 +100,23 @@ const quote = await getClient()?.actions.getQuote({
});
```

### Server-Side Example with API Key

```typescript
// Server-side only - pass API key via headers
const quote = await getClient()?.actions.getQuote(
{
chainId: 1,
toChainId: 10,
currency: "0x0000000000000000000000000000000000000000",
toCurrency: "0x0000000000000000000000000000000000000000",
amount: "10000000000000000", // 0.01 ETH
user: "WALLET_ADDRESS",
recipient: "RECIPIENT_ADDRESS",
},
false,
{ "x-api-key": process.env.RELAY_API_KEY }
);
```

**Note** - Quotes are revalidated when being filled, clients should regularly fetch fresh quotes so that users are always submitting up to date quotes. See [Getting a quote](/how-it-works/the-relay-solver#getting-a-quote) for more information on how quotes work.
3 changes: 2 additions & 1 deletion references/sdk/createClient.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ This method is used to create the Relay client globally in your application. The

| Property | Description | Required |
| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| **baseApiUrl** | The base api url to use when making requests, you can use the `MAINNET_RELAY_API` or the `TESTNET_RELAY_API` constants exported by the package. | ✅ |
| **baseApiUrl** | The base API url to use when making requests. You can use the `MAINNET_RELAY_API` or the `TESTNET_RELAY_API` constants exported by the package, or pass in your own proxy API url to protect your API key on the client. | ✅ |
| **apiKey** | A Relay API key to use when making requests. Only pass in this property when the Relay client instance is used exclusively server-side. Otherwise you'll leak your key to the client. | ❌ |
| **chains** | A list of Relay Chains, by default a list of backup chains is configured | ❌ |
| **source** | The source to associate your onchain activity with, should make to a domain | ❌ |
| **logLevel** | The level at which to log, refer to the `LogLevel` enum exported by the package | ❌ |
Expand Down