Skip to content

Lesson 15: Issue (and fix) while calling tokenURI via Moralis. #908

Answered by Mirthis
Mirthis asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, It took me quite some time to figure this out but the problem was actually related to the function declaration in the contract.
My function was declared as follow, where the argument name is commented as it's not used in the function body.

function tokenURI(
  uint256 /*tokenId */
) public view override returns (string memory) {
  return TOKEN_URI;
}

Still for the call to work from the front-end I had to remove the comment as follow:

function tokenURI(uint256 tokenId)
  public
  view
  override
  returns (string memory)
{
  return TOKEN_URI;
}

The two versions of the functions produce a different ABI and I assume this is what's creating the problem.

With parameter commented:

{
    "…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Mirthis
Comment options

Comment options

You must be logged in to vote
1 reply
@benjbright
Comment options

Answer selected by Mirthis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants