The pages http://www.kittyexplorer.com/prices/ and https://kittysales.herokuapp.com/ show sales with prices and the IDs of the cats sold. How could I implement such a functionality programmatically?

I've already searched GitHub but the code there does not allow to access such a sales history. I've also looked at the transaction details at https://etherscan.io/ but I do not get information about the cat ID there.

1 Answer 1



The kitty auction contract emits an "AuctionSuccessful" event on each successful sale. You can get past events using web3.js with code that looks something like:

var cksale = web3.eth.contract(saleAbi).at("0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C")

cksale.getPastEvents('AuctionSuccessful', { fromBlock: 4605167 }, (error, events)=>{
    console.log(`Got some sales: ${JSON.stringify(events)}`)

Note: Cryptokitties was deployed on block 4605167 so no point in checking blocks earlier than that for events.

It takes a while to search for past events, you'll probably be better off chunking it into 10/100 block intervals instead of trying to get all events in one giant call.

  • Note: that web3 1.0 is not yet officially released, so their may be regressions and breaking changes in the future.
    – Victory
    Dec 15, 2017 at 23:17

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.