Skip to content

What to use instaed of useSigner in the version "wagmi": "^2.8.3", #4297

Answered by Lakszy
Lakszy asked this question in Q&A
Discussion options

You must be logged in to vote

Check out the docs https://wagmi.sh/react/guides/ethers

Thanks
But please could be more specific

import { providers } from 'ethers'
import { useMemo } from 'react'
import type { Account, Chain, Client, Transport } from 'viem'
import { Config, useConnectorClient } from 'wagmi'

export function clientToSigner(client: Client<Transport, Chain, Account>) {
const { account, chain, transport } = client
const network = {
chainId: chain.id,
name: chain.name,
ensAddress: chain.contracts?.ensRegistry?.address,
}
const provider = new providers.Web3Provider(transport, network)
const signer = provider.getSigner(account.address)
return signer
}

/** Hook to convert a Viem Client to an ethers.js Signer. */

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@tmm
Comment options

@Lakszy
Comment options

Answer selected by Lakszy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants