-
One of the options is:
But I couldn't find any mention about |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
You probably want |
Beta Was this translation helpful? Give feedback.
-
Cant get it to work. i try pass wagmi wallet connected provider to uniswap swap widget. UNISWAP I get this error: Cannot read properties of undefined (reading 'options') |
Beta Was this translation helpful? Give feedback.
-
Hello @mqklin, I am probably late to the party, but I also struggled with this, so I'll share, might help others ! I think the current answer to your question should be this: import { useConnectorClient } from 'wagmi';
const { data: client } = useConnectorClient();
// you can use it like this:
const getBalance = async () => {
if (!client) {
throw new Error('Client is not initialized');
}
try {
const balance = await client.request({
method: 'eth_getBalance',
params: ['0x...', 'latest'],
});
return balance;
} catch(err) {
// handle error
console.error("Error occurred while fetching balance", err);
}
} In this case, you get direct access to your current connector's provider (e.g., MetaMask). However, if you wish, you can also specify a specific connector as an argument to useConnectorClient. |
Beta Was this translation helpful? Give feedback.
You probably want
connector.getProvider
since it's universal across all connectors.