FAQ / Troubleshooting | Wagmi (2024)

Collection of frequently asked questions with ideas on how to troubleshoot and resolve them.

Type inference doesn't work

  • Check that you set up TypeScript correctly with "strict": true in your tsconfig.json (TypeScript docs)
  • Check that you const-asserted any ABIs or Typed Data you are using.
  • Restart your language server or IDE, and check for type errors in your code.

My wallet doesn't work

If you run into issues with a specific wallet, try another before opening up an issue. There are many different wallets and it's likely that the issue is with the wallet itself, not Wagmi. For example, if you are using Wallet X and sending a transaction doesn't work, try Wallet Y and see if it works.

BigInt Serialization

Using native BigInt with JSON.stringify will raise a TypeError as BigInt values are not serializable. There are two techniques to mitigate this:

Lossless serialization

Lossless serialization means that BigInt will be converted to a format that can be deserialized later (e.g. 69420n"#bigint.69420"). The trade-off is that these values are not human-readable and are not intended to be displayed to the user.

Lossless serialization can be achieved with wagmi's serialize and deserialize utilities.

tsx

import { serialize, deserialize } from 'wagmi'const serialized = serialize({ value: 69420n })// '{"value":"#bigint.69420"}'const deserialized = deserialize(serialized)// { value: 69420n }

Lossy serialization

Lossy serialization means that the BigInt will be converted to a normal display string (e.g. 69420n'69420'). The trade-off is that you will not be able to deserialize the BigInt with JSON.parse as it can not distinguish between a normal string and a BigInt.

This method can be achieved by modifying JSON.stringify to include a BigInt replacer:

tsx

const replacer = (key, value) => typeof value === 'bigint' ? value.toString() : valueJSON.stringify({ value: 69420n }, replacer)// '{"value":"69420"}'

How do I support the project?

Wagmi is an open source software project and free to use. If you enjoy using Wagmi or would like to support Wagmi development, you can:

If you use Wagmi at work, consider asking your company to sponsor Wagmi. This may not be easy, but business sponsorships typically make a much larger impact on the sustainability of OSS projects than individual donations, so you will help us much more if you succeed.

Is Wagmi production ready?

Yes. Wagmi is very stable and is used in production by thousands of organizations, like Stripe, Shopify, Coinbase, Uniswap, ENS, Optimism.

Is Wagmi strict with semver?

Yes, Wagmi is very strict with semantic versioning and we will never introduce breaking changes to the runtime API in a minor version bump.

For exported types, we try our best to not introduce breaking changes in non-major versions, however, TypeScript doesn't follow semver and often introduces breaking changes in minor releases that can cause Wagmi type issues. See the TypeScript docs for more information.

How can I contribute to Wagmi?

The Wagmi team accepts all sorts of contributions. Check out the Contributing guide to get started. If you are interested in adding a new connector to Wagmi, check out the Creating Connectors guide.

Anything else you want to know?

Please create a new GitHub Discussion thread. You're also free to suggest changes to this or any other page on the site using the "Suggest changes to this page" button at the bottom of the page.

How does Wagmi work?

Until there's a more in-depth write-up about Wagmi internals, here is the gist:

  • Wagmi is essentially a wrapper around Viem and TanStack Query that adds connector and multichain support.
  • Connectors allow Wagmi and Ethereum accounts to communicate with each other.
  • The Wagmi Config manages connections established between Wagmi and Connectors, as well as some global state. Connections come with one or more addresses and a chain ID.
    • If there are connections, the Wagmi Config listens for connection changes and updates the chainId based on the "current" connection. (The Wagmi Config can have many connections established at once, but only one connection can be the "current" connection. Usually this is the connection from the last connector that is connected, but can changed based on event emitted from other connectors or through the useSwitchAccount hook and switchAccount action.)
    • If there are no connections, the Wagmi Config defaults the global state chainId to the first chain it was created with or last established connection.
    • The global chainId can be changed directly using the useSwitchChain hook and switchChain action. This works when there are no connections as well as for most connectors (not all connectors support chain switching).
  • Wagmi uses the global chainId (from the "current" connection or global state) to internally create Viem Client's, which are used by hooks and actions.
  • Hooks are constructed by TanStack Query options helpers, exported by the '@wagmi/core/query' entrypoint, and some additional code to wire up type parameters, hook into React Context, etc.
  • There are three types of hooks: query hooks, mutation hooks, and config hooks. Query hooks, like useCall, generally read blockchain state and mutation hooks, like useSendTransaction, usually change state through sending transactions via the "current" connection. Config hooks are for getting data from and managing the Wagmi Config instance, e.g. useChainId and useSwitchAccount. Query and mutation hooks usually have corresponding Viem actions.
FAQ / Troubleshooting | Wagmi (2024)
Top Articles
How to Handle a Job Offer Lower Than Your Current Salary? | gpac
What's Happening With GameStop Stock?
5 Bijwerkingen van zwemmen in een zwembad met te veel chloor - Bereik uw gezondheidsdoelen met praktische hulpmiddelen voor eten en fitness, deskundige bronnen en een betrokken gemeenschap.
Craigslist Dog Sitter
ds. J.C. van Trigt - Lukas 23:42-43 - Preekaantekeningen
Cvs Devoted Catalog
True Statement About A Crown Dependency Crossword
Florida (FL) Powerball - Winning Numbers & Results
Used Wood Cook Stoves For Sale Craigslist
Nonuclub
Zürich Stadion Letzigrund detailed interactive seating plan with seat & row numbers | Sitzplan Saalplan with Sitzplatz & Reihen Nummerierung
Nebraska Furniture Tables
Classic Lotto Payout Calculator
Stihl Km 131 R Parts Diagram
Viha Email Login
Grayling Purnell Net Worth
Epguides Strange New Worlds
Skip The Games Fairbanks Alaska
Craigslist Pearl Ms
Joan M. Wallace - Baker Swan Funeral Home
Yosemite Sam Hood Ornament
Play It Again Sports Norman Photos
Avatar: The Way Of Water Showtimes Near Maya Pittsburg Cinemas
Craigslist Hunting Land For Lease In Ga
800-695-2780
UCLA Study Abroad | International Education Office
Ticket To Paradise Showtimes Near Cinemark Mall Del Norte
Wonder Film Wiki
Is Henry Dicarlo Leaving Ktla
How do you get noble pursuit?
Askhistorians Book List
Ringcentral Background
Desales Field Hockey Schedule
Moonrise Time Tonight Near Me
Smayperu
new haven free stuff - craigslist
Craigslist Lakeside Az
Skip The Games Grand Rapids Mi
Who Is Responsible for Writing Obituaries After Death? | Pottstown Funeral Home & Crematory
Foxxequeen
Pulaski County Ky Mugshots Busted Newspaper
Pink Runtz Strain, The Ultimate Guide
How Big Is 776 000 Acres On A Map
Bekkenpijn: oorzaken en symptomen van pijn in het bekken
Noga Funeral Home Obituaries
El Patron Menu Bardstown Ky
Goosetown Communications Guilford Ct
Houston Primary Care Byron Ga
Kenmore Coldspot Model 106 Light Bulb Replacement
Noelleleyva Leaks
Vrca File Converter
Latest Posts
Article information

Author: Domingo Moore

Last Updated:

Views: 5964

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.