-
Notifications
You must be signed in to change notification settings - Fork 281
Description
Describe the bug
The Uniswap tool is causing a viem error when it attempts to send an approval transaction. The tool fetches approval data from an API, which correctly returns value: "0x00". However, the tool then passes this hex string directly to the walletClient.sendTransaction method.
The sendTransaction method from viem expects the value field to be a bigint, not a string. This type mismatch causes the transaction to fail. The error message "Cannot convert 0x0x00 to a BigInt\nVersion: viem@2.31.7" seems to indicate a string concatenation issue within the library where "0x" is incorrectly prepended to the existing "0x00".
To Reproduce
The bug occurs when creating any transaction where the value is zero (e.g., approving an ERC20 token, or swapping tokens).
Expected behavior
The transaction should be successfully created and broadcast. The Uniswap tool should correctly handle the data types required by the viem wallet client.
Suggested Solution
Before calling walletClient.sendTransaction, the approval.value string must be converted into a bigint. This can be done using viem's own fromHex utility.
const transaction = await walletClient.sendTransaction({
to: approval.to,
value: fromHex(approval.value, 'bigint'),
data: approval.data,
});