Genesis Block Creator

19 replies 481 views
Humbl3M4xiFull Member
Posts: 52 · Reputation: 408
#1Mar 7, 2025, 02:44 PM
So the title might be a bit off, I haven't actually figured out the genesis block calculations yet. Just wanted to let you know that I'm not really a great programmer. I started messing with C back in 2011 when I was mining and playing around with cgminer and nonces. I never bothered to crack open a book on C, so most of what I learned has been through trial and error. Honestly, it's kind of like trying to drive a car for a decade without actually knowing what you’re doing. Don’t expect top-notch code from me. I probably did some things in a very inefficient way or just plain wrong since I'm not sure how to do them better. You can check out the code here http://pastebin.com/nhuuV7y9, it's written in pure C. No binaries since that would be a bit tricky. The code uses OpenSSL, but since you'll need it anyway for Bitcoin, I don't think it’ll be a big deal. *Genesis Block finder is included. Some downsides: the program is set up for just one input and one output, so if you want to create a merkle hash like Freicoin’s with multiple inputs and outputs, this program won’t work for that. It assumes a reward of 50 coins, but that’s easy to tweak in the code. Probably the biggest issue is that I can easily recreate the Bitcoin merkle hash, but when I tried testing it with Litecoin's timestamp message, it didn't work. It’s likely an issue with Unicode. I won't lie, I understand Unicode and ASCII even less than C.
2 Reply Quote Share
greg2021Member
Posts: 7 · Reputation: 81
#2Mar 7, 2025, 03:41 PM
Wow, it's been made.
0 Reply Quote Share
Posts: 11 · Reputation: 109
#3Mar 7, 2025, 08:23 PM
Interesting, the Litecoin genesis block seems to have a Unicode "smart quote" (fancier apostrophe) encoded in UTF-8.  With my console configured for UTF-8 encoding, this seems to work to reproduce the LTC genesis tx: (Notice "Apple’s" as opposed to "Apple's")  This seems to correspond with the genesis tx at this block explorer.  Cool, thanks OP! (Also, this timestsamp may work in bash without terminal settings: "`echo -en NY Times 05/Oct/2011 Steve Jobs, Apple\\\\xE2\\\\x80\\\\x99s Visionary, Dies at 56`")
0 Reply Quote Share
Humbl3M4xiFull Member
Posts: 52 · Reputation: 408
#4Mar 7, 2025, 11:30 PM
I am glad it works for you. But a lot of users, me included are on Windows.
0 Reply Quote Share
Posts: 2 · Reputation: 89
#5Mar 8, 2025, 03:36 AM
http://www.evanjones.ca/unicode-in-c.html But you can also just pass it as binary by converting it to hex reading from a UTF-8 file containing the string...
4 Reply Quote Share
Humbl3M4xiFull Member
Posts: 52 · Reputation: 408
#6Mar 8, 2025, 01:24 PM
I was able to implement the block hashing part, will clean it up and release later.
3 Reply Quote Share
Humbl3M4xiFull Member
Posts: 52 · Reputation: 408
#7Mar 9, 2025, 07:23 PM
I have updated the code with block hashing to find a genesis block. If you need to specify custom nonce and unixtime(to re-create a block from some chain), you will have to edit the source. http://pastebin.com/nhuuV7y9
0 Reply Quote Share
humbleorbitFull Member
Posts: 56 · Reputation: 402
#8Mar 11, 2025, 01:15 AM
I tried your program with bitcoin's parameters: Why I don't get the same genesis hash as in the bitcoin program? Do I look at the wrong place?
3 Reply Quote Share
Posts: 11 · Reputation: 109
#9Mar 11, 2025, 06:01 AM
It looks like you've got a linebreak/space in the first argument.  I noticed this in OP's post too, if I double click the first argument it stops highlighting halfway through.  If I drag-select the whole thing and paste it somewhere, there's a space.  So, make sure you don't have any space between "bc3f" and "4cef".
4 Reply Quote Share
humbleorbitFull Member
Posts: 56 · Reputation: 402
#10Mar 11, 2025, 09:18 AM
I retried, still the same, no space or line-break in between... it's weird why it is not match.
2 Reply Quote Share
Humbl3M4xiFull Member
Posts: 52 · Reputation: 408
#11Mar 11, 2025, 11:44 PM
It's because the nonce and unixtime are different. For bitcoin, it's unixtime = 1231006505 and nonce = 2083236893 I will have to rework the program a bit and start working with switches for better control and/or parsing the data from a file.
1 Reply Quote Share
humbleorbitFull Member
Posts: 56 · Reputation: 402
#12Mar 12, 2025, 12:45 AM
OK got it. Nice, with these as initial value the genesis block come out immediately: Nice program!
2 Reply Quote Share
RogueMinerFull Member
Posts: 58 · Reputation: 306
#13Mar 12, 2025, 05:52 AM
Little help please: Thanks!!!
2 Reply Quote Share
laser07Newbie
Posts: 1 · Reputation: 26
#14Mar 12, 2025, 10:30 AM
How can I determine the first block as a checkpoint if I can't mine? Or can I mine without checkpoints?
2 Reply Quote Share
byte2019Senior Member
Posts: 270 · Reputation: 1836
#15Mar 12, 2025, 01:08 PM
nice job. Ill need to add a hard drive to my pc to store all the new block chains that will be coming out
4 Reply Quote Share
Posts: 1 · Reputation: 20
#16Mar 12, 2025, 02:50 PM
For future reference, you need to include the libraries in the command:
2 Reply Quote Share
Humbl3M4xiFull Member
Posts: 52 · Reputation: 408
#17Mar 12, 2025, 06:25 PM
Bumping this thread for anyone that might want to make MORE sha256 alt coins.
1 Reply Quote Share
wallet88Newbie
Posts: 1 · Reputation: 16
#18Mar 12, 2025, 11:04 PM
Subbed
4 Reply Quote Share
bit2017Senior Member
Posts: 278 · Reputation: 1886
#19Mar 13, 2025, 03:36 AM
hi, I downloaded(link in 1st post) & compiled under windows(mingw) & try to get the genesis block. Unable to get: Please advise. Thanks.
0 Reply Quote Share
Humbl3M4xiFull Member
Posts: 52 · Reputation: 408
#20Mar 13, 2025, 05:39 AM
You need to preset the UNIX time variable and nonce to match the ones there, otherwise it will find a different one.
5 Reply Quote Share

Related topics