ilemi
@ilemi
just found that "const { data: walletClient } = useWalletClient()" doesn't work in the farcaster miniapp (returns null even when the wallet is connected), is there some alternative way of accessing the wallet client? need it for signTypedData() in a miniapp you can see the code here: https://v0.dev/chat/farcaster-miniapp-SqtIJ6eQFzO cc @horsefacts.eth @samuellhuber.eth ?
1 reply
0 recast
2 reactions
Samuel ツ
@samuellhuber.eth
intended way is "miniapp-wagmi-connector" https://www.npmjs.com/package/@farcaster/miniapp-wagmi-connector though any injected provider should work and there's an EthereumProvider in https://miniapps.farcaster.xyz/docs/sdk/wallet
1 reply
0 recast
0 reaction
ilemi
@ilemi
already using that in the config, I'm trying to access the walletclient in a handler function now (code is in the v0 link above)
1 reply
0 recast
0 reaction
ilemi
@ilemi
see handlePermitSignature() in the SwapInterface.tsx file
1 reply
0 recast
0 reaction
ilemi
@ilemi
kk the fix requires you to just create your own wallet client, which then can signTypedData ``` export function useFarcasterWalletClient() { const { address } = useAccount(); const [walletClient, setWalletClient] = useState(null); useEffect(() => { if (!address) return; let mounted = true; (async () => { const provider = await sdk.wallet.getEthereumProvider(); const wallet = createWalletClient({ transport: custom(provider), chain: base, account: address as `0x${string}`, }); if (mounted) setWalletClient(wallet); })(); return () => { mounted = false }; }, [address]); return walletClient; } ```
0 reply
0 recast
1 reaction