-
Notifications
You must be signed in to change notification settings - Fork 0
/
web3_connections.py
41 lines (37 loc) · 1.11 KB
/
web3_connections.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import web3
import requests
import json
from macaron_utils import print_err
def get_trace(hash, rpc_endpoint):
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "debug_traceTransaction",
"params": [
hash,
{
"disableStorage": False,
"disableMemory": False,
"disableStack": False,
"fullStorage": True,
},
],
}
response = requests.post(rpc_endpoint, timeout=None, json=payload, stream=True)
assert response.status_code == 200, response
response_json = json.loads(response.text)
if "error" in response_json:
print_err(response_json["error"])
exit(1)
return response_json
def get_transactionData(hash, rpc_endpoint):
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getTransactionByHash",
"params": [hash],
}
response = requests.post(rpc_endpoint, json=payload, timeout=None, stream=True)
assert response.status_code == 200, response
response_json = json.loads(response.text)
return response_json