Categories
All Posts

What is a Market Maker?

Definition: A market maker (or liquidity provider) is a person or program which buys and sells tokens and securities. In contrast to “normal” traders a market maker is always available for buying or selling. Its purpose is to provide permanently liquidity and allow other traders to buy and sell at a market price.

Categories
All Posts Posts

How to Calculate a Bitcoin Block Hash Manually

In this post we describe how to calculate an verify a Bitcoin block hash manually. We need to follow five easy steps to calculate the block hash.

If you want to try it out, you can use our online bitcoin block hash calculator.

Input Values of a Bitcoin Block Hash

But before we start with the calculation we take a look at the input values.

The SHA-256 hash function takes six inputs in order to calculate the block hash.

Input Explanation
Version Tells us the block version number. Is also used to participate in polls about protocol changes
Previous Block Hash (hashPrevBlock) 256-bit hash of the previous block header
Merkle Root hash (hashMerkleRoot) 256-bit hash of the Merkle root. The Merkle root is based on all transactions in a block.
Time Block timestamp as seconds since 1970-01-01T00:00 UTC
Bits (difficulty) Target to be met by the block hash
Nonce 32-bit number used to find the correct block hash in PoW

Where to get the data from?

Blockchain data are public. If you install a node you will be able to request the data from your node.

But there are also public services called block explorers which provide the data. Here is a list of block explorers you can use:

  • com
  • https://www.blockchain.com/explorer

However, there is on caveat. The format in which the data are provided can be pretty messy. Some block explorers display the data in hex values others in decimal values. This requires a little cleanup before the actual calculation can begin. Some block explorers even give imprecise data like a truncated date without the seconds.

We take example data from the block number 600,000.

Input Value (original) Value in hexadecimal
Version 0x20000000 0x20000000
Previous Block Hash (hashPrevBlock) 00000000000000000003ecd827f336c6971f6f77a0b9fba362398dd867975645 00000000000000000003ecd827f336c6971f6f77a0b9fba362398dd867975645
Merkle Root hash (hashMerkleRoot) 66b7c4a1926b41ceb2e617ddae0067e7bfea42db502017fde5b695a50384ed26 66b7c4a1926b41ceb2e617ddae0067e7bfea42db502017fde5b695a50384ed26
Time 2019-10-19 02:04:21 as timestamp: 1571443461 0x5DAA5305
Bits (difficulty) 0x1715a35c 0x1715a35c
Nonce 0x3f93ada7 0x3f93ada7

Step 1: Converting into little-endian

All values need to be converted into little-endian hex format. Usually block explorers or hex calculators provide the data in big-endian. Little-endian means that the least significant byte is on the left side. (In big-endian it is on the right side)

big-endian to little-endian

Input Value in little-endian hexadecimal
Version 00000020
Previous Block Hash (hashPrevBlock) 45569767D88D3962A3FBB9A0776F1F97C636F327D8EC03000000000000000000
Merkle Root hash (hashMerkleRoot) 26ED8403A595B6E5FD172050DB42EABFE76700AEDD17E6B2CE416B92A1C4B766
Time 0x0553AA5D
Bits (difficulty) 0x5CA31517
Nonce 0xA7AD933F

Input data from Bitcoin block 600000.

Step 2: Concatenation

The next step is to concatenate all little-endian formatted hash values in the right order. The symbol || means concatenation. As result we receive our rawHex.

rawHex = Version || Previous Block Hash || Merkle Root hash || Time || Bits || Nonce

rawHex = 0000002045569767d88d3962a3fbb9a0776f1f97c636f327d8ec0300000000000000000026ed8403a595b6e5fd172050db42eabfe76700aedd17e6b2ce416b92a1c4b7660553aa5d5ca31517a7ad933f

Step 3: Convert into bits

The concatenated hash value now needs to be converted into binary format. Most hash calculators and libraries distinguish between string inputs and hexadecimal inputs.

Let us consider an example.

The string “2c” would have a binary representation of 0011001001100011. This is derived from the ASCII table.

Character 2 c
Binary ASCII representation 00110010 01100011

If we interpret “2c” as hexadecimal value its binary representation would be: 101100. And this is exactly what we need.

This step is usually done internal with many hash libraries. The resulting binary number of our rawHex would be too large to display here.

Step 4: Apply SHA-256 twice

On our bit representation of the rawHex we apply the SHA-256 now twice. This means, we first calculate the SHA-256 of the binary representation of our rawHex and then take the result (again as binary) and input it into our SHA-256 function again.

2 x SHA-256: 915fcd96d1c84298a8fbfb9c13a9f7b4760e9056683107000000000000000000

Step 5: Convert to little-endian

The last step is to convert the output of the last step into little endian hexadecimal format. Once this is done, we have your block hash.

00000000000000000007316856900e76b4f7a9139cfbfba89842c8d196cd5f91

Pitfalls when calculating a Bitcoin block hash

If you want to calculate or verify a Bitcoin block hash manually, you need to take care of the format of your input values.

Version: The version can be given as 1, 2, 0x00000002, 0x20000000, or in different values. If the version is given as decimal values like 1 or 2 it needs to be converted into a padded hexadecimal value first (0x00000002). If it is given as hex-value like this 0x20000000, it can be used as input value right away (it still needs to be converted to little-endian thought).

Date: make sure you use the correct date. Some browsers might give you wrong date values, because they apply the wrong time zone. And some block explorers cut off the seconds from their dates.

Further links

Another explanation can be found here and here.

Categories
All Posts Tools

Bitcoin Block Hash Verification Tool

Here, you can play around with calculating and verifying a Bitcoin block hash. Simply enter all necessary data and get the block hash calculated.

You can find the values in a block explorer like this here.

A detailed explanation on how a Bitcoin block hash is calculated can be found here.

Categories
All Posts

Ethereum Smart Contract User Interface

With this user interface for Ethereum you an easily interact with smart contracts. Simply copy the ABI and the contract address into the respective fields, click “read ABI” and start interacting. You need a Ethereum connection like MetaMask.

Categories
All Posts

Storage vs. Memory vs. Stack in Solidity & Ethereum

In this article we focus on the difference between storage, memory, and stack in Ethereum. We will also give a Solidity code sample and calculation examples.

Categories
All Posts Tools

Bitcoin Difficulty & Target Calculator

This calculator converts the bit value into the target.

Bit as hexadecimal number:
Coefficient:
Index:
Target as hexadecimal with padding:
Target as hexadecimal:
Target as decimal number:
Difficulty as decimal number:

An extensive explanation of the Bitcoin difficulty and how target, difficulty and bits are related can be found in this article: Bitcoin difficulty and Target

Categories
All Posts

Bitcoin Mining Difficulty & Target

Definition: The Bitcoin mining difficulty defines how hard it is to mine a new block. In average it takes ten minutes to mine a block.

A general explanation of the mining difficulty can be found here: There are two values we need to consider:

Categories
All Posts

Mining Difficulty Blockchain

Definition: The mining difficulty determines how long it takes in average (number of attempts) to find a suitable input set that results in a valid hash output in order to mine a block. Usually miners (in PoW) or block creators (PoS) are required to find a hash below a certain target.

Categories
All Posts Uncategorised

Block Reward – Blockchain

Block Reward Definition

The block reward in a blockchain is the payment a miner or block creator receives, if he finds a valid block (see mining). In Proof of Work systems it is also called mining reward.

The block reward serves as a remuneration of the miner or block creator for its work. It is therefore part of the incentive structure to keep the network safe.

Categories
All Posts

Blockchain & Bitcoin Mining

Explanation: Bitcoin Mining is the process of creating new coins while validating transactions and creating blocks. This is usually done by a proof of work (PoW) algorithm. But there are also other algorithms like proof of stake (PoS), delegated proof of Stake, proof of capacity (PoC), proof of elapsed time (PoET), etc.