Skip to content

Uniswap Plugin Fails on sendTransaction Due to Incorrect value Type #515

@dkirste

Description

@dkirste

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,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions