From 14227912d567d51f62eab3ac408d574266dbe7d0 Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 29 Apr 2019 09:27:59 +0900 Subject: [PATCH] add some scripts --- .gitignore | 2 ++ scripts/accounts.js | 5 +++++ scripts/getTransactionCount.js | 12 ++++++++++++ scripts/totalTransactions.js | 11 +++++++++++ 4 files changed, 30 insertions(+) create mode 100644 scripts/accounts.js create mode 100644 scripts/getTransactionCount.js create mode 100644 scripts/totalTransactions.js diff --git a/.gitignore b/.gitignore index 7d04ba6..78562a6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ .idea yarn-error.log .envrc +/scripts/mint.js # tmp file. .node-xmlhttprequest* +tmp* diff --git a/scripts/accounts.js b/scripts/accounts.js new file mode 100644 index 0000000..32ac2e1 --- /dev/null +++ b/scripts/accounts.js @@ -0,0 +1,5 @@ +import { web3 } from './helper'; + +const accounts = web3.eth.accounts; + +console.log(accounts.length) diff --git a/scripts/getTransactionCount.js b/scripts/getTransactionCount.js new file mode 100644 index 0000000..062e568 --- /dev/null +++ b/scripts/getTransactionCount.js @@ -0,0 +1,12 @@ +import { web3 } from './helper'; + +const address = process.argv[2]; +if (!address) { + console.log('No block_number'); + process.exit(); +} + + +web3.eth.getTransactionCount(address, (error, count) => { + console.log(count); +}); diff --git a/scripts/totalTransactions.js b/scripts/totalTransactions.js new file mode 100644 index 0000000..8375021 --- /dev/null +++ b/scripts/totalTransactions.js @@ -0,0 +1,11 @@ +import { web3 } from './helper'; + +const accounts = web3.eth.accounts; + +for (let i = 0; i < accounts.length; i++) { + web3.eth.getTransactionCount(accounts[i], (error, count) => { + console.log(count); + }); +} + +// yarn babel-node scripts/totalTransactions.js | sum