I'm building a dApp using Viem and experiencing issues specifically with Safe Wallet (formerly Gnosis Safe) when trying to interact with smart contracts via WalletConnect. The same code works perfectly with MetaMask.
When attempting to execute a contract function, I receive the following error:
ContractFunctionExecutionError: The requested method and/or account has not been authorized by the user.
Here's my code:
const { request, result } = await client.simulateContract({
account: account.address,
address: "0x...",
abi: abiObject,
functionName: "approve",
args: [
"0x...",
10000000,
],
});
I'm using:
Viem (latest version)
WalletConnect v2
Safe Wallet (latest version)
Connection to the wallet is successful btw.
Any help would be appreciated in understanding why this specific error occurs with Safe Wallet and how to resolve it.