web3 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generated_web3_methods.rb +389 -349
- data/lib/web3.rb +26 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580e8c735123564ea15894cbf75ab42be2451b22
|
4
|
+
data.tar.gz: 9b07d0cd09c9c798fe3ce79f2d59cbf1a4353c86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bc85f68a6ffef72f5819e5c58ce37c4eaa94c037705f4c4b02175084e6f15a9a1264c78e06a8f4cd3e0eb2dde9b580601ff862e52e79070b9ac7a46db8ef1e5
|
7
|
+
data.tar.gz: e0dff90efeff0e931faf48ccf88b8bff71da4d24164707d8cf0681a5ab84548f2ab2c535064a15457582de2f75011773b2bf2d734564ed154e3d880a03538ddc
|
@@ -1,349 +1,389 @@
|
|
1
|
-
module GeneratedWeb3Methods
|
2
|
-
|
3
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#web3_clientversion
|
4
|
-
def web3_clientVersion()
|
5
|
-
response = do_request("web3_clientVersion")
|
6
|
-
response["result"]
|
7
|
-
end
|
8
|
-
|
9
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#web3_sha3
|
10
|
-
def web3_sha3(data)
|
11
|
-
response = do_request("web3_sha3",[data])
|
12
|
-
response["result"]
|
13
|
-
end
|
14
|
-
|
15
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_version
|
16
|
-
def net_version()
|
17
|
-
response = do_request("net_version")
|
18
|
-
response["result"]
|
19
|
-
end
|
20
|
-
|
21
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_peercount
|
22
|
-
def net_peerCount()
|
23
|
-
response = do_request("net_peerCount")
|
24
|
-
to_decimal response["result"]
|
25
|
-
end
|
26
|
-
|
27
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_listening
|
28
|
-
def net_listening()
|
29
|
-
response = do_request("net_listening")
|
30
|
-
response["result"]
|
31
|
-
end
|
32
|
-
|
33
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_protocolversion
|
34
|
-
def eth_protocolVersion()
|
35
|
-
raise NotImplementedError.new "JSON-RPC call to eth_protocolVersion is not currently supported"
|
36
|
-
end
|
37
|
-
|
38
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_syncing
|
39
|
-
def eth_syncing()
|
40
|
-
response = do_request("eth_syncing")
|
41
|
-
response["result"]
|
42
|
-
end
|
43
|
-
|
44
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_coinbase
|
45
|
-
def eth_coinbase()
|
46
|
-
response = do_request("eth_coinbase")
|
47
|
-
response["result"]
|
48
|
-
end
|
49
|
-
|
50
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_mining
|
51
|
-
def eth_mining()
|
52
|
-
response = do_request("eth_mining")
|
53
|
-
response["result"]
|
54
|
-
end
|
55
|
-
|
56
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_hashrate
|
57
|
-
def eth_hashrate()
|
58
|
-
response = do_request("eth_hashrate")
|
59
|
-
to_decimal response["result"]
|
60
|
-
end
|
61
|
-
|
62
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gasprice
|
63
|
-
def eth_gasPrice()
|
64
|
-
response = do_request("eth_gasPrice")
|
65
|
-
to_decimal response["result"]
|
66
|
-
end
|
67
|
-
|
68
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_accounts
|
69
|
-
def eth_accounts()
|
70
|
-
response = do_request("eth_accounts")
|
71
|
-
response["result"]
|
72
|
-
end
|
73
|
-
|
74
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_blocknumber
|
75
|
-
def eth_blockNumber()
|
76
|
-
response = do_request("eth_blockNumber")
|
77
|
-
to_decimal response["result"]
|
78
|
-
end
|
79
|
-
|
80
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getbalance
|
81
|
-
def eth_getBalance(address, block = "latest")
|
82
|
-
response = do_request("eth_getBalance",[address, block])
|
83
|
-
to_decimal response["result"]
|
84
|
-
end
|
85
|
-
|
86
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getstorageat
|
87
|
-
def eth_getStorageAt(storage_address, position, block = "latest")
|
88
|
-
response = do_request("eth_getStorageAt",[storage_address, to_hex(position), block])
|
89
|
-
response["result"]
|
90
|
-
end
|
91
|
-
|
92
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactioncount
|
93
|
-
def eth_getTransactionCount(address, block = "latest")
|
94
|
-
response = do_request("eth_getTransactionCount",[address, block])
|
95
|
-
to_decimal response["result"]
|
96
|
-
end
|
97
|
-
|
98
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblocktransactioncountbyhash
|
99
|
-
def eth_getBlockTransactionCountByHash(data)
|
100
|
-
response = do_request("eth_getBlockTransactionCountByHash",[data])
|
101
|
-
to_decimal response["result"]
|
102
|
-
end
|
103
|
-
|
104
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblocktransactioncountbynumber
|
105
|
-
def eth_getBlockTransactionCountByNumber(block = "latest")
|
106
|
-
response = do_request("eth_getBlockTransactionCountByNumber",[block])
|
107
|
-
to_decimal response["result"]
|
108
|
-
end
|
109
|
-
|
110
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclecountbyblockhash
|
111
|
-
def eth_getUncleCountByBlockHash(data)
|
112
|
-
response = do_request("eth_getUncleCountByBlockHash",[data])
|
113
|
-
to_decimal response["result"]
|
114
|
-
end
|
115
|
-
|
116
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclecountbyblocknumber
|
117
|
-
def eth_getUncleCountByBlockNumber(data)
|
118
|
-
response = do_request("eth_getUncleCountByBlockNumber",[data])
|
119
|
-
to_decimal response["result"]
|
120
|
-
end
|
121
|
-
|
122
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcode
|
123
|
-
def eth_getCode(address, block = "latest")
|
124
|
-
response = do_request("eth_getCode",[address, block])
|
125
|
-
response["result"]
|
126
|
-
end
|
127
|
-
|
128
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
|
129
|
-
def eth_sign(address, data)
|
130
|
-
response = do_request("eth_sign",[address, data])
|
131
|
-
response["result"]
|
132
|
-
end
|
133
|
-
|
134
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction
|
135
|
-
def eth_sendTransaction(trans_object)
|
136
|
-
response = do_request("eth_sendTransaction",[trans_object])
|
137
|
-
response["result"]
|
138
|
-
end
|
139
|
-
|
140
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendrawtransaction
|
141
|
-
def eth_sendRawTransaction(data)
|
142
|
-
response = do_request("eth_sendRawTransaction",[data])
|
143
|
-
response["result"]
|
144
|
-
end
|
145
|
-
|
146
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call
|
147
|
-
def eth_call(trans_object,block)
|
148
|
-
response = do_request("eth_call",[trans_object, block])
|
149
|
-
response["result"]
|
150
|
-
end
|
151
|
-
|
152
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_estimategas
|
153
|
-
def eth_estimateGas(trans_object,block)
|
154
|
-
response = do_request("eth_estimateGas",[trans_object, block])
|
155
|
-
response["result"]
|
156
|
-
end
|
157
|
-
|
158
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbyhash
|
159
|
-
def eth_getBlockByHash(hash, full_transactions = true)
|
160
|
-
response = do_request("eth_getBlockByHash",[hash, full_transactions])
|
161
|
-
response["result"]
|
162
|
-
end
|
163
|
-
|
164
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber
|
165
|
-
def eth_getBlockByNumber(number, full_transactions = true)
|
166
|
-
response = do_request("eth_getBlockByNumber",[number, full_transactions])
|
167
|
-
response["result"]
|
168
|
-
end
|
169
|
-
|
170
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyhash
|
171
|
-
def eth_getTransactionByHash(hash)
|
172
|
-
response = do_request("eth_getTransactionByHash",[hash])
|
173
|
-
response["result"]
|
174
|
-
end
|
175
|
-
|
176
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyblockhashandindex
|
177
|
-
def eth_getTransactionByBlockHashAndIndex(hash, index)
|
178
|
-
response = do_request("eth_getTransactionByBlockHashAndIndex",[hash, index])
|
179
|
-
response["result"]
|
180
|
-
end
|
181
|
-
|
182
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyblocknumberandindex
|
183
|
-
def eth_getTransactionByBlockNumberAndIndex(number, index)
|
184
|
-
response = do_request("eth_getTransactionByBlockNumberAndIndex",[number, index])
|
185
|
-
response["result"]
|
186
|
-
end
|
187
|
-
|
188
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt
|
189
|
-
def eth_getTransactionReceipt(hash)
|
190
|
-
response = do_request("eth_getTransactionReceipt",[hash])
|
191
|
-
response["result"]
|
192
|
-
end
|
193
|
-
|
194
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclebyblockhashandindex
|
195
|
-
def eth_getUncleByBlockHashAndIndex(hash, index)
|
196
|
-
response = do_request("eth_getUncleByBlockHashAndIndex",[hash, index])
|
197
|
-
response["result"]
|
198
|
-
end
|
199
|
-
|
200
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclebyblocknumberandindex
|
201
|
-
def eth_getUncleByBlockNumberAndIndex(number, index)
|
202
|
-
response = do_request("eth_getUncleByBlockNumberAndIndex",[number, index])
|
203
|
-
response["result"]
|
204
|
-
end
|
205
|
-
|
206
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcompilers
|
207
|
-
def eth_getCompilers()
|
208
|
-
response = do_request("eth_getCompilers")
|
209
|
-
response["result"]
|
210
|
-
end
|
211
|
-
|
212
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilelll
|
213
|
-
def eth_compileLLL(code)
|
214
|
-
response = do_request("eth_compileLLL",[code])
|
215
|
-
response["result"]
|
216
|
-
end
|
217
|
-
|
218
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilesolidity
|
219
|
-
def eth_compileSolidity(code)
|
220
|
-
response = do_request("eth_compileSolidity",[code])
|
221
|
-
response["result"]
|
222
|
-
end
|
223
|
-
|
224
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compileserpent
|
225
|
-
def eth_compileSerpent(code)
|
226
|
-
response = do_request("eth_compileSerpent",[code])
|
227
|
-
response["result"]
|
228
|
-
end
|
229
|
-
|
230
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
|
231
|
-
def eth_newFilter(fromBlock, toBlock, address, topics)
|
232
|
-
response = do_request("$CODE",[fromBlock, toBlock, address, topics])
|
233
|
-
to_decimal response["result"]
|
234
|
-
end
|
235
|
-
|
236
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter
|
237
|
-
def eth_newBlockFilter()
|
238
|
-
response = do_request("eth_newBlockFilter")
|
239
|
-
to_decimal response["result"]
|
240
|
-
end
|
241
|
-
|
242
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter
|
243
|
-
def eth_newPendingTransactionFilter()
|
244
|
-
response = do_request("eth_newPendingTransactionFilter")
|
245
|
-
to_decimal response["result"]
|
246
|
-
end
|
247
|
-
|
248
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter
|
249
|
-
def eth_uninstallFilter(id)
|
250
|
-
response = do_request("eth_uninstallFilter",[id])
|
251
|
-
response["result"]
|
252
|
-
end
|
253
|
-
|
254
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
|
255
|
-
def eth_getFilterChanges(id)
|
256
|
-
response = do_request("eth_getFilterChanges",[id])
|
257
|
-
response["result"]
|
258
|
-
end
|
259
|
-
|
260
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
|
261
|
-
def eth_getFilterLogs(id)
|
262
|
-
response = do_request("eth_getFilterLogs",[id])
|
263
|
-
response["result"]
|
264
|
-
end
|
265
|
-
|
266
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs
|
267
|
-
def eth_getLogs(filter_obj)
|
268
|
-
response = do_request("eth_getLogs",[filter_obj])
|
269
|
-
response["result"]
|
270
|
-
end
|
271
|
-
|
272
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getwork
|
273
|
-
def eth_getWork()
|
274
|
-
response = do_request("eth_getWork")
|
275
|
-
response["result"]
|
276
|
-
end
|
277
|
-
|
278
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_submitwork
|
279
|
-
def eth_submitWork(nonce, powHash, mixDigest)
|
280
|
-
response = do_request("eth_submitWork",[nonce, powHash, mixDigest])
|
281
|
-
response["result"]
|
282
|
-
end
|
283
|
-
|
284
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_submithashrate
|
285
|
-
def eth_submitHashrate(hashrate, id)
|
286
|
-
response = do_request("eth_submitHashrate",[hashrate, id])
|
287
|
-
response["result"]
|
288
|
-
end
|
289
|
-
|
290
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_version
|
291
|
-
def shh_version()
|
292
|
-
response = do_request("shh_version")
|
293
|
-
response["result"]
|
294
|
-
end
|
295
|
-
|
296
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_post
|
297
|
-
def shh_post(post_object)
|
298
|
-
response = do_request("shh_post",[post_object])
|
299
|
-
response["result"]
|
300
|
-
end
|
301
|
-
|
302
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newidentity
|
303
|
-
def shh_newIdentity()
|
304
|
-
response = do_request("shh_newIdentity")
|
305
|
-
response["result"]
|
306
|
-
end
|
307
|
-
|
308
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_hasidentity
|
309
|
-
def shh_hasIdentity(address)
|
310
|
-
response = do_request("shh_hasIdentity",[address])
|
311
|
-
response["result"]
|
312
|
-
end
|
313
|
-
|
314
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newgroup
|
315
|
-
def shh_newGroup()
|
316
|
-
response = do_request("shh_newGroup")
|
317
|
-
response["result"]
|
318
|
-
end
|
319
|
-
|
320
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_addtogroup
|
321
|
-
def shh_addToGroup(address)
|
322
|
-
response = do_request("shh_addToGroup",[address])
|
323
|
-
response["result"]
|
324
|
-
end
|
325
|
-
|
326
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newfilter
|
327
|
-
def shh_newFilter(filter_object)
|
328
|
-
response = do_request("shh_newFilter",[filter_object])
|
329
|
-
to_decimal response["result"]
|
330
|
-
end
|
331
|
-
|
332
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_uninstallfilter
|
333
|
-
def shh_uninstallFilter(id)
|
334
|
-
response = do_request("shh_uninstallFilter",[id])
|
335
|
-
response["result"]
|
336
|
-
end
|
337
|
-
|
338
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_getfilterchanges
|
339
|
-
def shh_getFilterChanges(id)
|
340
|
-
response = do_request("shh_getFilterChanges",[id])
|
341
|
-
response["result"]
|
342
|
-
end
|
343
|
-
|
344
|
-
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_getmessages
|
345
|
-
def shh_getMessages(id)
|
346
|
-
response = do_request("shh_getMessages",[id])
|
347
|
-
response["result"]
|
348
|
-
end
|
349
|
-
|
1
|
+
module GeneratedWeb3Methods
|
2
|
+
|
3
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#web3_clientversion
|
4
|
+
def web3_clientVersion()
|
5
|
+
response = do_request("web3_clientVersion")
|
6
|
+
response["result"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#web3_sha3
|
10
|
+
def web3_sha3(data)
|
11
|
+
response = do_request("web3_sha3",[data])
|
12
|
+
response["result"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_version
|
16
|
+
def net_version()
|
17
|
+
response = do_request("net_version")
|
18
|
+
response["result"]
|
19
|
+
end
|
20
|
+
|
21
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_peercount
|
22
|
+
def net_peerCount()
|
23
|
+
response = do_request("net_peerCount")
|
24
|
+
to_decimal response["result"]
|
25
|
+
end
|
26
|
+
|
27
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_listening
|
28
|
+
def net_listening()
|
29
|
+
response = do_request("net_listening")
|
30
|
+
response["result"]
|
31
|
+
end
|
32
|
+
|
33
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_protocolversion
|
34
|
+
def eth_protocolVersion()
|
35
|
+
raise NotImplementedError.new "JSON-RPC call to eth_protocolVersion is not currently supported"
|
36
|
+
end
|
37
|
+
|
38
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_syncing
|
39
|
+
def eth_syncing()
|
40
|
+
response = do_request("eth_syncing")
|
41
|
+
response["result"]
|
42
|
+
end
|
43
|
+
|
44
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_coinbase
|
45
|
+
def eth_coinbase()
|
46
|
+
response = do_request("eth_coinbase")
|
47
|
+
response["result"]
|
48
|
+
end
|
49
|
+
|
50
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_mining
|
51
|
+
def eth_mining()
|
52
|
+
response = do_request("eth_mining")
|
53
|
+
response["result"]
|
54
|
+
end
|
55
|
+
|
56
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_hashrate
|
57
|
+
def eth_hashrate()
|
58
|
+
response = do_request("eth_hashrate")
|
59
|
+
to_decimal response["result"]
|
60
|
+
end
|
61
|
+
|
62
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gasprice
|
63
|
+
def eth_gasPrice()
|
64
|
+
response = do_request("eth_gasPrice")
|
65
|
+
to_decimal response["result"]
|
66
|
+
end
|
67
|
+
|
68
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_accounts
|
69
|
+
def eth_accounts()
|
70
|
+
response = do_request("eth_accounts")
|
71
|
+
response["result"]
|
72
|
+
end
|
73
|
+
|
74
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_blocknumber
|
75
|
+
def eth_blockNumber()
|
76
|
+
response = do_request("eth_blockNumber")
|
77
|
+
to_decimal response["result"]
|
78
|
+
end
|
79
|
+
|
80
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getbalance
|
81
|
+
def eth_getBalance(address, block = "latest")
|
82
|
+
response = do_request("eth_getBalance",[address, block])
|
83
|
+
to_decimal response["result"]
|
84
|
+
end
|
85
|
+
|
86
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getstorageat
|
87
|
+
def eth_getStorageAt(storage_address, position, block = "latest")
|
88
|
+
response = do_request("eth_getStorageAt",[storage_address, to_hex(position), block])
|
89
|
+
response["result"]
|
90
|
+
end
|
91
|
+
|
92
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactioncount
|
93
|
+
def eth_getTransactionCount(address, block = "latest")
|
94
|
+
response = do_request("eth_getTransactionCount",[address, block])
|
95
|
+
to_decimal response["result"]
|
96
|
+
end
|
97
|
+
|
98
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblocktransactioncountbyhash
|
99
|
+
def eth_getBlockTransactionCountByHash(data)
|
100
|
+
response = do_request("eth_getBlockTransactionCountByHash",[data])
|
101
|
+
to_decimal response["result"]
|
102
|
+
end
|
103
|
+
|
104
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblocktransactioncountbynumber
|
105
|
+
def eth_getBlockTransactionCountByNumber(block = "latest")
|
106
|
+
response = do_request("eth_getBlockTransactionCountByNumber",[block])
|
107
|
+
to_decimal response["result"]
|
108
|
+
end
|
109
|
+
|
110
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclecountbyblockhash
|
111
|
+
def eth_getUncleCountByBlockHash(data)
|
112
|
+
response = do_request("eth_getUncleCountByBlockHash",[data])
|
113
|
+
to_decimal response["result"]
|
114
|
+
end
|
115
|
+
|
116
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclecountbyblocknumber
|
117
|
+
def eth_getUncleCountByBlockNumber(data)
|
118
|
+
response = do_request("eth_getUncleCountByBlockNumber",[data])
|
119
|
+
to_decimal response["result"]
|
120
|
+
end
|
121
|
+
|
122
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcode
|
123
|
+
def eth_getCode(address, block = "latest")
|
124
|
+
response = do_request("eth_getCode",[address, block])
|
125
|
+
response["result"]
|
126
|
+
end
|
127
|
+
|
128
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
|
129
|
+
def eth_sign(address, data)
|
130
|
+
response = do_request("eth_sign",[address, data])
|
131
|
+
response["result"]
|
132
|
+
end
|
133
|
+
|
134
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction
|
135
|
+
def eth_sendTransaction(trans_object)
|
136
|
+
response = do_request("eth_sendTransaction",[trans_object])
|
137
|
+
response["result"]
|
138
|
+
end
|
139
|
+
|
140
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendrawtransaction
|
141
|
+
def eth_sendRawTransaction(data)
|
142
|
+
response = do_request("eth_sendRawTransaction",[data])
|
143
|
+
response["result"]
|
144
|
+
end
|
145
|
+
|
146
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call
|
147
|
+
def eth_call(trans_object,block)
|
148
|
+
response = do_request("eth_call",[trans_object, block])
|
149
|
+
response["result"]
|
150
|
+
end
|
151
|
+
|
152
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_estimategas
|
153
|
+
def eth_estimateGas(trans_object,block)
|
154
|
+
response = do_request("eth_estimateGas",[trans_object, block])
|
155
|
+
response["result"]
|
156
|
+
end
|
157
|
+
|
158
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbyhash
|
159
|
+
def eth_getBlockByHash(hash, full_transactions = true)
|
160
|
+
response = do_request("eth_getBlockByHash",[hash, full_transactions])
|
161
|
+
response["result"]
|
162
|
+
end
|
163
|
+
|
164
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber
|
165
|
+
def eth_getBlockByNumber(number, full_transactions = true)
|
166
|
+
response = do_request("eth_getBlockByNumber",[number, full_transactions])
|
167
|
+
response["result"]
|
168
|
+
end
|
169
|
+
|
170
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyhash
|
171
|
+
def eth_getTransactionByHash(hash)
|
172
|
+
response = do_request("eth_getTransactionByHash",[hash])
|
173
|
+
response["result"]
|
174
|
+
end
|
175
|
+
|
176
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyblockhashandindex
|
177
|
+
def eth_getTransactionByBlockHashAndIndex(hash, index)
|
178
|
+
response = do_request("eth_getTransactionByBlockHashAndIndex",[hash, index])
|
179
|
+
response["result"]
|
180
|
+
end
|
181
|
+
|
182
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyblocknumberandindex
|
183
|
+
def eth_getTransactionByBlockNumberAndIndex(number, index)
|
184
|
+
response = do_request("eth_getTransactionByBlockNumberAndIndex",[number, index])
|
185
|
+
response["result"]
|
186
|
+
end
|
187
|
+
|
188
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt
|
189
|
+
def eth_getTransactionReceipt(hash)
|
190
|
+
response = do_request("eth_getTransactionReceipt",[hash])
|
191
|
+
response["result"]
|
192
|
+
end
|
193
|
+
|
194
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclebyblockhashandindex
|
195
|
+
def eth_getUncleByBlockHashAndIndex(hash, index)
|
196
|
+
response = do_request("eth_getUncleByBlockHashAndIndex",[hash, index])
|
197
|
+
response["result"]
|
198
|
+
end
|
199
|
+
|
200
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclebyblocknumberandindex
|
201
|
+
def eth_getUncleByBlockNumberAndIndex(number, index)
|
202
|
+
response = do_request("eth_getUncleByBlockNumberAndIndex",[number, index])
|
203
|
+
response["result"]
|
204
|
+
end
|
205
|
+
|
206
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcompilers
|
207
|
+
def eth_getCompilers()
|
208
|
+
response = do_request("eth_getCompilers")
|
209
|
+
response["result"]
|
210
|
+
end
|
211
|
+
|
212
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilelll
|
213
|
+
def eth_compileLLL(code)
|
214
|
+
response = do_request("eth_compileLLL",[code])
|
215
|
+
response["result"]
|
216
|
+
end
|
217
|
+
|
218
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilesolidity
|
219
|
+
def eth_compileSolidity(code)
|
220
|
+
response = do_request("eth_compileSolidity",[code])
|
221
|
+
response["result"]
|
222
|
+
end
|
223
|
+
|
224
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compileserpent
|
225
|
+
def eth_compileSerpent(code)
|
226
|
+
response = do_request("eth_compileSerpent",[code])
|
227
|
+
response["result"]
|
228
|
+
end
|
229
|
+
|
230
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
|
231
|
+
def eth_newFilter(fromBlock, toBlock, address, topics)
|
232
|
+
response = do_request("$CODE",[fromBlock, toBlock, address, topics])
|
233
|
+
to_decimal response["result"]
|
234
|
+
end
|
235
|
+
|
236
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter
|
237
|
+
def eth_newBlockFilter()
|
238
|
+
response = do_request("eth_newBlockFilter")
|
239
|
+
to_decimal response["result"]
|
240
|
+
end
|
241
|
+
|
242
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter
|
243
|
+
def eth_newPendingTransactionFilter()
|
244
|
+
response = do_request("eth_newPendingTransactionFilter")
|
245
|
+
to_decimal response["result"]
|
246
|
+
end
|
247
|
+
|
248
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter
|
249
|
+
def eth_uninstallFilter(id)
|
250
|
+
response = do_request("eth_uninstallFilter",[id])
|
251
|
+
response["result"]
|
252
|
+
end
|
253
|
+
|
254
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
|
255
|
+
def eth_getFilterChanges(id)
|
256
|
+
response = do_request("eth_getFilterChanges",[id])
|
257
|
+
response["result"]
|
258
|
+
end
|
259
|
+
|
260
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
|
261
|
+
def eth_getFilterLogs(id)
|
262
|
+
response = do_request("eth_getFilterLogs",[id])
|
263
|
+
response["result"]
|
264
|
+
end
|
265
|
+
|
266
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs
|
267
|
+
def eth_getLogs(filter_obj)
|
268
|
+
response = do_request("eth_getLogs",[filter_obj])
|
269
|
+
response["result"]
|
270
|
+
end
|
271
|
+
|
272
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getwork
|
273
|
+
def eth_getWork()
|
274
|
+
response = do_request("eth_getWork")
|
275
|
+
response["result"]
|
276
|
+
end
|
277
|
+
|
278
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_submitwork
|
279
|
+
def eth_submitWork(nonce, powHash, mixDigest)
|
280
|
+
response = do_request("eth_submitWork",[nonce, powHash, mixDigest])
|
281
|
+
response["result"]
|
282
|
+
end
|
283
|
+
|
284
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_submithashrate
|
285
|
+
def eth_submitHashrate(hashrate, id)
|
286
|
+
response = do_request("eth_submitHashrate",[hashrate, id])
|
287
|
+
response["result"]
|
288
|
+
end
|
289
|
+
|
290
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_version
|
291
|
+
def shh_version()
|
292
|
+
response = do_request("shh_version")
|
293
|
+
response["result"]
|
294
|
+
end
|
295
|
+
|
296
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_post
|
297
|
+
def shh_post(post_object)
|
298
|
+
response = do_request("shh_post",[post_object])
|
299
|
+
response["result"]
|
300
|
+
end
|
301
|
+
|
302
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newidentity
|
303
|
+
def shh_newIdentity()
|
304
|
+
response = do_request("shh_newIdentity")
|
305
|
+
response["result"]
|
306
|
+
end
|
307
|
+
|
308
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_hasidentity
|
309
|
+
def shh_hasIdentity(address)
|
310
|
+
response = do_request("shh_hasIdentity",[address])
|
311
|
+
response["result"]
|
312
|
+
end
|
313
|
+
|
314
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newgroup
|
315
|
+
def shh_newGroup()
|
316
|
+
response = do_request("shh_newGroup")
|
317
|
+
response["result"]
|
318
|
+
end
|
319
|
+
|
320
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_addtogroup
|
321
|
+
def shh_addToGroup(address)
|
322
|
+
response = do_request("shh_addToGroup",[address])
|
323
|
+
response["result"]
|
324
|
+
end
|
325
|
+
|
326
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newfilter
|
327
|
+
def shh_newFilter(filter_object)
|
328
|
+
response = do_request("shh_newFilter",[filter_object])
|
329
|
+
to_decimal response["result"]
|
330
|
+
end
|
331
|
+
|
332
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_uninstallfilter
|
333
|
+
def shh_uninstallFilter(id)
|
334
|
+
response = do_request("shh_uninstallFilter",[id])
|
335
|
+
response["result"]
|
336
|
+
end
|
337
|
+
|
338
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_getfilterchanges
|
339
|
+
def shh_getFilterChanges(id)
|
340
|
+
response = do_request("shh_getFilterChanges",[id])
|
341
|
+
response["result"]
|
342
|
+
end
|
343
|
+
|
344
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_getmessages
|
345
|
+
def shh_getMessages(id)
|
346
|
+
response = do_request("shh_getMessages",[id])
|
347
|
+
response["result"]
|
348
|
+
end
|
349
|
+
|
350
|
+
# For web3 personal api - not activated by default in geth
|
351
|
+
def personal_listAccounts()
|
352
|
+
response = do_request("personal_listAccounts")
|
353
|
+
response["result"]
|
354
|
+
end
|
355
|
+
|
356
|
+
# For web3 personal api - not activated by default in geth
|
357
|
+
def personal_importRawKey(key, passphrase)
|
358
|
+
response = do_request("personal_importRawKey",[key, passphrase])
|
359
|
+
response["result"]
|
360
|
+
end
|
361
|
+
|
362
|
+
# For web3 personal api - not activated by default in geth
|
363
|
+
def personal_newAccount(password)
|
364
|
+
response = do_request("personal_newAccount",[password])
|
365
|
+
response["result"]
|
366
|
+
end
|
367
|
+
|
368
|
+
# For web3 personal api - not activated by default in geth
|
369
|
+
def personal_signAndSendTransaction(transaction, passphrase)
|
370
|
+
response = do_request("personal_signAndSendTransaction",[transaction, passphrase])
|
371
|
+
response["result"]
|
372
|
+
end
|
373
|
+
|
374
|
+
# For web3 personal api - not activated by default in geth
|
375
|
+
def personal_lockAccount(account)
|
376
|
+
response = do_request("personal_lockAccount",[account])
|
377
|
+
response["result"]
|
378
|
+
end
|
379
|
+
|
380
|
+
|
381
|
+
# For web3 personal api
|
382
|
+
# Be careful with this method. Do not leave an account unlocked, as that creates
|
383
|
+
# an opportunity for an attacker to make transactions from that account. In general
|
384
|
+
# personal_signAndSendTransaction is a better option than unlock -> send -> lock
|
385
|
+
def personal_unlockAccount(account, passphrase, duration)
|
386
|
+
response = do_request("personal_unlockAccount",[account, passphrase, duration])
|
387
|
+
response["result"]
|
388
|
+
end
|
389
|
+
end
|
data/lib/web3.rb
CHANGED
@@ -76,12 +76,37 @@ class Web3
|
|
76
76
|
decimal.to_s(16)
|
77
77
|
end
|
78
78
|
|
79
|
+
def to_0x(decimal)
|
80
|
+
"0x" + to_hex(decimal)
|
81
|
+
end
|
82
|
+
|
79
83
|
def wei_to_ether(wei)
|
80
84
|
1.0 * wei / 10**18
|
81
85
|
end
|
82
86
|
|
83
87
|
def ether_to_wei(ether)
|
84
|
-
ether * 10**18
|
88
|
+
(ether * 10**18).round()
|
89
|
+
end
|
90
|
+
|
91
|
+
def ether_to_0xwei(ether)
|
92
|
+
to_0x(ether_to_wei(ether))
|
93
|
+
end
|
94
|
+
|
95
|
+
# Convenience function to simply send ether from one account to another, using
|
96
|
+
# the default gas settings.
|
97
|
+
# This requires the personal api to be active. See https://github.com/ethereum/go-ethereum/wiki/Management-APIs
|
98
|
+
def sendEther(from_address, to_address, ether, password)
|
99
|
+
trans = {}
|
100
|
+
trans["from"] = from_address
|
101
|
+
trans["to"] = to_address
|
102
|
+
trans["value"] = ether_to_0xwei(ether)
|
103
|
+
# if gas != nil
|
104
|
+
# trans["gas"] = to_hex(gas) #should this to_hex or to_0x?
|
105
|
+
# end
|
106
|
+
# if gasPrice != nil
|
107
|
+
# trans["gasPrice"] = to_hex(gasPrice)
|
108
|
+
# end
|
109
|
+
personal_signAndSendTransaction(trans, password)
|
85
110
|
end
|
86
111
|
|
87
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanna-nouveau
|