<blockquote>
<p><strong>is it possible to get bitcoins using your own custom code?</strong></p>
</blockquote>
<p>Yes, the software (&quot;code&quot;) would be what Bitcoin folk called a miner back when software and a CPU or GPU was all you needed. Nowadays you would need to write custom code that works with custom or commercial ASIC hardware.</p>
<blockquote>
<p><strong>Is it possible to get a hash somewhere ...</strong></p>
</blockquote>
<p>That's not how Bitcoin mining works. You need to create block template, set the value of an arbitary &quot;nonce&quot; and then <em>calculate</em> the hash of this block data. Then vary the nonce and repeat until you find a nonce value that leads to a block hash whose value is less than the current target value.</p>
<p>You need to be listening to the Bitcoin network using the Bitcoin network protocols in order to collect information needed to construct a new block. This would include the hash of the currently latest block, the network target and other items. Optionally you would maintain a pool of pending transactions you might want to include in a block.</p>
<p>Part of the block data you create is a &quot;coinbase&quot; transaction of your own devising that pays to an address of your choice the block-reward plus total of transaction fees of any pending transactions you included in the block.</p>
<p>That constitutes mining a block.</p>
<p>Nowadays you'd typically use a mining-pool network protocol to work as part of a mining pool. If you have huge financial resources and can buy immense numbers of ASICs you might not need to be part of a pool.</p>
<blockquote>
<p><strong>... come up with a solution on my own, and then submit the solution somewhere?</strong></p>
</blockquote>
<p>Once you have mined a new block you use Bitcoin network protocol to notify a few bitcoin nodes (peers) that you have new block data. You find those peers using the Bitcoin peer-discovery process.</p>
<p>If your block is acceptable, you can spend your coinbase output anytime after 100 other blocks have been mined using your block as an ancestor.</p>

CC BY-SA 4.0
2022-02-06T21:48:10.817Z
I must have used the wrong terms, I mean the target value you speak off, how do you get that one? Basically I thought finding the hash for a given target value sounded like an interesting problem. There should be other ways to solve that problem than just random trials.
Emil
CC BY-SA 4.0
2022-02-07T01:01:08.207Z
See https://en.bitcoin.it/wiki/Difficulty. There should NOT be other ways to solve that problem or Bitcoin is dead and much of cryptography too.
RedGrittyBrick
CC BY-SA 4.0
2022-02-07T06:48:39.683Z
It is has happened before that if you don't tell the student it is hard they will find the solution if you give it as homework. I don't understand why I need anything else than the target, does it have to be linked to the latest block somehow?
Emil
CC BY-SA 4.0
2022-02-07T12:49:36.207Z
It is true that if you find a way to force hash collisions you may become famous or even wealthy. However I suggest: 1) formulate a simple question. 2) search here for that question. 3) if not already asked and answered, use the "ask question" button. 4) goto 1.
RedGrittyBrick
CC BY-SA 4.0
2022-02-07T14:41:23.983Z
Okay. I don't understand your answer but it seems I didn't understand my question either so I guess I'll accept it.
Emil
CC BY-SA 4.0
2022-02-06T21:25:55.737Z
2022-02-06T21:41:39.633Z
2022-02-06T21:41:39.633Z
RedGrittyBrick
<p>is it possible to get bitcoins using your own custom code? Is it possible to get a hash somewhere, come up with a solution on my own, and then submit the solution somewhere? I just thought the puzzle part of bitcoin sounded fun, I don't want to have some other person's solver running on my machine.</p>

<api>
Where do you get work and submit solutions?
Emil
# Where do you get work and submit solutions?

(Asked by: username_0 on 2022-02-06)

is it possible to get bitcoins using your own custom code? Is it possible to get a hash somewhere, come up with a solution on my own, and then submit the solution somewhere? I just thought the puzzle part of bitcoin sounded fun, I don't want to have some other person's solver running on my machine.

**Tags:** api


---

## 1 answers

### Answer by username_1 on 2022-02-06. Score: 2 | Accepted answer

> **is it possible to get bitcoins using your own custom code?**

Yes, the software ("code") would be what Bitcoin folk called a miner back when software and a CPU or GPU was all you needed. Nowadays you would need to write custom code that works with custom or commercial ASIC hardware.

> **Is it possible to get a hash somewhere ...**

That's not how Bitcoin mining works. You need to create block template, set the value of an arbitary "nonce" and then *calculate* the hash of this block data. Then vary the nonce and repeat until you find a nonce value that leads to a block hash whose value is less than the current target value.

You need to be listening to the Bitcoin network using the Bitcoin network protocols in order to collect information needed to construct a new block. This would include the hash of the currently latest block, the network target and other items. Optionally you would maintain a pool of pending transactions you might want to include in a block.

Part of the block data you create is a "coinbase" transaction of your own devising that pays to an address of your choice the block-reward plus total of transaction fees of any pending transactions you included in the block.

That constitutes mining a block.

Nowadays you'd typically use a mining-pool network protocol to work as part of a mining pool. If you have huge financial resources and can buy immense numbers of ASICs you might not need to be part of a pool.

> **... come up with a solution on my own, and then submit the solution somewhere?**

Once you have mined a new block you use Bitcoin network protocol to notify a few bitcoin nodes (peers) that you have new block data. You find those peers using the Bitcoin peer-discovery process.

If your block is acceptable, you can spend your coinbase output anytime after 100 other blocks have been mined using your block as an ancestor.

> **Comments:**
> **username_0**: I must have used the wrong terms, I mean the target value you speak off, how do you get that one? Basically I thought finding the hash for a given target value sounded like an interesting problem. There should be other ways to solve that problem than just random trials.  
> **username_1**: See https://en.bitcoin.it/wiki/Difficulty. There should NOT be other ways to solve that problem or Bitcoin is dead and much of cryptography too.  
> **username_0**: It is has happened before that if you don't tell the student it is hard they will find the solution if you give it as homework. I don't understand why I need anything else than the target, does it have to be linked to the latest block somehow?  
> **username_1**: It is true that if you find a way to force hash collisions you may become famous or even wealthy. However I suggest: 1) formulate a simple question. 2) search here for that question. 3) if not already asked and answered, use the "ask question" button. 4) goto 1.  
> **username_0**: Okay. I don't understand your answer but it seems I didn't understand my question either so I guess I'll accept it.  

---

