You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a dApp on Base Mainnet (chain ID 8453) using Wagmi and viem, and I'm encountering an issue with walletClient.signTransaction. My goal is to sign a transaction locally using the user's wallet and then send the signed transaction using publicClient.sendRawTransaction (which uses eth_sendRawTransaction) to route the transaction through an endpoint. However, walletClient.signTransaction consistently fails with an InvalidInputRpcError: Missing or invalid parameters. Details: unknown account error, even though the wallet supports eth_sendTransaction (as evidenced by walletClient.sendTransaction working fine).
I suspect the issue is related to the wallet connector (WalletConnect) not supporting eth_signTransaction, but I'm looking for guidance on how to resolve this while still meeting my requirement of using eth_sendRawTransaction via the publicClient.
// 1. Prepare transaction requestconstpreparedRequest=awaitwalletClient.prepareTransactionRequest({to: request.to,data: request.dataas `0x${string}`,value: request.value,account: address,gasPrice: request.gasPrice,});console.log("preparedRequest",preparedRequest);lettransactionHash: `0x${string}`;// 2. Try to sign the transaction with the wallettry{constsignature=awaitwalletClient.signTransaction(preparedRequest);console.log("signature",signature);// 3. Send the signed transaction using the public client (uses eth_sendRawTransaction)transactionHash=awaitpublicClient.sendRawTransaction({serializedTransaction: signature,});console.log("Sent via publicClient (eth_sendRawTransaction)");}catch(signError){console.warn("Failed to sign transaction with signTransaction:",signError);console.warn("Falling back to sendTransaction (may not use desired RPC endpoint)");// Fallback: Use sendTransaction, which signs and sends in one steptransactionHash=awaitwalletClient.sendTransaction({
...preparedRequest,account: address,});console.log("Sent via walletClient.sendTransaction (may use wallet's default RPC)");}
Expected Behavior
walletClient.signTransaction should sign the transaction locally using the user’s wallet (via eth_signTransaction).
Actual Behavior
walletClient.signTransaction fails with the following error:
InvalidInputRpcError: Missing or invalid parameters.
Double check you have provided the correct parameters.
Details: unknown account
Version: [email protected]
However, using walletClient.sendTransaction works fine, indicating that the wallet supports eth_sendTransaction.
Debugging Steps Taken
Verified Wallet Connection:
isConnected is true, and the address matches the expected account.
walletClient.requestAddresses() returns the correct account, confirming the wallet has access to it.
Tested with walletClient.sendTransaction:
Replacing signTransaction and sendRawTransaction with walletClient.sendTransaction works, but it doesn’t use my publicClient, I assume that the transaction is sent via the wallet’s default RPC endpoint.
Tried Explicitly Passing account:
Passed account: address to signTransaction, but the error persists.
Questions
Is there a way to make walletClient.signTransaction work?
Are there known issues with useWalletClient or signTransaction in [email protected] that might cause the "unknown account" error?
Additional Context
I need to use eth_sendRawTransaction via my publicClient because I want to route the transaction through a dedicated endpoint.
Any help or guidance would be greatly appreciated! Let me know if you need more details or logs.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I'm building a dApp on Base Mainnet (chain ID 8453) using Wagmi and viem, and I'm encountering an issue with
walletClient.signTransaction
. My goal is to sign a transaction locally using the user's wallet and then send the signed transaction usingpublicClient.sendRawTransaction
(which useseth_sendRawTransaction
) to route the transaction through an endpoint. However,walletClient.signTransaction
consistently fails with anInvalidInputRpcError: Missing or invalid parameters. Details: unknown account
error, even though the wallet supportseth_sendTransaction
(as evidenced bywalletClient.sendTransaction
working fine).I suspect the issue is related to the wallet connector (WalletConnect) not supporting
eth_signTransaction
, but I'm looking for guidance on how to resolve this while still meeting my requirement of usingeth_sendRawTransaction
via thepublicClient
.Environment
Code Snippets
Wagmi Configuration (
wagmiConfig.ts
)useSendTransaction
Hook (useSendTransaction.ts
)Expected Behavior
walletClient.signTransaction
should sign the transaction locally using the user’s wallet (viaeth_signTransaction
).Actual Behavior
walletClient.signTransaction
fails with the following error:walletClient.sendTransaction
works fine, indicating that the wallet supportseth_sendTransaction
.Debugging Steps Taken
Verified Wallet Connection:
isConnected
istrue
, and theaddress
matches the expected account.walletClient.requestAddresses()
returns the correct account, confirming the wallet has access to it.Tested with
walletClient.sendTransaction
:signTransaction
andsendRawTransaction
withwalletClient.sendTransaction
works, but it doesn’t use mypublicClient
, I assume that the transaction is sent via the wallet’s default RPC endpoint.Tried Explicitly Passing
account
:account: address
tosignTransaction
, but the error persists.Questions
walletClient.signTransaction
work?useWalletClient
orsignTransaction
in [email protected] that might cause the "unknown account" error?Additional Context
eth_sendRawTransaction
via mypublicClient
because I want to route the transaction through a dedicated endpoint.Any help or guidance would be greatly appreciated! Let me know if you need more details or logs.
Beta Was this translation helpful? Give feedback.
All reactions