useChain
A hook that returns the current chain as well as a function to set the chain.
Note: when calling setChain
the chain that’s passed in must be defined in
your initial createConfig
call. Calling setChain
causes the chain to change across the board. For example, if you use set chain then use useSmartAccountClient
, the client will flip to the loading state and address for the account on the changed chain.
For switching chains, you can also use createBundlerClient or createSmartAccoutClient directly and create a different client for each chain. You would have to manage different clients, but you wouldn’t have to wait for any hooks to complete and can run these queries in parallel. This way the chain set in the config that the smart account client and other hooks inherit is not also affected.
Import
Usage
Parameters
mutationArgs
UseChainParams
optional properties which contain mutation arg overrides. ref
Returns
UseChainResult
an object containing the current chain and a function to set the chain as well as loading state of setting the chain. ref