0

I'm trying to create a bond NFT on blockchain and currently testing the functions on the ERC721 standard.

I'm having issues with the function ownerOf(uint256 _tokenId) external view returns (address);

I'm using 0xcert implementation for ERC-721 (nf-token.sol https://github.com/0xcert/ethereum-erc721/blob/master/src/contracts/tokens/nf-token.sol), which has this function defined. I've managed to get other functions to work in my smart contract, but for this one I get an error saying 'not found or not visible argument dependent lookup' (on Remix).

I'm guessing I'm doing something wrong, but can't figure out where the problem is. Am I using the function parameters wrong? I have tokenIds (unit256) running from 0 to tokenCounter). Can anyone help me on this?

// 0xcert function:

  function ownerOf(uint256 _tokenId)
    external
    override
    view
    returns (address _owner)
  {
    _owner = idToOwner[_tokenId];
    require(_owner != address(0), NOT_VALID_NFT);
  }

// Function on my contract where I try to call the function:

function payCoupon() external onlyOwner {
         for (uint256 i = 1; i <= tokenCounter; i++) {
             // Get the owner for each token
             address _tokenOwner = super.ownerOf(i);
             // Pay the coupon from company to the owner
             pay(_company, _tokenOwner, _coupon);
         }
     }

Full implementation of my code (I have not defined the pay function yet, but left it there to show what my intentions are) :

// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;

import "https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol";
import "https://github.com/0xcert/ethereum-erc721/src/contracts/ownership/ownable.sol";
 
 
 contract Nft is NFTokenMetadata, Ownable {
     uint256 tokenCounter;
     uint256 coupon;
     address issuer;
     
     constructor(uint256 _coupon, address _issuer ) {
         nftName = "Test Bond";
         nftSymbol = "NFTB";
         tokenCounter = _coupon;
         address = _issuer;
     }
     
     
     function payCoupon() external onlyOwner {
         for (uint i = 1; i <= tokenCounter; i++) {
             // Get the owner for each token
             address _tokenOwner = super.ownerOf(i);
             // Pay the coupon from company to the owner
             pay(_company, _tokenOwner, _coupon);
         }
     }
     
     function mint (address _to, string calldata _uri) external onlyOwner {
         tokenCounter++;
         uint256 _tokenId = tokenCounter;
         super._mint(_to, _tokenId);
         super._setTokenUri(_tokenId, _uri);
     }
 }
3
  • Could you copy-paste your full implementation? I think you're extending 0xcert's implementation instead of forking and changing it, and I don't recommend to do things that way. Still, the reason why your code above doesn't work is because ownerOf is defined with the external visibility modifier. Which means you can't call it in the extended contract as super.ownerOf(i). It needs to be 0xCertContract(contractAddress).ownerOf(i);. – scorpion9979 Jun 9 at 12:47
  • @scorpion9979 Thank you! I have added the full implementation above. I'm extending the implementation as you said, and haven't even thought about forking. Would the function work if I could change the visibility modifier? (I need to do more reading on this!) And when you have the contractAddress there which address does it refer to? I did some digging, and someone suggested that the function would work by using this.functionName() for functions with external visibility modifiers. – lepocode Jun 10 at 10:59
  • contractAddress is the address of the deployed 0xCertContract. The function should work if you set the visibility modifier from external to public, but I would recommend just forking the code. – scorpion9979 Jun 10 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.