[{"_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"},{"_path":"/providers/jsonrpc","_draft":false,"_partial":false,"_empty":false,"title":"JSON RPC","description":"The jsonRpcProvider configures the chains with the RPC URLs that you specify and also provides an ethers.js StaticJsonRpcProvider.","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/jsonrpc-provider/#StaticJsonRpcProvider","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ethers.js "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"StaticJsonRpcProvider"}]}]},{"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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\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 { chain, configureChains } from 'vagmi';\nimport { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n      }),\n    }),\n  ],\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: JsonRpcProvider,\n  webSocketProvider: WebSocketProvider\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: JsonRpcProvider,\n  webSocketProvider: WebSocketProvider\n}\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"configuration"},"children":[{"type":"text","value":"Configuration"}]},{"type":"element","tag":"h3","props":{"id":"rpc"},"children":[{"type":"text","value":"rpc"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Accepts a function which provides the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"chain"}]},{"type":"text","value":" and expects to receive a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"http"}]},{"type":"text","value":" URL and optionally a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webSocket"}]},{"type":"text","value":" URL."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\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 { chain, configureChains } from 'vagmi';\nimport { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n    }),\n  ],\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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      pollingInterval: 5000,\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\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 { chain, configureChains } from 'vagmi';\nimport { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      pollingInterval: 5000,\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n    }),\n  ],\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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      priority: 0,\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n    }),\n    alchemyProvider({ 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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      priority: 0,\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n    }),\n    alchemyProvider({ 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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n      stallTimeout: 1000,\n    }),\n    alchemyProvider({ priority: 1, 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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n      stallTimeout: 1000,\n    }),\n    alchemyProvider({ priority: 1, stallTimeout: 1000 }),\n  ],\n);\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"static-optional"},"children":[{"type":"text","value":"static (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Flag to indicate if the provider should return a "},{"type":"element","tag":"a","props":{"href":"https://docs.ethers.io/v5/api/providers/jsonrpc-provider/#StaticJsonRpcProvider","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"StaticJsonRpcProvider"}]}]},{"type":"text","value":" or "},{"type":"element","tag":"a","props":{"href":"https://docs.ethers.io/v5/api/providers/jsonrpc-provider/#JsonRpcProvider","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JsonRpcProvider"}]}]},{"type":"text","value":". Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"true"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { chain, configureChains } from 'vagmi';\nimport { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n      static: false,\n    }),\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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n      static: false,\n    }),\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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n      weight: 1,\n    }),\n    alchemyProvider({ priority: 1, 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 { jsonRpcProvider } from 'vagmi/providers/jsonRpc';\n\nconst { chains, provider } = configureChains(\n  [chain.mainnet, chain.polygon],\n  [\n    jsonRpcProvider({\n      rpc: chain => ({\n        http: `https://${chain.id}.example.com`,\n        webSocket: `wss://${chain.id}.example.com`,\n      }),\n      weight: 1,\n    }),\n    alchemyProvider({ priority: 1, weight: 2 }),\n  ],\n);\n"}]}]}]}]},"_type":"markdown","_id":"content:3.providers:5.jsonRpc.md","_source":"content","_file":"3.providers/5.jsonRpc.md","_extension":"md"}]