I’m a software developer starting with blockchain/bitcoin programming.

I’ve mined with this piece of ruby code:

require 'digest'

target = '0000000'

block = '{"Name":"Pretty cool block","Nonce":"%s","Transactions":["OP_RETURN \'taxation is theft\'","OP_RETURN \'Imposto é roubo\'"]}'

nonce = 0

loop do

hash = Digest::SHA256.hexdigest(block % nonce.to_s)

if hash.start_with?(target)

puts "Block mined with nonce #{nonce}: #{hash}"

break

end

nonce += 1

puts "Trying with nonce (#{nonce})"

end

Reply to this note

Please Login to reply.

Discussion

No replies yet.