1

I am trying to get latest blocks data and gets all the transaction IDS inside the block and send that transaction IDS array to an api server. I am using this command in geth console :

 eth.filter('latest').watch(function(err, result){console.log(result)})

Is there a way in which a script will run 24/7 in geth console(get attach) and run the above command to get latest block data and send the transaction IDS array to an api server? Any ideas/help is greatly appreciated, Thanks!

3

Use --exec along with geth attach:

geth --exec "<code>" attach <target>

For more information and examples, including the execution of files (loading them from the specified code), see Non-interactive use: JSRE script mode.

1

You can directly run the JavaScript script under node VM. It will have the same execution context as geth attach that is effectively a JavaScript console

Examples (scroll to end):

https://tokenmarket.net/blog/creating-ethereum-smart-contract-transactions-in-client-side-javascript/

  • 1
    Thanks, I read the above link but i am not able to figure out how to run the above eth.filter command to check for each new block and then use a callback to send data to api , can you please give an example for the same – Farhan Feb 6 '18 at 8:56
  • 1
    I can tell you where to go to look for the answer, but I won't do your work for you. – Mikko Ohtamaa Feb 6 '18 at 9:29
  • no problem, i ask questions only when i am stuck, you are not doing my work. – Farhan Feb 6 '18 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.