0

I'm trying to pull together a dataset on various token transcations using the web3 module in python.

However, being new, I'm confused by how to subset the blockchain information to a specific contract?

From the documentation, I see that getBlock returns a dictionary of data along the following lines:

 web3.eth.getBlock('latest')
    AttributeDict({'difficulty': 3565901981820924,
 'extraData': HexBytes('0xd88301080c846765746888676f312e31302e33856c696e7578'),
 'gasLimit': 8003769,
 'gasUsed': 910656,
 'hash': HexBytes('0xd923c9eab4170829de4564d890da4252734be917e1def8e552d3b629f96095c2'),
 'logsBloom': HexBytes('0x0000000000000000020000000001000210005088000000100010010000000000000014000000020000000000000004000000000000000000000000001000000000000000000000010200000800000000000000800000000000000000000000000000000000000000000100400000000080000000042000000000001000002021000002400000000042000002008800000000080200000000000000000000210000000800000020a000000400000080000000000000100000000082000400080820400022000000002010000002000008000204000000000020080000210000020200000100000008000000001010800000000000000000000000000000000000'),
 'miner': '0x70AEc4B9CFFA7b55C0711b82DD719049d615E21d',
 'mixHash': HexBytes('0xd2cc21eaddd0bb4fef18dea5818fdbef9be15fd3b2a2437e3d544e17d0d9d2fc'),
 'nonce': HexBytes('0xd9d9069c3f22029b'),
 'number': 6094883,
 'parentHash': HexBytes('0x5bb80f9cb2c211d491f0e577af5200554acd598c04747209d7bd6992c7c085ea'),
 'receiptsRoot': HexBytes('0xaf036a72249908917ba2c75ce8fb335130ddf1b32c82600f6a43aaa684a77981'),
 'sha3Uncles': HexBytes('0x6b1c94df0470550749913d1b41ad7cd7b90f31293138e141b5f4fb629a91cc77'),
 'size': 4132,
 'stateRoot': HexBytes('0x6cce79f7a0f33944e6a9d646161efde8ae994829d524c25e45a66f0e4b60e191'),
 'timestamp': 1533504315,
 'totalDifficulty': 5815824596916454330163,
 'transactions': [HexBytes('0x8562054f35b0b903b910f692842c14eadeb91f5e8a8c621e417e70c12a8860a5'),
  HexBytes('0x63d00f5d3cdacb7eb9817fd770184642edbe3efa873ab713bd0697a99be0145f'),

However, I'm not clear on how to parse this block information to look for transfers of a particular token. Any help is appreciated.

0

1 Answer 1

0

Every standard ( ERC-20 ) token has an event for transfers and Web3 allows you to use these events for showing Token transfer history.

for example you can use this part of code to get all transfers of a specific token:
transferEvent = Token.Transfer({}, {fromBlock: 0, toBlock: 'latest'});

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