wayfinder.resolveUrl()
Resolve ar:// URLs to dynamic gateway URLs using the configured routing strategy.
Parameters
originalUrl
(string
): The ar:// URL to resolve to a full gateway URLlogger
(Logger
, optional): Custom logger for this operation. Defaults to wayfinder's logger
Returns
Type: Promise<URL>
Returns a fully-qualified URL object that points to the selected gateway.
Examples
Legacy URLs
import { Wayfinder, NetworkGatewaysProvider } from '@ar.io/wayfinder-core'
import { ARIO } from '@ar.io/sdk'
const wayfinder = new Wayfinder({
gatewaysProvider: new NetworkGatewaysProvider({
ario: ARIO.mainnet(),
}),
})
// An existing arweave.net URL
const url = await wayfinder.resolveUrl({
originalUrl: 'https://arweave.net/<some-tx-id>',
})
console.log('Resolved URL:', url.toString())
// Output: https://<some-other-gateway>/ABC123...XYZ
Transaction IDs
// Transaction IDs are resolved to sandboxed subdomains
const txUrl = await wayfinder.resolveUrl({
txId: 'YTB0dGJURWpqQ25iS2NaY1RPSi1TOUQxMmd3cGRFaHUzV2hiWnVlZ2o5WT0',
})
console.log('Transaction URL:', txUrl.toString())
// Output: https://ytb0dgjuqwpqq25iy2naytpsi1tpuqxnz3dqrfaohuzwhiwnu5j9y.<some-gateway>
ArNS Names
// ArNS names resolve to subdomain format
const arnsUrl = await wayfinder.resolveUrl({
arnsName: 'ardrive',
})
console.log('ArNS URL:', arnsUrl.toString())
// Output: https://ardrive.<some-gateway>
Gateway Endpoints
// Gateway info endpoint
const infoUrl = await wayfinder.resolveUrl({
originalUrl: 'ar:///info',
})
console.log('Info URL:', infoUrl.toString())
// Output: https://<some-gateway>/info
Comparison with request()
Method | Network Request | Verification | Use Case |
---|---|---|---|
resolveUrl() | ✅ Yes | ❌ No | Get a dynamic URL for transaction id, ArNS name or gateway endpoint |
request() | ✅ Yes | ✅ Optional | Fetch and optionally verify data from an AR.IO gateway |
Related
- request(): Fetching data via Wayfinder
- Gateway Providers: Understand gateway discovery options
- Routing Strategies: Explore different routing algorithms
- Verification Strategies: Learn about data integrity verification
- Telemetry: Set up monitoring and observability