import { createAvalancheClient } from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
// HTTP Transport with custom configuration
const httpClient = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
url: "https://api.avax.network/ext/bc/C/rpc", // Custom RPC URL
config: {
fetchOptions: {
headers: {
"Custom-Header": "value"
},
},
retryCount: 3,
retryDelay: 1000,
timeout: 5000
}
},
apiKey: "your-api-key", // Optional
rlToken: "your-rate-limit-token" // Optional
})
// WebSocket Transport for real-time updates
const wsClient = createAvalancheClient({
chain: avalanche,
transport: {
type: "ws",
url: "wss://api.avax.network/ext/bc/C/ws",
config: {
retryCount: 3,
retryDelay: 1000
}
}
})
// Fallback Transport for high availability
const fallbackClient = createAvalancheClient({
chain: avalanche,
transport: {
type: "fallback",
transports: [
{ type: "http", url: "https://api.avax.network/ext/bc/C/rpc" },
{ type: "http", url: "https://rpc.ankr.com/avalanche" },
{ type: "http", url: "https://avalanche.public-rpc.com" }
],
config: {
retryCount: 5,
retryDelay: 2000
}
}
})