Skip to content

Instantly share code, notes, and snippets.

@lukem512
Created May 12, 2017 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukem512/be79ffbf0c5e19cad24be372a146ef3e to your computer and use it in GitHub Desktop.
Save lukem512/be79ffbf0c5e19cad24be372a146ef3e to your computer and use it in GitHub Desktop.
Computes cryptocurrency distribution
// Tool for working out cryptocurrency distribution rates
// Luke Mitchell, 2014
#include "stdlib.h"
#include "stdio.h"
int main (int argc, char** argv) {
printf ("Cryptodistribution tool\n");
printf ("=======================\n\n");
double reward = 40; // initial block reward (subsidy)
double reduction = 0.50; // % reduction
double supply = 42000000; // initial supply
//double min_subsidy = 1.0; // minimum subsidy (usually 0.00000001)
double min_subsidy = 0.00000001; // minimum subsidy (usually 0.00000001)
printf ("Using initial reward of %f\n", reward);
if (reduction != 0.5) printf ("Using reduction of %f\n", reduction);
if (min_subsidy != 0.00000001) printf ("Using minimum reward of %f\n", min_subsidy);
double block_time_minutes = 1; // block time in minutes
double blocks_per_hour = 60 / block_time_minutes;
double blocks_per_day = blocks_per_hour * 24;
double blocks_per_week = blocks_per_day * 7;
double blocks_per_month = blocks_per_day * 30;
double blocks_per_year = blocks_per_day * 365;
int blocks_per_reduction = 1 * blocks_per_year; // subsidy reduces
printf("Using %d blocks per reduction\n\n", blocks_per_reduction);
// some more stats
printf ("Initial mining rate will be approximately %f coins/day\n\n", blocks_per_day*reward);
int i = 0;
printf ("Step\tReward\t\tTotal supply\n");
while (reward >= min_subsidy) {
// add supply for step
supply = supply + (reward * blocks_per_reduction);
// print
printf("%d\t%.8f\t%.8f\n", i, reward, supply);
// reduce reward for next step
reward = reward - (reward * reduction);
// increase step counter
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment