Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Providers

Icon LinkProviders

An instance of the Provider class lets you connect to a Fuel node. It provides read-only access to the blockchain state. You can use this provider as-is or through a Wallet instance.

const provider = await Provider.create(FUEL_NETWORK_URL);
const { consensusParameters } = provider.getChain();

You can also provide options to the Provider:

await Provider.create(FUEL_NETWORK_URL, {
  fetch: async (url: string, requestInit: RequestInit | undefined) => {
    // do something
    await sleep(100);
    return fetch(url, requestInit);
  },
  timeout: 2000,
  cacheUtxo: 1500,
  requestMiddleware: async (request: RequestInit) => {
    const credentials = await fetchSomeExternalCredentials();
    request.headers ??= {};
    (request.headers as Record<string, string>).Authorization = credentials;
 
    return request;
  },
  retryOptions: {
    maxRetries: 5,
    baseDelay: 100,
    backoff: 'exponential',
  },
});