'web3.exceptions.ValidationError: with tuple[], address, bytes

Getting the following validation error and could not point to why

Could not identify the intended function with name `z`, positional argument(s) of type `(<class 'list'>, <class 'str'>, <class 'bytes'>)` and keyword argument(s) of type `{}`.
Found 1 function(s) with the name `z`: ['z(tuple[],address,bytes)']
Function invocation failed due to no matching argument types.

Here is the function signature of the contract

function z(Tx[] memory d, address payable addr, bytes calldata data) public onlyOwners;

Using the following web3.py code

tx = []
addr = "0x..."
data = "...."
data = data.encode()       <--- Tried with and without this

contract.functions.z(tx, addr, data).buildTransaction({...})

Any help would be really appreciated.



Solution 1:[1]

The function asks for a type tuple[]. I found that you have to create your tx list like this: tx = [()] instead of tx = [].

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tony Brinkman