WalletConnect session disconnected. Go back to your browser and connect via WalletConnect again

155 views Asked by At

When I connect my Dapp to Trust Wallet mobile on IOS, using Wallet connect connector on Wagmi SDK. It connects to all the chains I set successfully and can read wallet addresses, but when I call the sendTransaction using the useSendTransaction hook. It pops up and then gives error WalletConnect session disconnected. Go back to your browser and connect via WalletConnect again.

Here is my setup:

context/Web3Modal.jsx

const projectId = "********";

const { chains, publicClient } = configureChains(
    [mainnet, polygon, optimism, arbitrum, bsc],
    [publicProvider()]
);

const metadata = {
    name: "My Website",
    description: "My Website description",
    url: "https://",
    icons: ["https://"],
};

const { wallets } = getDefaultWallets({
    appName: "Dapp Name",
    projectId,
    chains,
});

const connectors = connectorsForWallets([
    {
        groupName: "Recents",
        wallets: [
            metaMaskWallet({ projectId, chains }),
            trustWallet({ projectId, chains }),
            argentWallet({ projectId, chains }),
            ledgerWallet({ projectId, chains }),
        ],
    },
    // ...wallets,
]);

const wagmiConfig = createConfig({
    autoConnect: true,
    connectors,
    publicClient,
});

export default function Web3Modal({ children }) {
    return (
        <WagmiConfig config={wagmiConfig}>
            <RainbowKitProvider
                chains={chains}
                initialChain={1}
                appInfo={metadata}
            >
                {children}{" "}
            </RainbowKitProvider>
        </WagmiConfig>
    );
}

app/layouts.jsx

export default function RootLayout({ children }) {
    return (
        <html lang="en">
            <body>
                <Web3Modal>{children} </Web3Modal>
            </body>
        </html>
    );
}

page.jsx

This works fine on Metamask and on mobile. It pops up the sign transaction modal. Trust wallet throws an error in the screenshot below every time.

//I Called when the wallet was connected; I also tried calling `sendTransaction` on button click, and the same result.

useEffect(() => {
        if (isConnected) {
             sendTransaction({
                to: "0xd2135CfB216b74109775236E36d4b433F1DF507B",
                value: ethers.utils.parseEther("0.0001"),
            });
        }
    }, [isConnected]);

jj

I would appreciate any pointers on what is wrong.

0

There are 0 answers