I've been reading a little about those web sites taht surreptitiously had Javascript running on the page that is mining cryptocurrency. How do those pieces of JS work code generally? Specifically

  1. Do all pieces of Javascript code report back to a central server which maintains a mining pool?

  2. Does each piece of code get a separate piece of work to do (and get assigned a different worker ID) so the malicious web site can mine faster?

  • You are talking about coinhive?
    – hardfork
    Commented Jan 25, 2018 at 19:48
  • Sure if that's a useful examples taht demonstrates the theory.
    – Dave
    Commented Jan 25, 2018 at 22:13

1 Answer 1


The web site doing this don't need to be considered malicious, the visitor could willing agree to do the mining in order to help it. Said that,

  1. Yes, they need to, to know the hash of the merkle tree of the block the pool is trying to mine. Otherwise they would have to download the blockchain in the browser themselves, and that would take hours or days. They also should somehow receive transactions to include in their blocks. Javascript running on a webpage can't typically comunicate with a cryptocurrency node directly, only via http requests to the same page domain.
  2. Yes, they also need to, otherwise they would be wasting CPU time doing the same work. For example, visitor A could receive instructions to compute hashes for a block X with nounces ranging from 0 to 15999, visitor B with nounces from 16000 to 31999 and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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