etherscan-lite 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +3 -0
- data/README.md +146 -146
- data/lib/etherscan-lite/base.rb +64 -28
- data/lib/etherscan-lite/contract.rb +21 -0
- data/lib/etherscan-lite/misc.rb +48 -0
- data/lib/etherscan-lite/proxy.rb +46 -0
- data/lib/etherscan-lite/version.rb +1 -1
- data/lib/etherscan-lite.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edbdb29fdae2d064fbf9d6513b2747ecba5058ef8449d3e430c67be2a2aaa4da
|
4
|
+
data.tar.gz: febad888db3cf78c34e78f46ff09bea7555f2ad0ba030b6146172f5fab03e23d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a545c314b42eb7ed7531e79aac0b3a3d495cb3557fcd4f204421154f7b4a1742064552628045af78ff68573e69a44b4ba1e790461507ce26eed2b25990795f4
|
7
|
+
data.tar.gz: 5e66dd8e43960e491b0b2746a38dfeee2a37d6d1b5dfe5c62e1e1d9dd717f752c3973bbf1da4121ae4c7c58f8c87185f565e4ff45b259c0324c18f71383c4ec8
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -59,44 +59,44 @@ pp data
|
|
59
59
|
resulting in:
|
60
60
|
|
61
61
|
``` json
|
62
|
-
[{"blockNumber"
|
63
|
-
"timeStamp"
|
64
|
-
"hash"
|
65
|
-
"nonce"
|
66
|
-
"blockHash"
|
67
|
-
"from"
|
68
|
-
"contractAddress"
|
69
|
-
"to"
|
70
|
-
"value"
|
71
|
-
"tokenName"
|
72
|
-
"tokenSymbol"
|
73
|
-
"tokenDecimal"
|
74
|
-
"transactionIndex"
|
75
|
-
"gas"
|
76
|
-
"gasPrice"
|
77
|
-
"gasUsed"
|
78
|
-
"cumulativeGasUsed"
|
79
|
-
"input"
|
80
|
-
"confirmations"
|
81
|
-
{"blockNumber"
|
82
|
-
"timeStamp"
|
83
|
-
"hash"
|
84
|
-
"nonce"
|
85
|
-
"blockHash"
|
86
|
-
"from"
|
87
|
-
"contractAddress"
|
88
|
-
"to"
|
89
|
-
"value"
|
90
|
-
"tokenName"
|
91
|
-
"tokenSymbol"
|
92
|
-
"tokenDecimal"
|
93
|
-
"transactionIndex"
|
94
|
-
"gas"
|
95
|
-
"gasPrice"
|
96
|
-
"gasUsed"
|
97
|
-
"cumulativeGasUsed"
|
98
|
-
"input"
|
99
|
-
"confirmations"
|
62
|
+
[{"blockNumber": "16191306",
|
63
|
+
"timeStamp": "1671121931",
|
64
|
+
"hash": "0x77361870fdc3046f7c24cabafa7185a84d60f4fa12aef8363e8520fbdd003cc7",
|
65
|
+
"nonce": "4866500",
|
66
|
+
"blockHash": "0x1f5d2e10774bd5473257ad0f47d08b3e523e3baace6f0218bce8aab62e90ec67",
|
67
|
+
"from": "0xdfd5293d8e347dfe59e90efd55b2956a1343963d",
|
68
|
+
"contractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
69
|
+
"to": "0x40fbc37ff0e4d3f900b867f2ca48ae6aba77c854",
|
70
|
+
"value": "495264069",
|
71
|
+
"tokenName": "Tether USD",
|
72
|
+
"tokenSymbol": "USDT",
|
73
|
+
"tokenDecimal": "6",
|
74
|
+
"transactionIndex": "44",
|
75
|
+
"gas": "207128",
|
76
|
+
"gasPrice": "31567202036",
|
77
|
+
"gasUsed": "63197",
|
78
|
+
"cumulativeGasUsed": "5207555",
|
79
|
+
"input": "deprecated",
|
80
|
+
"confirmations": "3"},
|
81
|
+
{"blockNumber": "16191304",
|
82
|
+
"timeStamp": "1671121907",
|
83
|
+
"hash": "0xd3d529d0d420e38680ad9066a5d62434a04b01e94b00b81fc5fea303afbda076",
|
84
|
+
"nonce": "4866498",
|
85
|
+
"blockHash": "0x9b2dfbfd068c90546c7572bc059cd790e12eb6b9f9b21a3c7c33e0abd8d69d6c",
|
86
|
+
"from": "0xdfd5293d8e347dfe59e90efd55b2956a1343963d",
|
87
|
+
"contractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
88
|
+
"to": "0xf7140bb010da74a191e3c98f801e596937f177fb",
|
89
|
+
"value": "4496800000",
|
90
|
+
"tokenName": "Tether USD",
|
91
|
+
"tokenSymbol": "USDT",
|
92
|
+
"tokenDecimal": "6",
|
93
|
+
"transactionIndex": "57",
|
94
|
+
"gas": "207128",
|
95
|
+
"gasPrice": "32759178674",
|
96
|
+
"gasUsed": "46109",
|
97
|
+
"cumulativeGasUsed": "3775818",
|
98
|
+
"input": "deprecated",
|
99
|
+
"confirmations": "5"},
|
100
100
|
...
|
101
101
|
]
|
102
102
|
```
|
@@ -127,16 +127,16 @@ end
|
|
127
127
|
resulting in:
|
128
128
|
|
129
129
|
```
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
130
|
+
[0] 2022-12-15 16:32:11 UTC - Tether USD (USDT) 495.264069 (495264069) - from: 0xdfd5293d8 to: 0x40fbc37ff - txid: 0x7736187
|
131
|
+
[1] 2022-12-15 16:31:47 UTC - Tether USD (USDT) 4496.800000 (4496800000) - from: 0xdfd5293d8 to: 0xf7140bb01 - txid: 0xd3d529d
|
132
|
+
[2] 2022-12-15 16:31:11 UTC - Tether USD (USDT) 1496.800000 (1496800000) - from: 0xdfd5293d8 to: 0xcab0e46b1 - txid: 0x0b7986d
|
133
|
+
[3] 2022-12-15 16:31:11 UTC - Tether USD (USDT) 122.800000 (122800000) - from: 0xdfd5293d8 to: 0xcc38c0e6f - txid: 0x8894af7
|
134
|
+
[4] 2022-12-15 16:30:35 UTC - Tether USD (USDT) 22953.971400 (22953971400) - from: 0xdfd5293d8 to: 0xccb95ec69 - txid: 0x0bb6b75
|
135
|
+
[5] 2022-12-15 16:30:11 UTC - Tether USD (USDT) 254.743920 (254743920) - from: 0xdfd5293d8 to: 0x68f2a6311 - txid: 0xf691bed
|
136
|
+
[6] 2022-12-15 16:29:35 UTC - Tether USD (USDT) 548.950317 (548950317) - from: 0xdfd5293d8 to: 0xaa00cd50e - txid: 0x847854b
|
137
|
+
[7] 2022-12-15 16:29:11 UTC - Tether USD (USDT) 33667.697868 (33667697868) - from: 0xdfd5293d8 to: 0xcfb27a23f - txid: 0x7a2390d
|
138
|
+
[8] 2022-12-15 16:28:59 UTC - Tether USD (USDT) 48126.270731 (48126270731) - from: 0xdfd5293d8 to: 0x09857b83a - txid: 0x0653035
|
139
|
+
[9] 2022-12-15 16:28:35 UTC - Tether USD (USDT) 15996.800000 (15996800000) - from: 0xdfd5293d8 to: 0xd8d6ffe34 - txid: 0xb02d04b
|
140
140
|
```
|
141
141
|
|
142
142
|
|
@@ -156,44 +156,44 @@ pp data
|
|
156
156
|
resulting in:
|
157
157
|
|
158
158
|
``` json
|
159
|
-
[{"blockNumber"
|
160
|
-
"timeStamp"
|
161
|
-
"hash"
|
162
|
-
"nonce"
|
163
|
-
"blockHash"
|
164
|
-
"from"
|
165
|
-
"contractAddress"
|
166
|
-
"to"
|
167
|
-
"tokenID"
|
168
|
-
"tokenName"
|
169
|
-
"tokenSymbol"
|
170
|
-
"tokenDecimal"
|
171
|
-
"transactionIndex"
|
172
|
-
"gas"
|
173
|
-
"gasPrice"
|
174
|
-
"gasUsed"
|
175
|
-
"cumulativeGasUsed"
|
176
|
-
"input"
|
177
|
-
"confirmations"
|
178
|
-
{"blockNumber"
|
179
|
-
"timeStamp"
|
180
|
-
"hash"
|
181
|
-
"nonce"
|
182
|
-
"blockHash"
|
183
|
-
"from"
|
184
|
-
"contractAddress"
|
185
|
-
"to"
|
186
|
-
"tokenID"
|
187
|
-
"tokenName"
|
188
|
-
"tokenSymbol"
|
189
|
-
"tokenDecimal"
|
190
|
-
"transactionIndex"
|
191
|
-
"gas"
|
192
|
-
"gasPrice"
|
193
|
-
"gasUsed"
|
194
|
-
"cumulativeGasUsed"
|
195
|
-
"input"
|
196
|
-
"confirmations"
|
159
|
+
[{"blockNumber": "16191303",
|
160
|
+
"timeStamp": "1671121895",
|
161
|
+
"hash": "0xf049e3247e19e2eca1971f6daa38e7310bf2705b7da6347b9801122eef57f30e",
|
162
|
+
"nonce": "16348",
|
163
|
+
"blockHash": "0x2ec6abfc229cb61b7a851d9e078e93681634cf0b2b3390a54f6fa21e8d10cd04",
|
164
|
+
"from": "0x8ae57a027c63fca8070d1bf38622321de8004c67",
|
165
|
+
"contractAddress": "0x23581767a106ae21c074b2276d25e5c3e136a68b",
|
166
|
+
"to": "0xdc3276739390e3fdf7929056593d2ce316ebcfa8",
|
167
|
+
"tokenID": "2934",
|
168
|
+
"tokenName": "Moonbirds",
|
169
|
+
"tokenSymbol": "MOONBIRD",
|
170
|
+
"tokenDecimal": "0",
|
171
|
+
"transactionIndex": "150",
|
172
|
+
"gas": "168819",
|
173
|
+
"gasPrice": "30350829601",
|
174
|
+
"gasUsed": "64019",
|
175
|
+
"cumulativeGasUsed": "16664047",
|
176
|
+
"input": "deprecated",
|
177
|
+
"confirmations": "25"},
|
178
|
+
{"blockNumber": "16191297",
|
179
|
+
"timeStamp": "1671121823",
|
180
|
+
"hash": "0xb341b32b2c8904733c05648f67c09c99602a22b454f6f99b68746eb204c8f235",
|
181
|
+
"nonce": "4310",
|
182
|
+
"blockHash": "0x8774a12b660e59586ae94af1670362d2c73d09c94230f236859548ae0768f387",
|
183
|
+
"from": "0x8bc110db7029197c3621bea8092ab1996d5dd7be",
|
184
|
+
"contractAddress": "0x23581767a106ae21c074b2276d25e5c3e136a68b",
|
185
|
+
"to": "0x6ce2eb1c3006850ebbb97499f1a25b8ce6c01a44",
|
186
|
+
"tokenID": "9836",
|
187
|
+
"tokenName": "Moonbirds",
|
188
|
+
"tokenSymbol": "MOONBIRD",
|
189
|
+
"tokenDecimal": "0",
|
190
|
+
"transactionIndex": "15",
|
191
|
+
"gas": "3576346",
|
192
|
+
"gasPrice": "35958543341",
|
193
|
+
"gasUsed": "2751035",
|
194
|
+
"cumulativeGasUsed": "3999647",
|
195
|
+
"input": "deprecated",
|
196
|
+
"confirmations": "31"},
|
197
197
|
...
|
198
198
|
]
|
199
199
|
```
|
@@ -217,16 +217,16 @@ end
|
|
217
217
|
resulting in:
|
218
218
|
|
219
219
|
```
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
220
|
+
[0] 2022-12-15 16:31:35 UTC - Moonbirds 2934 - from: 0x8ae57a027 to: 0xdc3276739 - txid: 0xf049e32
|
221
|
+
[1] 2022-12-15 16:30:23 UTC - Moonbirds 9836 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
222
|
+
[2] 2022-12-15 16:30:23 UTC - Moonbirds 9378 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
223
|
+
[3] 2022-12-15 16:30:23 UTC - Moonbirds 9059 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
224
|
+
[4] 2022-12-15 16:30:23 UTC - Moonbirds 8199 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
225
|
+
[5] 2022-12-15 16:30:23 UTC - Moonbirds 7800 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
226
|
+
[6] 2022-12-15 16:30:23 UTC - Moonbirds 5952 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
227
|
+
[7] 2022-12-15 16:30:23 UTC - Moonbirds 5868 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
228
|
+
[8] 2022-12-15 16:30:23 UTC - Moonbirds 5853 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
229
|
+
[9] 2022-12-15 16:30:23 UTC - Moonbirds 501 - from: 0x8bc110db7 to: 0x6ce2eb1c3 - txid: 0xb341b32
|
230
230
|
```
|
231
231
|
|
232
232
|
|
@@ -249,46 +249,46 @@ resulting in:
|
|
249
249
|
|
250
250
|
|
251
251
|
``` json
|
252
|
-
[{"blockNumber"
|
253
|
-
"timeStamp"
|
254
|
-
"hash"
|
255
|
-
"nonce"
|
256
|
-
"blockHash"
|
257
|
-
"transactionIndex"
|
258
|
-
"from"
|
259
|
-
"to"
|
260
|
-
"value"
|
261
|
-
"gas"
|
262
|
-
"gasPrice"
|
263
|
-
"isError"
|
264
|
-
"txreceipt_status"
|
265
|
-
"input"
|
266
|
-
"contractAddress"
|
267
|
-
"cumulativeGasUsed"
|
268
|
-
"gasUsed"
|
269
|
-
"confirmations"
|
270
|
-
"methodId"
|
271
|
-
"functionName"
|
272
|
-
{"blockNumber"
|
273
|
-
"timeStamp"
|
274
|
-
"hash"
|
275
|
-
"nonce"
|
276
|
-
"blockHash"
|
277
|
-
"transactionIndex"
|
278
|
-
"from"
|
279
|
-
"to"
|
280
|
-
"value"
|
281
|
-
"gas"
|
282
|
-
"gasPrice"
|
283
|
-
"isError"
|
284
|
-
"txreceipt_status"
|
285
|
-
"input"
|
286
|
-
"contractAddress"
|
287
|
-
"cumulativeGasUsed"
|
288
|
-
"gasUsed"
|
289
|
-
"confirmations"
|
290
|
-
"methodId"
|
291
|
-
"functionName"
|
252
|
+
[{"blockNumber": "16191330",
|
253
|
+
"timeStamp": "1671122219",
|
254
|
+
"hash": "0xea692b153ec048322dd6dc0a42fba45a0f06b2bd0e6888c7e42edbc629689f00",
|
255
|
+
"nonce": "998",
|
256
|
+
"blockHash": "0x3c3a23b78fd1522f9f9ed5a1fc45d5a7d1d71327961c77d164c0eeb1e72b4322",
|
257
|
+
"transactionIndex": "244",
|
258
|
+
"from": "0xae4705dc0816ee6d8a13f1c72780ec5021915fed",
|
259
|
+
"to": "0x4dbd4fc535ac27206064b68ffcf827b0a60bab3f",
|
260
|
+
"value": "420690000000000000",
|
261
|
+
"gas": "92219",
|
262
|
+
"gasPrice": "26218969764",
|
263
|
+
"isError": "0",
|
264
|
+
"txreceipt_status": "1",
|
265
|
+
"input": "0x439370b1",
|
266
|
+
"contractAddress": "",
|
267
|
+
"cumulativeGasUsed": "18496407",
|
268
|
+
"gasUsed": "91261",
|
269
|
+
"confirmations": "16",
|
270
|
+
"methodId": "0x439370b1",
|
271
|
+
"functionName": "depositEth()"},
|
272
|
+
{"blockNumber": "16191327",
|
273
|
+
"timeStamp": "1671122183",
|
274
|
+
"hash": "0x8a82fc0e7ac1fb588f1ee248810d518bc03dfb4e938160c6502f949fcc16054c",
|
275
|
+
"nonce": "2",
|
276
|
+
"blockHash": "0xb533b2cd157369414839c58b74319bf32400dd6521b5d945eb7ac405d0600203",
|
277
|
+
"transactionIndex": "78",
|
278
|
+
"from": "0x338b8d83e644689a0ea90f04e0efa144fccfb3c7",
|
279
|
+
"to": "0x4dbd4fc535ac27206064b68ffcf827b0a60bab3f",
|
280
|
+
"value": "19000000000000000",
|
281
|
+
"gas": "92219",
|
282
|
+
"gasPrice": "29492008048",
|
283
|
+
"isError": "0",
|
284
|
+
"txreceipt_status": "1",
|
285
|
+
"input": "0x439370b1",
|
286
|
+
"contractAddress": "",
|
287
|
+
"cumulativeGasUsed": "7020870",
|
288
|
+
"gasUsed": "91261",
|
289
|
+
"confirmations": "19",
|
290
|
+
"methodId": "0x439370b1",
|
291
|
+
"functionName": "depositEth()"},
|
292
292
|
...
|
293
293
|
]
|
294
294
|
```
|
@@ -322,16 +322,16 @@ end
|
|
322
322
|
resulting in:
|
323
323
|
|
324
324
|
```
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
325
|
+
[0] 2022-12-15 16:36:59 UTC - depositEth() 0.420690000000000000 (420690000000000000) - from: 0xae4705dc0 to: 0x4dbd4fc53 - txid: 0xea692b1
|
326
|
+
[1] 2022-12-15 16:36:23 UTC - depositEth() 0.019000000000000000 (19000000000000000) - from: 0x338b8d83e to: 0x4dbd4fc53 - txid: 0x8a82fc0
|
327
|
+
[2] 2022-12-15 16:35:23 UTC - depositEth() 0.040000000000000000 (40000000000000000) - from: 0x63e1c7edc to: 0x4dbd4fc53 - txid: 0x46bc422
|
328
|
+
[3] 2022-12-15 16:34:23 UTC - depositEth() 0.003330000000000000 (3330000000000000) - from: 0xe29abe7f8 to: 0x4dbd4fc53 - txid: 0x2fbd49e
|
329
|
+
[4] 2022-12-15 16:34:23 UTC - depositEth() 0.022398548608559353 (22398548608559353) - from: 0x3dbcf6a3d to: 0x4dbd4fc53 - txid: 0xc311e3f
|
330
|
+
[5] 2022-12-15 16:32:23 UTC - depositEth() 0.195713000000000000 (195713000000000000) - from: 0xc7099c3ed to: 0x4dbd4fc53 - txid: 0x4a2f2e4
|
331
|
+
[6] 2022-12-15 16:31:23 UTC - depositEth() 0.100000000000000000 (100000000000000000) - from: 0x78cea29ac to: 0x4dbd4fc53 - txid: 0xedc3793
|
332
|
+
[7] 2022-12-15 16:28:35 UTC - depositEth() 2.406000000000000000 (2406000000000000000) - from: 0xa59192967 to: 0x4dbd4fc53 - txid: 0xde20917
|
333
|
+
[8] 2022-12-15 16:28:23 UTC - depositEth() 0.030000000000000000 (30000000000000000) - from: 0x03a64c941 to: 0x4dbd4fc53 - txid: 0xc813c01
|
334
|
+
[9] 2022-12-15 16:27:35 UTC - depositEth() 0.004000000000000000 (4000000000000000) - from: 0x614d071bf to: 0x4dbd4fc53 - txid: 0xb24df57
|
335
335
|
```
|
336
336
|
|
337
337
|
and so on.
|
data/lib/etherscan-lite/base.rb
CHANGED
@@ -2,56 +2,92 @@ module Etherscan
|
|
2
2
|
BASE = 'https://api.etherscan.io/api'
|
3
3
|
|
4
4
|
|
5
|
-
|
6
|
-
|
7
5
|
def self.call( src ) ## get response as (parsed) json (hash table)
|
8
|
-
uri = URI.parse( src )
|
9
|
-
|
10
|
-
http = Net::HTTP.new( uri.host, uri.port )
|
11
|
-
|
12
|
-
puts "[debug] GET #{uri.request_uri} uri=#{uri}"
|
13
6
|
|
14
7
|
headers = {
|
15
8
|
# 'User-Agent' => "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
|
16
9
|
'User-Agent' => "ruby v#{RUBY_VERSION}",
|
17
10
|
}
|
18
11
|
|
12
|
+
response = Webclient.get( src, headers: headers )
|
19
13
|
|
20
|
-
|
21
|
-
|
22
|
-
http.use_ssl = true
|
23
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
24
|
-
end
|
25
|
-
|
26
|
-
response = http.request( request )
|
27
|
-
|
28
|
-
if response.code == '200'
|
29
|
-
puts "#{response.code} #{response.message} - content_type: #{response.content_type}, content_length: #{response.content_length}"
|
14
|
+
if response.status.ok?
|
15
|
+
puts "#{response.status.code} #{response.status.message} - content_type: #{response.content_type}, content_length: #{response.content_length}"
|
30
16
|
|
31
|
-
|
32
|
-
text = text.force_encoding( Encoding::UTF_8 )
|
33
|
-
|
34
|
-
data = JSON.parse( text )
|
35
|
-
data
|
17
|
+
data = response.json
|
36
18
|
|
37
19
|
## note: "unwrap" result - and auto-check status/message e.g.
|
38
20
|
## {"status"=>"1",
|
39
21
|
## "message"=>"OK",
|
40
22
|
## "result"=> ..
|
41
23
|
## }
|
42
|
-
|
43
|
-
|
44
|
-
|
24
|
+
##
|
25
|
+
## An API call that encounters an error will return 0 as its status code and display the cause of the error under the result field.
|
26
|
+
## {
|
27
|
+
## "status":"0",
|
28
|
+
## "message":"NOTOK",
|
29
|
+
## "result":"Max rate limit reached, please use API Key for higher rate limit"
|
30
|
+
## }
|
31
|
+
|
32
|
+
##
|
33
|
+
# note: add special error handling case for no transaction found!!
|
34
|
+
# ==> [8] query 0x01c59869B44F3Fc5420dbB9166a735CdC020E9Ae...
|
35
|
+
# [debug] GET /api?module=account&action=txlist&address=...
|
36
|
+
# 200 OK - content_type: application/json, content_length: 172
|
37
|
+
# !! ETHERSCAN API ERROR:
|
38
|
+
# 0 No transactions found - []
|
39
|
+
|
40
|
+
if data['status'] == '0' && data['message'] == 'No transactions found' && data['result'].empty?
|
41
|
+
data['result']
|
42
|
+
elsif data['status'] == '1' && data['message'] == 'OK'
|
43
|
+
## puts "#{data['status']} #{data['message']}"
|
44
|
+
data['result']
|
45
45
|
else
|
46
46
|
puts "!! ETHERSCAN API ERROR:"
|
47
|
-
puts "#{data['status']} #{data['message']}"
|
47
|
+
puts "#{data['status']} #{data['message']} - #{data['result']}"
|
48
48
|
exit 1
|
49
49
|
end
|
50
50
|
else
|
51
|
-
puts "!! ERROR:"
|
52
|
-
puts "#{response.code} #{response.message}"
|
51
|
+
puts "!! HTTP ERROR:"
|
52
|
+
puts "#{response.status.code} #{response.status.message}"
|
53
53
|
exit 1
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
|
58
|
+
def self.proxy_call( src ) ## get response as (parsed) json (hash table)
|
59
|
+
|
60
|
+
headers = {
|
61
|
+
# 'User-Agent' => "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
|
62
|
+
'User-Agent' => "ruby v#{RUBY_VERSION}",
|
63
|
+
}
|
64
|
+
|
65
|
+
response = Webclient.get( src, headers: headers )
|
66
|
+
|
67
|
+
if response.status.ok?
|
68
|
+
puts "#{response.status.code} #{response.status.message} - content_type: #{response.content_type}, content_length: #{response.content_length}"
|
69
|
+
|
70
|
+
### check for {"jsonrpc"=>"2.0",
|
71
|
+
## "id"=>1,
|
72
|
+
## "result"=> ... }
|
73
|
+
data = response.json
|
74
|
+
## pp data
|
75
|
+
|
76
|
+
if data['result']
|
77
|
+
data['result']
|
78
|
+
elsif data['error']
|
79
|
+
puts "!! ETHERSCAN API (PROXY JSON-RPC) ERROR:"
|
80
|
+
puts "#{data['error']}"
|
81
|
+
exit 1
|
82
|
+
else
|
83
|
+
puts "!! ETHERSCAN API (PROXY JSON-RPC) ERROR:"
|
84
|
+
puts " No response on request"
|
85
|
+
exit 1
|
86
|
+
end
|
87
|
+
else
|
88
|
+
puts "!! HTTP ERROR:"
|
89
|
+
puts "#{response.status.code} #{response.status.message}"
|
90
|
+
exit 1
|
91
|
+
end
|
92
|
+
end
|
57
93
|
end # module Etherscan
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Etherscan
|
2
|
+
|
3
|
+
|
4
|
+
###
|
5
|
+
## Get Contract Creator and Creation Tx Hash
|
6
|
+
## Returns a contract's deployer address and transaction hash
|
7
|
+
## it was created, up to 5 at a time.
|
8
|
+
## see https://docs.etherscan.io/api-endpoints/contracts#get-contract-creator-and-creation-tx-hash
|
9
|
+
def self.getcontractcreation_url( contractaddresses: )
|
10
|
+
src = "#{BASE}?module=contract&action=getcontractcreation" +
|
11
|
+
"&contractaddresses=#{contractaddresses.join(',')}" +
|
12
|
+
"&apikey=#{config.key}"
|
13
|
+
src
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.getcontractcreation( **kwargs )
|
17
|
+
call( getcontractcreation_url( **kwargs ) )
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end # module Etherscan
|
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
module Etherscan
|
3
|
+
|
4
|
+
|
5
|
+
###############
|
6
|
+
# all-in-one helper for getting contract details
|
7
|
+
# note: requires (collects data via) three api calls
|
8
|
+
|
9
|
+
def self.getcontractdetails( contractaddress: )
|
10
|
+
|
11
|
+
delay_in_s = 0.5
|
12
|
+
puts " sleeping #{delay_in_s} sec(s)..."
|
13
|
+
sleep( delay_in_s )
|
14
|
+
data = getcontractcreation( contractaddresses: [contractaddress] )
|
15
|
+
## pp data
|
16
|
+
|
17
|
+
# [{"contractAddress"=>"0x16f5a35647d6f03d5d3da7b35409d65ba03af3b2",
|
18
|
+
# "contractCreator"=>"0xc352b534e8b987e036a93539fd6897f53488e56a",
|
19
|
+
# "txHash"=>"0xc82aa34310c310463eb9fe7835471f7317ac4b5008034a78c93b2a8a237be228"}]
|
20
|
+
|
21
|
+
## reuse hash from repsone - why? why not?
|
22
|
+
details = data[0]
|
23
|
+
|
24
|
+
puts " sleeping #{delay_in_s} sec(s)..."
|
25
|
+
sleep( delay_in_s )
|
26
|
+
data2 = gettransactionbyhash( txhash: details['txHash'] )
|
27
|
+
## puts
|
28
|
+
## pp data2
|
29
|
+
# {"blockHash"=>"0x07f9b4846ee2702da8d18b9eeead15912d977acc8886ab9bf5d760914cb37670",
|
30
|
+
# "blockNumber"=>"0x3f17d2",
|
31
|
+
# "from"=>"0xa97f8ffc8f8e354475880448334e4e99a0e7212f",
|
32
|
+
# "gas"=>"0x2c51d3",
|
33
|
+
# "gasPrice"=>"0x53c53dc33",
|
34
|
+
# "hash"=>"0x79d48c41b99f0ac8f735dbf4d048165542576862df2b05a80be9a4dbe233a623",
|
35
|
+
details['blockNumber'] = data2['blockNumber']
|
36
|
+
|
37
|
+
puts " sleeping #{delay_in_s} sec(s)..."
|
38
|
+
sleep( delay_in_s )
|
39
|
+
data3 = getblockbynumber( blocknumber: data2['blockNumber'] )
|
40
|
+
## puts
|
41
|
+
## pp data3
|
42
|
+
|
43
|
+
details['timestamp'] = data3['timestamp']
|
44
|
+
details
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end # module Etherscan
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
module Etherscan
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
###
|
7
|
+
## eth_getTransactionByHash
|
8
|
+
## Returns the information about a transaction requested
|
9
|
+
## by transaction hash.
|
10
|
+
## see https://docs.etherscan.io/api-endpoints/geth-parity-proxy#eth_gettransactionbyhash
|
11
|
+
|
12
|
+
def self.gettransactionbyhash_url( txhash: )
|
13
|
+
src = "#{BASE}?module=proxy&action=eth_getTransactionByHash" +
|
14
|
+
"&txhash=#{txhash}" +
|
15
|
+
"&apikey=#{config.key}"
|
16
|
+
src
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.gettransactionbyhash( **kwargs )
|
20
|
+
## note: requires proxy_call!!! - different return / response format in json!!
|
21
|
+
proxy_call( gettransactionbyhash_url( **kwargs ) )
|
22
|
+
end
|
23
|
+
|
24
|
+
#####
|
25
|
+
## eth_getBlockByNumber
|
26
|
+
## Returns information about a block by block number.
|
27
|
+
## see https://docs.etherscan.io/api-endpoints/geth-parity-proxy#eth_getblockbynumber
|
28
|
+
##
|
29
|
+
## the boolean value to show full transaction objects.
|
30
|
+
## when true, returns full transaction objects and their information,
|
31
|
+
## when false only returns a list of transactions.
|
32
|
+
def self.getblockbynumber_url( blocknumber:, transactions: false )
|
33
|
+
src = "#{BASE}?module=proxy&action=eth_getBlockByNumber" +
|
34
|
+
"&tag=#{blocknumber}" + ## note - must be a hexstring !!! e.g. 0x10d4f
|
35
|
+
"&boolean=#{transactions}" + ## " note:must be true or false
|
36
|
+
"&apikey=#{config.key}"
|
37
|
+
src
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.getblockbynumber( **kwargs )
|
41
|
+
## note: requires proxy_call!!! - different return / response format in json!!
|
42
|
+
proxy_call( getblockbynumber_url( **kwargs ) )
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end # module Etherscan
|
data/lib/etherscan-lite.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etherscan-lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocos
|
@@ -75,6 +75,9 @@ files:
|
|
75
75
|
- lib/etherscan-lite.rb
|
76
76
|
- lib/etherscan-lite/account.rb
|
77
77
|
- lib/etherscan-lite/base.rb
|
78
|
+
- lib/etherscan-lite/contract.rb
|
79
|
+
- lib/etherscan-lite/misc.rb
|
80
|
+
- lib/etherscan-lite/proxy.rb
|
78
81
|
- lib/etherscan-lite/version.rb
|
79
82
|
homepage: https://github.com/rubycocos/blockchain
|
80
83
|
licenses:
|