-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathethereum.py
149 lines (104 loc) · 4.7 KB
/
ethereum.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
import ethereumJSON
class EthereumAPI:
def __init__(self):
self.json = ethereumJSON.EthereumJSON()
def coinbase(self):
return self.json.sendJSONRequest("eth_coinbase")
# Not implemented 150220 in go-ethereum
# Implemented in cpp-ethereum
def setCoinbase(self, coinbase):
return self.json.sendJSONRequest("eth_setCoinbase", coinbase)
def listening(self):
return self.json.sendJSONRequest("eth_listening")
# Not implemented 150220 in go-ethereum
# Implemented in cpp-ethereum
def setListening(self, listening):
return self.json.sendJSONRequest("eth_setListening", listening)
def mining(self):
return self.json.sendJSONRequest("eth_mining")
# Not implemented 150220 in go-ethereum
# Implemented in cpp-ethereum
def setMining(self, mining):
return self.json.sendJSONRequest("eth_setMining", mining)
def gasPrice(self):
return self.json.sendJSONRequest("eth_gasPrice")
def accounts(self, client=None):
return self.json.sendJSONRequest("eth_accounts", client)
def peerCount(self):
return self.json.sendJSONRequest("eth_peerCount")
def defaultBlock(self):
return self.json.sendJSONRequest("eth_defaultBlock")
def setDefaultBlock(self, block):
return self.json.sendJSONRequest("eth_setDefaultBlock", block)
def number(self):
return self.json.sendJSONRequest("eth_number")
def balanceAt(self, address):
return self.json.sendJSONRequest("eth_balanceAt", address)
# Not working :( TODO:
def stateAt(self, address, index):
return self.json.sendJSONRequest("eth_stateAt", address, index)
def storageAt(self, address):
return self.json.sendJSONRequest("eth_storageAt", address)
def countAt(self, address):
return self.json.sendJSONRequest("eth_countAt", address)
def transactionCountByHash(self, hash):
return self.json.sendJSONRequest("eth_transactionCountByHash", hash)
def transactionCountByNumber(self, number):
return self.json.sendJSONRequest("eth_transactionCountByNumber", number)
def uncleCountByHash(self, hash):
return self.json.sendJSONRequest("eth_uncleCountByHash", hash)
def uncleCountByNumber(self, number):
return self.json.sendJSONRequest("eth_uncleCountByNumber", number)
def codeAt(self, address):
return self.json.sendJSONRequest("eth_codeAt", address)
# TODO: test
def transact(self, code):
return self.json.sendJSONRequest("eth_transact", json.dumps({"code":code}))
# TODO: test
def call(self, to, data):
return self.json.sendJSONRequest("eth_call", json.dumps({"to":to, "data":data}))
def flush(self):
return self.json.sendJSONRequest("eth_flush")
# TODO: Not working :(
def blockByHash(self, hash):
return self.json.sendJSONRequest("eth_blockByHash", hash)
def blockByNumber(self, number):
return self.json.sendJSONRequest("eth_blockByNumber", number)
# TODO: test
def transactionByHash(self, hash, index):
return self.json.sendJSONRequest("eth_transactionByHash", hash, index)
# Exception?
def transactionByNumber(self, number, index):
return self.json.sendJSONRequest("eth_transactionByNumber", number, index)
# TODO: test
def uncleByHash(self, hash, index):
return self.json.sendJSONRequest("eth_uncleByHash", hash, index)
def uncleByNumber(self, number, index):
return self.json.sendJSONRequest("eth_uncleByNumber", number, index)
def compilers(self):
return self.json.sendJSONRequest("eth_compilers")
# TODO: def lll():
def solidity(self, contract):
return self.json.sendJSONRequest("eth_solidity", contract)
# TODO: test when implemented in ethereum
#def serpent(contract):
# return self.json.sendJSONRequest("eth_serpent", contract)
# TODO: test
def newFilter(self, topic):
return self.json.sendJSONRequest("eth_newFilter", json.dumps({"topic":topic}))
# TODO: test
def newFilterString(self, string):
return self.json.sendJSONRequest("eth_newFilterString", string)
# TODO: test
def uninstallFilter(self, id):
return self.json.sendJSONRequest("eth_uninstallFilter", id)
def changed(self, id):
return self.json.sendJSONRequest("eth_changed", id)
def filterLogs(self, id):
return self.json.sendJSONRequest("eth_filterLogs", id)
def logs(self, topic):
return self.json.sendJSONRequest("eth_logs", json.dumps({"topic":topic}))
def getWork(self):
return self.json.sendJSONRequest("eth_getWork")
def submitWork(self, work):
return self.json.sendJSONRequest("eth_submitWork", work)