Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ERC-721 tokens #447

Closed
acravenho opened this issue Jul 21, 2018 · 2 comments · Fixed by #484
Closed

Add support for ERC-721 tokens #447

acravenho opened this issue Jul 21, 2018 · 2 comments · Fixed by #484

Comments

@acravenho
Copy link
Contributor

acravenho commented Jul 21, 2018

As reported by @alexgaribay this week some tokens do not have total supply and other functions that other ERC-20 tokens usually possess. Most likely these token transfers are ERC-721. There are a few slight differences in these 2 types of token transfers.

ERC-721 are non-fungible tokens and every token can be owned by a separate owner.

  1. ERC-721 have a 4th topic which is the TokenID of that particular token being transferred
  2. The data field of the token which usually determines the number of tokens being transferred for ERC-20 tokens is in a different format.
  3. For now we should just use the name and symbol functions for the ABI to query the blockchain.

Here is the source code for a standard ERC-721 token:

contract ERC721 {
   // ERC20 compatible functions
   function name() constant returns (string name);
   function symbol() constant returns (string symbol);
   function totalSupply() constant returns (uint256 totalSupply);
   function balanceOf(address _owner) constant returns (uint balance);
   // Functions that define ownership
   function ownerOf(uint256 _tokenId) constant returns (address owner);
   function approve(address _to, uint256 _tokenId);
   function takeOwnership(uint256 _tokenId);
   function transfer(address _to, uint256 _tokenId);
   function tokenOfOwnerByIndex(address _owner, uint256 _index) constant returns (uint tokenId);
   // Token metadata
   function tokenMetadata(uint256 _tokenId) constant returns (string infoUrl);
   // Events
   event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
   event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
}

Here is the ABI I'm using for name and symbol for ERC-721 on the community explorer:

https://github.com/acravenho/contract-verification/blob/master/contracts/erc721.json

@acravenho acravenho added this to the Kuala Lumpur milestone Jul 21, 2018
@alexgaribay
Copy link
Contributor

@acravenho When it comes to indexing, I shouldn't parse the data field for what are supposed to be ERC-721 token transfers? For ERC-20, I'm parsing that field for the amount of tokens being transferred.

@acravenho
Copy link
Contributor Author

@alexgaribay I believe the data field is an extra field that could be used to show an image or some other data. I'm looking for clarification on this and will keep digging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants