Hi,
I'm trying to write a little script using web3 1.0.0-beta.26 to watch things on the blockchain related to CryptoKitties.
Somehow my first two attempts at posting some code got cut off.
Here is some code:
var Web3 = require('web3');
var web3 = new Web3(Web3.givenProvider || "ws://localhost:8546");
var subscription = web3.eth.subscribe('logs', {
address: '0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C' // sales auction contract
}, function(error, result) {
if (!error) {
console.log(result);
}
});
It works, I'm getting events but I don't know how to interpret the "topics" array.
From what I've read it's supposed to be the sha3() hash of the fingerprint of the event.
I've tried fingerprinting lots of strings and none of them match.
According to the
latest ERC721 draft, the event should be
Transfer(address,address,uint256).
Yet
console.log(web3.utils.sha3("Transfer(address,address,uint256)"));yields
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef which is a value that never appears in the list of topics I am receiving.
Here are some results:
{ address: '0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C',
topics:
[ '0x4fcc30d90a842164dd58501ab874a101a3749c3d4747139cefe7c876f4ccebd2' ],
data: '0x00000000000000000000000000000000000000000000000000000000000409020000000000000000000000000000000000000000000000000018de76816d8000
0000000000000000000000005f8119e5cab14c2f4ecc81cef51789f1a3bc611a',
blockNumber: 0,
transactionHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
transactionIndex: 0,
blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
logIndex: 0,
removed: false,
id: 'log_247b1779',
}
{ address: '0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C',
topics:
[ '0xa9c8dfcda5664a5a124c713e386da27de87432d5b668e79458501eb296389ba7' ],
data: '0x000000000000000000000000000000000000000000000000000000000003ad5e000000000000000000000000000000000000000000000000008e1bc9bf040000000000000000000000000000000000000000000000000000006a94d74f430000000000000000000000000000000000000000000000000000000000000002a300',
blockNumber: 0,
transactionHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
transactionIndex: 0,
blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
logIndex: 0,
removed: false,
id: 'log_247b1779',
}
{ address: '0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C',
topics:
[ '0x2809c7e17bf978fbc7194c0a694b638c4215e9140cacc6c38ca36010b45697df' ],
data: '0x00000000000000000000000000000000000000000000000000000000000270d0',
blockNumber: 0,
transactionHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
transactionIndex: 0,
blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
logIndex: 0,
removed: false,
id: 'log_247b1779',
}
Could someone explain to me the values for the topics array I am seeing here? I tried to hash various Event signatures with sha3() but it came up with something else.
Comments
One of the events is "AuctionSuccessful" with the signature
AuctionSuccessful(uint256,uint256,address)
sha3() yields 0x4fcc30d90a842164dd58501ab874a101a3749c3d4747139cefe7c876f4ccebd2
Another one is
AuctionCreated(uint256,uint256,uint256,uint256)
yielding
0xa9c8dfcda5664a5a124c713e386da27de87432d5b668e79458501eb296389ba7
Here is my new working code: