<p>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,</p>

<ol>
<li>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. </li>
<li>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.</li>
</ol>

CC BY-SA 3.0
2018-02-12T00:08:20.963Z
2018-02-12T00:08:20.963Z
Osias Jota
<p>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</p>

<ol>
<li><p>Do all pieces of Javascript code report back to a central server which maintains a mining pool?</p></li>
<li><p>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?</p></li>
</ol>

CC BY-SA 3.0
2018-01-25T19:48:15.537Z
You are talking about coinhive?
hardfork
CC BY-SA 3.0
2018-01-25T22:13:37.700Z
Sure if that's a useful examples taht demonstrates the theory.
Dave
<transactions><mining-pools><mining-theory><javascript>
How does a mining pool coordinate with different Javascript clients?
Dave
# How does a mining pool coordinate with different Javascript clients?

(Asked by: username_0 on 2018-01-25)

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?

**Tags:** transactions, mining-pools, mining-theory, javascript

> **Comments:**
> **username_1**: You are talking about coinhive?  
> **username_0**: Sure if that's a useful examples taht demonstrates the theory.  

---

## 1 answers

### Answer by username_2 on 2018-02-12. Score: 1 | Accepted answer

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.


---

