I'm trying to make a simple function call to a view function that takes a single uint256 as input, however when I try to pass the variable, next type check gives me this error: Expected 0 arguments, but got 1.

Here is my code:

const txData = claimContract.methods["viewEvent(uint256)"](eventId)

  const transactionObject = {
    to: claimContract.options.address!,
    data: txData.encodeABI(), 

  const eventData = await web3.eth.call(transactionObject as any);

I've console logged the method to ensure it takes an input parameter:

viewEvent: [Function (anonymous)],
  'viewEvent(uint256)': [Function (anonymous)],
  '0x24923f5f': [Function (anonymous)],

And also tried the three different web3js syntax from the docs:

//const txData = claimContract.methods.viewEvent(eventId);
  //const txData = claimContract.methods["viewEvent(uint256)"](eventId);
  // const txData = claimContract.methods["0x24923f5f"](eventId);

1 Answer 1


There is an active web3js GitHub issue about this problem that will hopefully fix this issue in the future.

However, one "ugly" workaround to make this work while pleasing next type checks would be to create your data object like this:

const txData = (claimContract.methods.viewEvent as any)(eventId);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.