ethereum-docker icon indicating copy to clipboard operation
ethereum-docker copied to clipboard

Add support for running arbritary scripts against the nodes

Open tayzlor opened this issue 9 years ago • 1 comments

For example (the below script) -

i = 0;
while (i < eth.accounts.length) {
  account = eth.accounts[i];
  balance = web3.fromWei(eth.getBalance(account), "ether");
  console.log("Account: " + account);
  console.log("Balance: " + balance + '\n');
  i++;
}

Can be run like -

docker exec -it bootstrap geth --datadir=~/.ethereum/devchain --jspath "/tmp/scripts" --exec 'loadScript("getAccountBalances.js")' attach

Should wrap this up to make it a bit easier to consume and less convoluted

tayzlor avatar Apr 28 '16 10:04 tayzlor

@tayzlor Here's what I got

# Use loadScript
npm run exec -- 'loadScript("/src/helloworld.js")'

# Or just load
JS=./src/helloworld.js npm run load

More at https://github.com/katopz/ethereum-docker#to-run-external-javascript-file

Want me to PR? :)

katopz avatar Oct 26 '17 11:10 katopz