Blocks commit proposed transactions into the ledger. A transaction that do not appear on a valid block is not accepted by the network.
We use Blocks to commit proposed Transactions to the ledger in order to realize them.
transaction_list of the Block is filled with valid transactions.
In order to create a valid block, the proposer must find a suitable nonce value that makes the hash of the block valid.
The properties a valid hash should have will be explained in subsequent sections.
We are mining using blake2s algorithm, which produces 256-bit hashes. Hash/second is roughly 20x103 on my machine, a new block can be mined in around 4-6 minutes.
Requests
GET
A HTTP GET request to /block endpoint will return the latest mined block.
POST
A HTTP POST request with Authorization using JWT will allow you to propose your own blocks.
Fields
transaction_list: [array of Transaction IDs]
nonce: unsigned 32-bit integer
timestamp: ISO 8601 Timestamp (<date>T<time>)
hash: String
Coinbase
The proposer of the block is identified by the source of the first transaction in transaction_list.
This transaction is called the coinbase, and its source will get awarded by the block mining reward for their work.
The amount of the reward is determined by block_reward field of /config.
Place one of your own transactions as the first item in
transaction_list. Otherwise, the server will not be able to authenticate you.
Mining
The mining process for the hash involves;
- Creating a temporary JSON object with
transaction_list,nonce, andtimestampvalues - Serializing it
- NOTE: Serialized JSON must comply with the rules explained in hash section of transaction page.
- The order of keys should be as follows:
transaction_list,nonce,timestamp. - Example:
{"transaction_list":["a1a3","cde4","60e7","4e04"],"nonce":5342433,"timestamp":"2022-04-23T23:49:24.622651"}
- Calculating blake2s hash of the serialized string
- Checking if the hash is valid
- The hash is considered valid if its hexadecimal representation starts with an arbitrary number of zeros.
- This number is given by
hash_zerosfield of/config. - For instance, if
hash_zerosis 6, a valid hash must start with 6 hexadecimal zeros.
If the resulting hash is valid, then you can create a Block JSON object with the found nonce and hash.
Hash
tha field in jwt documentation stands for "The Hash" in the context of blocks.
Fill this with the hash value you found during the mining process.
Block Rules
- Blocks have to include a minimum number of transactions.
- Blocks cannot have duplicate transactions.
Gradecoin