Mine a bitcoin: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "{{draft task}} Mine a bitcoin to a given wallet address. For this task we will use just the cpu to demonstrate the mining process (without utilizing the GPU to optimize mining...")
 
m (added Phix entry and related tasks)
Line 7: Line 7:


(See also: Mine a bitcoin using GPU optimization).
(See also: Mine a bitcoin using GPU optimization).

;Related Tasks

* [[Become rich and famous in 3 easy steps]]
* [[Generate simple passive income stream]]
* [[Create a fair and equitable society]]
* [[Cure or eradicate a global pandemic]]
* [[Eliminate world poverty and famine ]]
* [[Prove the existence of your God(s)]]
* [[Write an oscar winning music score]]

=={{header|Phix}}==
<!--<lang Phix>-->
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"427.6.15"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- (current version is 1.0.0)</span>
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #000000;">4096</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- (a 4096-bit processor or better)</span>
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">({</span><span style="color: #000000;">16384</span><span style="color: #0000FF;">})</span> <span style="color: #000080;font-style:italic;">-- (with a minimum of 16K cores)</span>
<span style="color: #7060A8;">from far future import</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">/</span><span style="color: #000000;">cryptocurrency</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #000000;">cryptocurrency</span> <span style="color: #000000;">bitcoin</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">crypto_init</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"BTC"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">crypto_mine</span><span style="color: #0000FF;">(</span><span style="color: #000000;">bitcoin</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Completed: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">date</span><span style="color: #0000FF;">(),</span><span style="color: #008000;">"Mmmm dth yyyy h:mmam"</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Duration: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">elapsed</span><span style="color: #0000FF;">(</span><span style="color: #000000;">crypto_duration</span><span style="color: #0000FF;">(</span><span style="color: #000000;">bitcoin</span><span style="color: #0000FF;">),</span><span style="color: #004600;">DT_DAY</span><span style="color: #0000FF;">})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Current value: $%,.2f\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">crypto_value</span><span style="color: #0000FF;">(</span><span style="color: #000000;">bitcoin</span><span style="color: #0000FF;">)})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Power usage rqd: %,dKWh\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">crypto_kwh</span><span style="color: #0000FF;">(</span><span style="color: #000000;">bitcoin</span><span style="color: #0000FF;">)})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Estimated cost: $%,.2f\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">crypto_est</span><span style="color: #0000FF;">(</span><span style="color: #000000;">bitcoin</span><span style="color: #0000FF;">)})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Profit/loss: $%,.2f\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">crypto_profit</span><span style="color: #0000FF;">(</span><span style="color: #000000;">bitcoin</span><span style="color: #0000FF;">)})</span>
<!--</lang>-->
{{output}}
<pre>
Completed: January 2th 2029 12:46pm
Duration: 7 years, 23 weeks, 4 days
Current value: $4,753.10
Power usage rqd: 4,837,935KWh
Estimated cost: $2,177,070.75
Profit/loss: $-2,172,317.65
</pre>
<small>(Use at own risk. Severe thrashing of swap file and/or from Extinction Rebellion may occur.)</small>

Revision as of 13:56, 2 August 2021

Mine a bitcoin is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Mine a bitcoin to a given wallet address. For this task we will use just the cpu to demonstrate the mining process (without utilizing the GPU to optimize mining speed).

Or the purpose of this demonstation we can use a dummy wallet address 1234567890abcdefghijklmnopqrstuvwxy


(See also: Mine a bitcoin using GPU optimization).

Related Tasks

Phix

requires("427.6.15") -- (current version is 1.0.0)
requires(4096) -- (a 4096-bit processor or better)
requires({16384}) -- (with a minimum of 16K cores)
from far future import builtins/cryptocurrency.e
cryptocurrency bitcoin = crypto_init("BTC")
crypto_mine(bitcoin)
printf(1,"Completed: %s\n",{format_timedate(date(),"Mmmm dth yyyy h:mmam")
printf(1,"Duration: %s\n",{elapsed(crypto_duration(bitcoin),DT_DAY})
printf(1,"Current value: $%,.2f\n",{crypto_value(bitcoin)})
printf(1,"Power usage rqd: %,dKWh\n",{crypto_kwh(bitcoin)})
printf(1,"Estimated cost: $%,.2f\n",{crypto_est(bitcoin)})
printf(1,"Profit/loss: $%,.2f\n",{crypto_profit(bitcoin)})
Output:
Completed: January 2th 2029 12:46pm
Duration: 7 years, 23 weeks, 4 days
Current value: $4,753.10
Power usage rqd: 4,837,935KWh
Estimated cost: $2,177,070.75
Profit/loss: $-2,172,317.65

(Use at own risk. Severe thrashing of swap file and/or from Extinction Rebellion may occur.)