0

I'm writing a React app that calls to see who the owner of a tokenId is.

I am trying to call the built-in function ownerOf(uint256 tokenId) from the ERC721 contract.

Here is my javascript code:

const GetOwnerOf = async (tokenId) => {
  console.log(`Getting owner of ${tokenId}`);

  const bc = new web3.eth.Contract(bannerContractABI, bannerContractAddress);
  const r = bc.methods.ownerOf(tokenId);

  console.log(r);
  return r;
}

I'm seeing this in my console (Chrome): enter image description here

I have confirmed that the contract ABI is correct and the contract address is correct.

How do i retrieve the data? The ownerOf function returns an address, how do i view this address?

.

2 Answers 2

1

Adding to the previous answer, use await since all the methods are async.

const r = await bc.methods.ownerOf(tokenId).call();
console.log(r);
1

You didnt actually call:

https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html#id29

need to do bc.methods.ownerOf(tokenId).call(blah)

Your Answer

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

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