[{"_path":"/providers/configuring-chains","_draft":false,"_partial":false,"_empty":false,"title":"Configuring Chains","description":"The configureChains function allows you to configure your chains with providers such as: Alchemy, Infura, or something else. This means you don't need to worry about defining RPC URLs and chain configuration in your connector or provider. This is managed internally by vagmi.","excerpt":{"type":"root","children":[{"type":"element","tag":"h2","props":{"id":"usage"},"children":[{"type":"text","value":"Usage"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"configureChains"}]},{"type":"text","value":" accepts an array of chains and an array of providers. It returns:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"chains"}]},{"type":"text","value":": to pass to your connector(s)"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"provider"}]},{"type":"text","value":": to pass to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createClient"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webSocketProvider"}]},{"type":"text","value":": to optionally pass to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createClient"}]}]}]},{"type":"element","tag":"code","props":{"code":"import { configureChains, createClient, defaultChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\nimport { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\n\nconst { chains, provider } = configureChains(defaultChains, [\n  alchemyProvider({ alchemyId }),\n  publicProvider(),\n]);\n\nconst client = createClient({\n  autoConnect: true,\n  connectors: [new InjectedConnector({ chains })],\n  provider,\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { configureChains, createClient, defaultChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\nimport { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\n\nconst { chains, provider } = configureChains(defaultChains, [\n  alchemyProvider({ alchemyId }),\n  publicProvider(),\n]);\n\nconst client = createClient({\n  autoConnect: true,\n  connectors: [new InjectedConnector({ chains })],\n  provider,\n});\n"}]}]}]},{"type":"element","tag":"alert","props":{"type":"info"},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"🔗 The "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"publicProvider"}]},{"type":"text","value":" ensures that your chains always have an RPC URL to fall back on (in case Alchemy does not support the chain)."}]}]},{"type":"element","tag":"alert","props":{"type":"info"},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"⚠️ If a user has their wallet connected to a chain that is unsupported by your app, the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"provider"}]},{"type":"text","value":" will use the first chain listed in the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"chains"}]},{"type":"text","value":" array."}]}]},{"type":"element","tag":"h3","props":{"id":"multiple-providers"},"children":[{"type":"text","value":"Multiple providers"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"configureChains"}]},{"type":"text","value":" function accepts multiple providers. This is useful if not all your chains support a single provider. For example, you may want to use "},{"type":"element","tag":"a","props":{"href":"https://alchemy.com","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Alchemy"}]},{"type":"text","value":" for Ethereum, and "},{"type":"element","tag":"a","props":{"href":"https://avax.network","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"avax.network"}]},{"type":"text","value":" for Avalanche."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"configureChains"}]},{"type":"text","value":" wraps the providers that you provide into an "},{"type":"element","tag":"a","props":{"href":"https://docs.ethers.io/v5/api/providers/other/#FallbackProvider","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ethers.js "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"FallbackProvider"}]}]},{"type":"text","value":", that comes with support for:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Falling back to another provider if a provider goes down (e.g. If Infura goes down, we can fall back to Alchemy)"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Ensuring the responses are legitimate by setting a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"targetQuorum"}]},{"type":"text","value":"."}]}]},{"type":"element","tag":"code","props":{"code":"import type { Chain } from 'vagmi';\nimport { configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst avalancheChain: Chain = {\n  id: 43_114,\n  name: 'Avalanche',\n  network: 'avalanche',\n  nativeCurrency: {\n    decimals: 18,\n    name: 'Avalanche',\n    symbol: 'AVAX',\n  },\n  rpcUrls: {\n    default: 'https://api.avax.network/ext/bc/C/rpc',\n  },\n  blockExplorers: {\n    default: { name: 'SnowTrace', url: 'https://snowtrace.io' },\n  },\n  testnet: false,\n};\n\nconst { provider, chains } = configureChains(\n  [chain.mainnet, avalancheChain],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    jsonRpcProvider({\n      rpc: (chain) => {\n        if (chain.id !== avalancheChain.id)\n          return null;\n        return { http: chain.rpcUrls.default };\n      },\n    }),\n  ],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import type { Chain } from 'vagmi';\nimport { configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst avalancheChain: Chain = {\n  id: 43_114,\n  name: 'Avalanche',\n  network: 'avalanche',\n  nativeCurrency: {\n    decimals: 18,\n    name: 'Avalanche',\n    symbol: 'AVAX',\n  },\n  rpcUrls: {\n    default: 'https://api.avax.network/ext/bc/C/rpc',\n  },\n  blockExplorers: {\n    default: { name: 'SnowTrace', url: 'https://snowtrace.io' },\n  },\n  testnet: false,\n};\n\nconst { provider, chains } = configureChains(\n  [chain.mainnet, avalancheChain],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    jsonRpcProvider({\n      rpc: (chain) => {\n        if (chain.id !== avalancheChain.id)\n          return null;\n        return { http: chain.rpcUrls.default };\n      },\n    }),\n  ],\n);\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"quorum"},"children":[{"type":"text","value":"Quorum"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"targetQuorum"}]},{"type":"text","value":" option is set to a value greater than "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"1"}]},{"type":"text","value":", it will dispatch interactions to multiple providers, in which the responses are verified by comparing them to each other. If the quorum is reached, then the result will be returned to the consumer."}]},{"type":"element","tag":"code","props":{"code":"const { provider, chains } = configureChains(\n  [chain.mainnet, avalancheChain],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    jsonRpcProvider({\n      rpc: (chain) => {\n        if (chain.id !== avalancheChain.id)\n          return null;\n        return { http: chain.rpcUrls.default };\n      },\n    }),\n  ],\n  { targetQuorum: 2 },\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"const { provider, chains } = configureChains(\n  [chain.mainnet, avalancheChain],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    jsonRpcProvider({\n      rpc: (chain) => {\n        if (chain.id !== avalancheChain.id)\n          return null;\n        return { http: chain.rpcUrls.default };\n      },\n    }),\n  ],\n  { targetQuorum: 2 },\n);\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"By default, for a given chain, it will "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"attempt"}]},{"type":"text","value":" to set the quorum value, but if the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"targetQuorum"}]},{"type":"text","value":" value is greater than the number of providers for the chain, it will default to the number of providers."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For instance, in the example provided above "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"targetQuorum = 2"}]},{"type":"text","value":", however there is only 1 available provider for Avalanche ("},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jsonRpcProvider"}]},{"type":"text","value":"), so the quorum will get set to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"1"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To guarantee a static quorum, you can provide a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"minQuorum"}]},{"type":"text","value":" as a config option."}]},{"type":"element","tag":"h2","props":{"id":"arguments"},"children":[{"type":"text","value":"Arguments"}]},{"type":"element","tag":"h3","props":{"id":"chains"},"children":[{"type":"text","value":"chains"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Chains that need to be configured."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [publicProvider()],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [publicProvider()],\n);\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"providers"},"children":[{"type":"text","value":"providers"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The providers the app supports."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If a provider does not support a chain, it will fall back onto the next one in the array. If no RPC URLs are found, "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"configureChains"}]},{"type":"text","value":" will throw an error."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [alchemyProvider({ alchemyId }), publicProvider()],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [alchemyProvider({ alchemyId }), publicProvider()],\n);\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"configuration"},"children":[{"type":"text","value":"Configuration"}]},{"type":"element","tag":"h4","props":{"id":"targetquorum-optional"},"children":[{"type":"text","value":"targetQuorum (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Sets the target quorum. Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"1"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    publicProvider(),\n  ],\n  { targetQuorum: 3 },\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    publicProvider(),\n  ],\n  { targetQuorum: 3 },\n);\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"minquorum-optional"},"children":[{"type":"text","value":"minQuorum (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Sets the minimum quorum that must be accepted by the providers. Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"1"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    publicProvider(),\n  ],\n  { targetQuorum: 3, minQuorum: 2 },\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    publicProvider(),\n  ],\n  { targetQuorum: 3, minQuorum: 2 },\n);\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"stalltimeout-optional"},"children":[{"type":"text","value":"stallTimeout (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The timeout in milliseconds after which another provider will be attempted."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    publicProvider(),\n  ],\n  { stallTimeout: 5000 },\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { alchemyProvider } from 'vagmi/providers/alchemy';\nimport { publicProvider } from 'vagmi/providers/public';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains } = configureChains(\n  [chain.mainnet, chain.optimism],\n  [\n    alchemyProvider({ alchemyId }),\n    infuraProvider({ infuraId }),\n    publicProvider(),\n  ],\n  { stallTimeout: 5000 },\n);\n"}]}]}]}]},"_type":"markdown","_id":"content:3.providers:1.configuring-chains.md","_source":"content","_file":"3.providers/1.configuring-chains.md","_extension":"md"},{"_path":"/providers/infura","_draft":false,"_partial":false,"_empty":false,"title":"Infura","description":"The infuraProvider configures the chains with Infura RPC URLs and also provides an ethers.js InfuraProvider.","excerpt":{"type":"root","children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Visit "},{"type":"element","tag":"a","props":{"href":"https://docs.ethers.io/v5/api/providers/api-providers/#InfuraProvider","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ethers.js "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"InfuraProvider"}]}]},{"type":"text","value":"."}]},{"type":"element","tag":"h2","props":{"id":"usage"},"children":[{"type":"text","value":"Usage"}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [infuraProvider({ infuraId })],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [infuraProvider({ infuraId })],\n);\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"return-value"},"children":[{"type":"text","value":"Return Value"}]},{"type":"element","tag":"code","props":{"code":"{\n  chains: Chain[],\n  provider: InfuraProvider,\n  webSocketProvider: InfuraWebSocketProvider\n}\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"{\n  chains: Chain[],\n  provider: InfuraProvider,\n  webSocketProvider: InfuraWebSocketProvider\n}\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"configuration"},"children":[{"type":"text","value":"Configuration"}]},{"type":"element","tag":"h3","props":{"id":"infuraid-optional"},"children":[{"type":"text","value":"infuraId (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Your Infura ID from the "},{"type":"element","tag":"a","props":{"href":"https://infura.io/login","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Infura Dashboard"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If no Infura ID is provided, it will use the public Infura ID. It is recommended to provide your own Infura ID to prevent being rate-limited."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [infuraProvider({ infuraId })],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [infuraProvider({ infuraId })],\n);\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"pollinginterval-optional"},"children":[{"type":"text","value":"pollingInterval (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The frequency in milliseconds at which the provider polls."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [infuraProvider({ infuraId, pollingInterval: 5000 })],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [infuraProvider({ infuraId, pollingInterval: 5000 })],\n);\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"priority-optional"},"children":[{"type":"text","value":"priority (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The priority used for the provider. Lower-value priorities are favoured over higher-value priorities. If multiple providers share the same priority, they are chosen at random."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    infuraProvider({ infuraId, priority: 0 }),\n    alchemyProvider({ alchemyId, priority: 1 }),\n  ],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    infuraProvider({ infuraId, priority: 0 }),\n    alchemyProvider({ alchemyId, priority: 1 }),\n  ],\n);\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"stalltimeout-optional"},"children":[{"type":"text","value":"stallTimeout (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The timeout in milliseconds after which another provider will be attempted."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    infuraProvider({ infuraId, stallTimeout: 1000 }),\n    alchemyProvider({ alchemyId, stallTimeout: 1000 }),\n  ],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    infuraProvider({ infuraId, stallTimeout: 1000 }),\n    alchemyProvider({ alchemyId, stallTimeout: 1000 }),\n  ],\n);\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"weight-optional"},"children":[{"type":"text","value":"weight (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The weight a response from this provider provides. This can be used if a given provider is more trusted."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    infuraProvider({ infuraId, weight: 1 }),\n    alchemyProvider({ alchemyId, weight: 2 }),\n  ],\n);\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain, configureChains } from 'vagmi';\nimport { infuraProvider } from 'vagmi/providers/infura';\n\nconst alchemyId = import.meta.env.ALCHEMY_ID;\nconst infuraId = import.meta.env.INFURA_ID;\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    infuraProvider({ infuraId, weight: 1 }),\n    alchemyProvider({ alchemyId, weight: 2 }),\n  ],\n);\n"}]}]}]}]},"_type":"markdown","_id":"content:3.providers:3.infura.md","_source":"content","_file":"3.providers/3.infura.md","_extension":"md"}]