So I am building a Dapp to interact with an ERC721 contract. So far I'm able to mint, transfer and check an address balance. I'm stuck with trying to show who owns which token( via their token id). The output keeps saying


It randomly works and shows the address of the owner. The console is not showing any errors. Attached are my code and picture of the output. Thanks in advance.


 <h1>Token Owner</h1>
<br><label for "tokenId">Token ID;</label><input type="text" id="tokenId" placeholder="e.g., 03945812"></input>
<br><br>Owner is <span type="text" id="wallet"></span>
<br><br><button id="check" onclick="App.ownerOf()">Check</button>

App.js Code

//App.ownerOf function 5
ownerOf: function(){ //stuck at Checking blockchain info... not throwing an error
var self = this;

var tokenId = parseInt(document.getElementById("tokenId").value);

this.setStatus("Checking Blockchain info...");

var check;
  check = instance;
  return check.ownerOf.call(tokenId,{from: account});
}).then(function(account){ //function(owner)
  var value;
  value = account;
  var account_element = document.getElementById("wallet");
  account_element.textContent = value.valueOf();
  self.setStatus("Error checking ticket ID; see log");

ERC7221BasicToken.sol Code

function ownerOf(uint256 _tokenId) public view returns (address) {
  address owner = tokenOwner[_tokenId];
  require(owner != address(0));
  return owner;

Web Screenshot

enter image description here

Thanks Again! Let me k now if you guys need me to add anything else.

  • 0x is the value of an empty address. Are you sure that the token 1 got an owner ?
    – Tclairet
    Aug 3, 2018 at 13:25
  • Yes, when you mint a token it automatically gets stored in the address you wanted it to get mint. I am also double checking everything by interacting with the contract on wallet.ethereum.org and I does show a owner for token 1.
    – Mr.Blonde
    Aug 3, 2018 at 17:49
  • How are tokens minted? Do you have the code of the contract? You can check the receipt of the transaction to verify if the tx was executed correctly
    – Ismael
    Aug 3, 2018 at 23:46

2 Answers 2


It seems like you are using truffle(i don't have much experience in truffle). But if you use following code snippet your task will be done. There is no need to use call in your case. Hope this'll help you out.

ownerOf: function(){
var self = this;
var tokenId = parseInt(document.getElementById("tokenId").value);
var contractAbi = web3.eth.contract(YourContractABI);
var myContract = contractAbi.at(YourContractAddress);
       //Here Data will be Token Holder address
  • I am trying to use, it lets me compile but when I click the check button on the webapp, nothing happens, it does not show an error or anything. I'm going to keep playing with it.
    – Mr.Blonde
    Aug 3, 2018 at 17:50

So I was doing a stupid mistake, on my in HTML I was using the same "id" in two functions. I just changed the id and now is working.

  • Please close question, it sounds like this is too specific of an error to be useful for others. Thanks!
    – PhABC
    Aug 3, 2018 at 20:44
  • Wil do just waiting so StackExchange lets me accept my own answer!
    – Mr.Blonde
    Aug 3, 2018 at 21:53

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.