forked from vitaliy-kuzmich/bets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtruffle-support.js
36 lines (35 loc) · 1.6 KB
/
truffle-support.js
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
function getTransactionsByAccount(myaccount, startBlockNumber, endBlockNumber) {
if (endBlockNumber == null) {
endBlockNumber = eth.blockNumber;
console.log("Using endBlockNumber: " + endBlockNumber);
}
if (startBlockNumber == null) {
startBlockNumber = endBlockNumber - 1000;
console.log("Using startBlockNumber: " + startBlockNumber);
}
console.log("Searching for transactions to/from account \"" + myaccount + "\" within blocks " + startBlockNumber + " and " + endBlockNumber);
for (var i = startBlockNumber; i <= endBlockNumber; i++) {
if (i % 1000 == 0) {
console.log("Searching block " + i);
}
var block = eth.getBlock(i, true);
if (block != null && block.transactions != null) {
block.transactions.forEach( function(e) {
if (myaccount == "*" || myaccount == e.from || myaccount == e.to) {
console.log(" tx hash : " + e.hash + "\n"
+ " nonce : " + e.nonce + "\n"
+ " blockHash : " + e.blockHash + "\n"
+ " blockNumber : " + e.blockNumber + "\n"
+ " transactionIndex: " + e.transactionIndex + "\n"
+ " from : " + e.from + "\n"
+ " to : " + e.to + "\n"
+ " value : " + e.value + "\n"
+ " time : " + block.timestamp + " " + new Date(block.timestamp * 1000).toGMTString() + "\n"
+ " gasPrice : " + e.gasPrice + "\n"
+ " gas : " + e.gas + "\n"
+ " input : " + e.input);
}
})
}
}
}