-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheth.py
213 lines (153 loc) · 11.1 KB
/
eth.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
from Base_API_Call import API
import http.client
import json
class eth_Request:
def protocolVersion(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//protocolVersion"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_protocolVersion\",\"params\":[],\"id\":67}"
return API.Format(Call,Payload,Content,conn,form)
def syncing(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//syncing"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_syncing\",\"params\":[],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def coinbase(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//coinbase"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_coinbase\",\"params\":[],\"id\":64}"
return API.Format(Call,Payload,Content,conn,form)
def gasPrice(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//gasPrice"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_gasPrice\",\"params\":[],\"id\":73}"
return API.Format(Call,Payload,Content,conn,form)
def accounts(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON",ETH_account="0x438e0b511981FE8CF7283e981ca8c3394bB3646E"):
Call = "POST"
Content = "//accounts"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_accounts\",\"params\":[%s],\"id\":1}" % ETH_account
return API.Format(Call,Payload,Content,conn,form)
def blockNumber(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//blockNumber"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":83}"
return API.Format(Call,Payload,Content,conn,form)
def getBalance(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON",Address=""):
Call = "POST"
Content = "//getBalance"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBalance\",\"params\":[\"xdce4C4FeBE1Cb34C3490167c163C9ED92049B32B5c\",\"latest\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
#### REVIEW ####
def getStorageAt(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getStorageAt"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getStorageAt\",\"params\":[\"0x295a70b2de5e3953354a6a8344e616ed314d7251\",\"0x0\",\"latest\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
#### #### #### ####
def getTransactionCount(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getTransactionCount"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionCount\",\"params\":[\"0xbf1dcb735e512b731abd3404c15df6431bd03d42\",\"latest\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getBlockTransactionCountByHash(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getBlockTransactionCountByHash"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockTransactionCountByHash\",\"params\":[\"0xc8b967161c671ce952a3d50987a78d64157fb5a8e1724804b87d3e9b11e3aa34\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getBlockTransactionCountByNumber(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getBlockTransactionCountByNumber"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockTransactionCountByNumber\",\"params\":[\"0x52A8CA\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getCode(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getCode"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\",\"params\":[\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\",\"0x2\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
#### REVIEW ####
def sign(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//sign"
Payload = "{ \"jsonrpc\": \"2.0\", \"method\": \"eth_accounts\", \"params\": [], \"id\": 1}"
return API.Format(Call,Payload,Content,conn,form)
#### #### #### ####
def sendTransaction(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//sendTransaction"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_sendTransaction\",\"params\":[{\"from\":\"0xb60e8dd61c5d32be8058bb8eb970870f07233155\",\"to\":\"0xd46e8dd67c5d32be8058bb8eb970870f07244567\",\"gas\":\"0x76c0\",\"gasPrice\":\"0x9184e72a000\",\"value\":\"0x9184e72a\",\"data\":\"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675\"}],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def sendRawTransaction(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//sendRawTransaction"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_sendRawTransaction\",\"params\":[\"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def call(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//call"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_call\",\"params\":[{\"from\":\"0xb60e8dd61c5d32be8058bb8eb970870f07233155\",\"to\":\"0xd46e8dd67c5d32be8058bb8eb970870f07244567\",\"gas\":\"0x76c0\",\"gasPrice\":\"0x9184e72a000\",\"value\":\"0x9184e72a\",\"data\":\"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675\"},\"latest\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def estimateGas(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//estimateGas"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_estimateGas\",\"params\":[{\"from\":\"0xb60e8dd61c5d32be8058bb8eb970870f07233155\",\"to\":\"0xd46e8dd67c5d32be8058bb8eb970870f07244567\",\"gas\":\"0x76c0\",\"gasPrice\":\"0x9184e72a000\",\"value\":\"0x9184e72a\",\"data\":\"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675\"}],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getBlockByHash(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getBlockByHash"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByHash\",\"params\":[\"0x9326145f8a2c8c00bbe13afc7d7f3d9c868b5ef39d89f2f4e9390e9720298624\",true],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getBlockByNumber(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getBlockByNumber"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"0x0\",true],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getBlockSignersByNumber(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getBlockSignersByNumber"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockSignersByNumber\",\"params\":[\"0xA61F98\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getBlockSignersByHash(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getBlockSignersByHash"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockSignersByHash\",\"params\":[\"0x605777ee60ef3ccf21e079fa1b091b0196cf1a2c1dd7c088dd5b1ab03f680b6f\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getBlockFinalityByNumber(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getBlockFinalityByNumber"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockFinalityByNumber\",\"params\":[\"0xA61F98\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getBlockFinalityByHash(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getBlockFinalityByHash"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockFinalityByHash\",\"params\":[\"0x605777ee60ef3ccf21e079fa1b091b0196cf1a2c1dd7c088dd5b1ab03f680b6f\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getCandidates(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getCandidates"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCandidates\",\"params\":[\"latest\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getCandidateStatus(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getCandidateStatus"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCandidateStatus\",\"params\":[\"0x1d50df657b6dce50bac634bf18e2d986d807e940\",\"latest\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getTransactionByHash(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getTransactionByHash"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionByHash\",\"params\":[\"0xd83b26e101dd6480764bade90fc283407919f60b7e65ff83fbf6cdc92f1138a1\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getTransactionByBlockHashAndIndex(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getTransactionByBlockHashAndIndex"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionByBlockHashAndIndex\",\"params\":[\"0x3c82bc62179602b67318c013c10f99011037c49cba84e31ffe6e465a21c521a7\",\"0x0\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getTransactionByBlockNumberAndIndex(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getTransactionByBlockNumberAndIndex"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionByBlockNumberAndIndex\",\"params\":[\"0x52A96E\",\"0x1\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)
def getTransactionReceipt(conn=http.client.HTTPSConnection("rpc.xinfin.network"), form="JSON"):
Call = "POST"
Content = "//getTransactionReceipt"
Payload = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionReceipt\",\"params\":[\"0xa3ece39ae137617669c6933b7578b94e705e765683f260fcfe30eaa41932610f\"],\"id\":1}"
return API.Format(Call,Payload,Content,conn,form)