CRYPTO NEWS

Parsing log data from Etherscan

I am trying to use Python to parse Uniswap swap event data from Etherscan. Here is the code for obtaining the swap event log:

import requests  etherscan_api = 'https://api.etherscan.io/api' etherscan_api_key = 'ETHERSCAN_API_KEY' pool_address = '0x5777d92f208679DB4b9778590Fa3CAB3aC9e2168' #DAU/USDC pool  swap_topic = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67'  params = {     'module': 'logs',     'action': 'getLogs',     'address': pool_address,     'fromBlock': 15591456,     'toBlock': 15591456,     'topic0': swap_topic,     'page': 1,     'offset': 1000,     'apikey': etherscan_api_key }  resp = requests.get(url=etherscan_api, params=params) resp.json()['result'] 

which returns

[{'address': '0x5777d92f208679db4b9778590fa3cab3ac9e2168',   'topics': ['0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67',    '0x000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564',    '0x000000000000000000000000b0ccf43ada6cbaa26dcf4907117b496d49f74242'],   'data': '0xfffffffffffffffffffffffffffffffffffffffffffffff7cf3dd2f5c2526afa000000000000000000000000000000000000000000000000000000000901ae820000000000000000000000000000000000000000000010c70158041addb5d04a00000000000000000000000000000000000000000003717214bf888b6de019b6fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89c',   'blockNumber': '0xede820',   'blockHash': '0x173abb50387b29add553b4e1fc3154d02f0fc55c277738bd8d16d3d8022ae76d',   'timeStamp': '0x632cce2b',   'gasPrice': '0x2ba5552a7',   'gasUsed': '0x20d7a',   'logIndex': '0xb6',   'transactionHash': '0x63e6d27fdbea0968fb10130e59dfa1b79d18074a971ed5cbd7c25cfe32c1f1e3',   'transactionIndex': '0x34'}] 

I expect that the data field contains the swap information (sender, receiver, amounts, etc.) How do I actually parse it?

Access blocked by CORS policy

I have an Ubuntu machine running two docker nodes. When I try to access nodes from my web based application, installed on the same machine I keep getting the following error : web3.min.js:2 Access to XMLHttpRequest at ‘http://localhost:8502/’ from origin ‘http://localhost:8000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control::Listen

I have an Ubuntu machine running two docker nodes. When I try to access nodes from my web based application, installed on the same machine I keep getting the following error :

web3.min.js:2 Access to XMLHttpRequest at ‘http://localhost:8502/’ from origin ‘http://localhost:8000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Even if my starting command is the following:

CMD exec ./geth –syncmode ‘full’ –port 30313 –rpc –rpccorsdomain ‘*’ –rpcaddr ‘0.0.0.0’ –rpcport 8503 –rpcapi personal,db,eth,net,web3,txpool,miner –bootnodes "enode://[email protected]$bootnodeIp:30311" –networkid="1005" –gasprice ‘1’ -unlock $address –password ~/.password –mine

so including : –rpccorsdomain ‘*’

Result is the same with google chrome and with Firefox. Connection with Metamask is working well.

Can anybody help ?

Thanks

Parsing log data from Etherscan

Shopping cart
There are no products in the cart!
Continue shopping
0