0

I'd like to understand more about this ERC721 non-fungible tokens.

I bought some cryptokitties (non 721), some art on KnownOrigin and now I want to display them in a web page.

For Cryptokitties I'm contacting the Cryptokitties API with the public address and get all the info

https://api.cryptokitties.co/kitties?owner_wallet_address=PUBLIC_ADDRESS&limit=100&offset=0

{
"offset": 0,
"limit": 20,
"kitties": [
    {
        "id": 732654,
        "name": null,
        "image_url": "https://storage.googleapis.com/ck-kitty-image/0x06012c8cf97bead5deae237070f9587f8e7a266d/732654.svg",
        "image_url_cdn": "https://img.cn.cryptokitties.co/0x06012c8cf97bead5deae237070f9587f8e7a266d/732654.svg",
        "generation": 10,
        "created_at": "2018-05-02T17:21:13.000Z",
        "color": "mintgreen",
        "is_fancy": false,
        "is_exclusive": false,
        "fancy_type": null,
        "language": "en",
        "status": {
            "cooldown": 1442113251014,
            "cooldown_index": 5,
            "is_ready": true,
            "is_gestating": false
        },
        "purrs": {
            "count": 0,
            "is_purred": false
        },
        "watchlist": {
            "count": 0,
            "is_watchlisted": false
        },
        "hatched": true,
        "auction": {},
        "owner": {
            "address": "0x15d82290c2d78764fca6e158b5af5e2e9ddb46a8",
            "nickname": "Ziba Leah",
            "image": "13"
        },
        "sire": {
            "id": 193991,
            "name": null,
            "image_url": "https://storage.googleapis.com/ck-kitty-image/0x06012c8cf97bead5deae237070f9587f8e7a266d/193991.svg",
            "image_url_cdn": "https://img.cn.cryptokitties.co/0x06012c8cf97bead5deae237070f9587f8e7a266d/193991.svg",
            "generation": 5,
            "created_at": "2017-12-09T22:25:59.000Z",
            "color": "strawberry",
            "is_fancy": false,
            "is_exclusive": false,
            "fancy_type": null
        },
        "matron": {
            "id": 730675,
            "name": null,
            "image_url": "https://storage.googleapis.com/ck-kitty-image/0x06012c8cf97bead5deae237070f9587f8e7a266d/730675.svg",
            "image_url_cdn": "https://img.cn.cryptokitties.co/0x06012c8cf97bead5deae237070f9587f8e7a266d/730675.svg",
            "generation": 9,
            "created_at": "2018-04-30T14:41:12.000Z",
            "color": "mintgreen",
            "is_fancy": false,
            "is_exclusive": false,
            "fancy_type": null
        }
    }
]
"total": 1

}

From my understanding some of the metadata are saved into the blockchain. So I called the API from several API service (blockcypher, etherscan etc) and receive my list of tokens like:

{
"address": "PUB ADDRESS",
"total_received": 150015053924110913,
"total_sent": 30815090241240544,
"balance": 119199963682870369,
"unconfirmed_balance": 0,
"final_balance": 119199963682870369,
"n_tx": 13,
"unconfirmed_n_tx": 0,
"final_n_tx": 13,
"nonce": 9,
"pool_nonce": 9,
"txrefs": [
    {
        "tx_hash": "a73c7c191012a0a26cfe434d49a6ff7cd8a94002c6e50f733b7cdd19a3a5efc7",
        "block_height": 5544476,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 8582063000000000,
        "ref_balance": 119199963682870369,
        "confirmations": 3677,
        "confirmed": "2018-05-02T16:56:18Z",
        "double_spend": false
    },
    {
        "tx_hash": "00dab2130486c9c5fddf1896347a56ce776dde0131a1d639ad889f8e07436641",
        "block_height": 5544474,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 141419687500000,
        "ref_balance": 127782026682870369,
        "confirmations": 3679,
        "confirmed": "2018-05-02T16:56:11Z",
        "double_spend": false
    },
    {
        "tx_hash": "26cad46648d402ed5d784ac9406d896da68d3f82472568a45fe42023cf7438a2",
        "block_height": 5544471,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 128380000000000,
        "ref_balance": 127923446370370369,
        "confirmations": 3682,
        "confirmed": "2018-05-02T16:55:22Z",
        "double_spend": false
    },
    {
        "tx_hash": "032bde82867e4df40f26c75cbb88b1a6853ff379f65cdb3645e90ece61860e20",
        "block_height": 5544469,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 8399925000000000,
        "ref_balance": 128051826370370369,
        "confirmations": 3684,
        "confirmed": "2018-05-02T16:54:46Z",
        "double_spend": false
    },
    {
        "tx_hash": "8d4f922977ae6a662cbd09cf49719b17ac213a88f4d02b4dd4a53206fc458794",
        "block_height": 5532550,
        "tx_input_n": -1,
        "tx_output_n": 0,
        "value": 2521768148157,
        "ref_balance": 136451751370370369,
        "confirmations": 15603,
        "confirmed": "2018-04-30T14:24:18Z",
        "double_spend": false
    },
    {
        "tx_hash": "64a8fc9012dc23443b8b1d66bf1dd4aad8501552fdd17146e4a0479612689169",
        "block_height": 5532550,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 1838649731111120,
        "ref_balance": 136449229602222212,
        "confirmations": 15603,
        "confirmed": "2018-04-30T14:24:18Z",
        "double_spend": false
    },
    {
        "tx_hash": "e061d7c8e6e5775cdc4029244e0da568412a15608592cd95abd7b4ad965b9cba",
        "block_height": 5532491,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 8319940000000000,
        "ref_balance": 138287879333333332,
        "confirmations": 15662,
        "confirmed": "2018-04-30T14:08:53Z",
        "double_spend": false
    },
    {
        "tx_hash": "601d8d3b02c20cb0a3413aafd738f01340ceb0f006e76294b684f12eee51f487",
        "block_height": 5532066,
        "tx_input_n": -1,
        "tx_output_n": 0,
        "value": 2997693382888,
        "ref_balance": 146607819333333332,
        "confirmations": 16087,
        "confirmed": "2018-04-30T12:17:29Z",
        "double_spend": false
    },
    {
        "tx_hash": "30498f034eedb42762386a36ed12c290c7e13fc9e912afbc21f7646ddcf2a550",
        "block_height": 5532066,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 1901140804494000,
        "ref_balance": 146604821639950444,
        "confirmations": 16087,
        "confirmed": "2018-04-30T12:17:29Z",
        "double_spend": false
    },
    {
        "tx_hash": "debfb135948a8daf10df225f7f462be27a9fe2064379120c5464b129386a3e71",
        "block_height": 5532064,
        "tx_input_n": -1,
        "tx_output_n": 0,
        "value": 9534462579868,
        "ref_balance": 148505962444444444,
        "confirmations": 16089,
        "confirmed": "2018-04-30T12:17:11Z",
        "double_spend": false
    },
    {
        "tx_hash": "b267fe9b152176dfa67ee4a8b773069793d0cfb42b6fce2350990f057dac92a5",
        "block_height": 5532064,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 1408372018135424,
        "ref_balance": 148496427981864576,
        "confirmations": 16089,
        "confirmed": "2018-04-30T12:17:11Z",
        "double_spend": false
    },
    {
        "tx_hash": "ca0b0f8de001df25c39f3cd479f981a37b5ff348b23c8c3b2cbe596aabfc2a27",
        "block_height": 5532062,
        "tx_input_n": 0,
        "tx_output_n": -1,
        "value": 95200000000000,
        "ref_balance": 149904800000000000,
        "confirmations": 16091,
        "confirmed": "2018-04-30T12:16:41Z",
        "double_spend": false
    },
    {
        "tx_hash": "390a3231fd3a7fa80b52bdbc6f97eee1217bc026fdbf8e41a59bafda5160b5d4",
        "block_height": 5531712,
        "tx_input_n": -1,
        "tx_output_n": 0,
        "value": 150000000000000000,
        "ref_balance": 150000000000000000,
        "confirmations": 16441,
        "confirmed": "2018-04-30T10:50:00Z",
        "double_spend": false
    }
],
"tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"

}

I would expect at this point to see somehow the METADATA stored on the chain.

Where can I get this info from my public address?

Is it related to the API I'm contacting (maybe they are not showing all the metadata in the response)?

As far as I understand, I must get somewhere an ID to get from IPFS the metadata. Where can I find this id from the transaction list / from public address?

Thanks in advance

-1

Most of the ERC721 implements a method to obtain the token assigned for a user.

So the "standard" approach works like this:

  • get the contract
  • get the balance for the current user
  • get the single item via "tokenOfOwnerByIndex" (or similar)
  • get the metadata of the item via getItem method (getFighter, getKitty etc..)

An example for CryptoFighters could be something like this (using web3js):

var CRYPTOFIGHTERS_ADDRESS = "0x87d598064c736dd0C712D329aFCFAA0Ccc1921A1";
var CRYPTOFIGHTERS_ABI = [.... TOO LONG ... ]
var CRYPTOFIGHTERS_API = web3.eth.contract(CRYPTOFIGHTERS_ABI).at(CRYPTOFIGHTERS_ADDRESS);

CRYPTOFIGHTERS_API.balanceOf(web3.eth.accounts[0], function(e, s)
{
  totalFighters = parseInt(s);
  for (i = 0; i < totalFighters; i++)
  {
    CRYPTOFIGHTERS_API.tokensOfOwnerByIndex(web3.eth.accounts[0],i, function(error, success) 
    {
       if (success.c[0] > 0)
        loadFighter(success.c[0]);
    });
  }
});      


function loadFighter(id)
{
    CRYPTOFIGHTERS_API.getFighter(id, function(error, success) 
    { 
      console.log(JSON.stringify(success)); 
      cryptofighters.push(JSON.stringify(success));
});
}

The same approach could be used for CryptoKitties and most of them. The methods in the smart contract can change a little but the approach is the same.

PLEASE NOTE

Crypto Kitties method is "too slow" so most of the time gives "0" as answer. The suggestion is to use their API. The same for other platforms, the developers suggest to use their specific API

Your Answer

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

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