Block
JSON Model
NOTE: This is the base json model in the BRS Transaction class. The API contains additional fields that will be discussed on the API page.
The fields are listed here in the order they are seen in the BRS software. However, json does not require them in this order, so long as they are present.
- Version
- Key:
version
- Value Datatype:
number
- Key:
- Timestamp
- Key:
timestamp
- Value Datatype:
number
- Key:
- Previous Block ID
- Key:
previousBlock
- Value Datatype:
string
(Unsigned 64 bit integer
asString
)
- Key:
- Total Amount of Signa in NQT
- Key:
totalAmountNQT
- Value Datatype:
number
- Key:
- Total Fee in NQT
- Key:
totalFeeNQT
- Value Datatype:
number
- Key:
- Payload Length
- Key:
payloadLength
- Value Datatype:
number
- Key:
- Payload Hash
- Key:
payloadHash
- Value Datatype:
string
(Hex encoded bytes)
- Key:
- Generator Public Key
- Key:
generatorPublicKey
- Value Datatype:
string
(Hex encoded bytes)
- Key:
- Generation Signature
- Key:
generationSignature
- Value Datatype:
string
(Hex encoded bytes)
- Key:
- Previous Block Hash
- Only if block version > 1
- Key:
previousBlockHash
- Value Datatype:
string
(Hex encoded bytes)
- Block Signature
- Key:
blockSignature
- Value Datatype:
string
(Hex encoded bytes)
- Key:
- Transactions
- Key:
transactions
- Value Datatype:
array of object
(See Transaction)
- Key:
- Nonce
- Key:
nonce
- Value Datatype:
string
(Unsigned 64 bit integer
asString
)
- Key:
- Base Target
- Key:
baseTarget
- Value Datatype:
string
(Unsigned 64 bit integer
asString
)
- Key:
- Block ATs
- Key:
blockATs
- Value Datatype:
string
(Hex encoded bytes)
- Key:
Structure of Bytes Representation
Here is the list of fields that should exist on a block in memory to properly create the hash and forge the block.
Notes about the structure:
- The byte order must be Little Endian.
- The bytes must be directly concatenated in a single large buffer.
- The length of the buffer will change depending on the block version and if any ATs are added.
- There are additional fields related to blocks that do not get included in this, but are necessary to store. See the database structures.
- Block Version Number
- Datatype:
Signed 32 bit integer
- What block version this block is. As the protocol and data evolve with newer versions of the software, this will increment.
- Current version:
3
- Datatype:
- Timestamp
- Datatype:
Signed 32 bit integer
- The time this block was forged, based on the start of the blockchain at 11 August 2014, Time: 02:00:00.
- TODO: Add the format of this timestamp
- Datatype:
- Previous Block ID
- Datatype:
Signed 64 bit integer
- The first 8 bytes of the previous block hash converted into a number.
- TODO: Add the datatype of the number
- Datatype:
- Total amount of Signa
- Block version < 3
- Datatype:
Signed 32 bit integer
- Value: total amount of NQT / 100000000
- Datatype:
- Block version >= 3
- Datatype:
Signed 64 bit integer
- Value: total amount of NQT
- Datatype:
- The sum of the coins sent in transactions in this block.
- Block version < 3
- Total amount of Fees charged
- Block version < 3
- Datatype:
Signed 32 bit integer
- Value: total amount of NQT / 100000000
- Datatype:
- Block version >= 3
- Datatype:
Signed 64 bit integer
- Value: total amount of NQT
- Datatype:
- The sum of the fees charged for messages, transactions, and smart contracts running in this block.
- This amount goes to the account that forged this block.
- Block version < 3
- Length of Payload
- Datatype:
Signed 32 bit integer
- The total number of bytes of the entire payload field.
- Datatype:
- Payload Hash
- Datatype:
32 raw bytes
- A SHA-256 hash of all the data in this block's payload field.
- Datatype:
- Forger Public Key
- Datatype:
32 raw bytes
- The public key of the account that forged this block.
- Datatype:
- Generation Signature
- Datatype:
32 raw bytes
- The 32-byte generation signature used to forge this block.
- Datatype:
- Previous Block Hash
- Block version > 1
- Datatype:
32 raw bytes
- The SHA-256 hash of the contents of the previous block.
- Nonce
- Datatype:
Signed 64 bit integer
- The nonce number used to forge this block.
- TODO: Define this better
- Datatype:
- AT Bytes
- Datatype:
Raw bytes, length of AT
- The bytes of an AT that may be present in this block
- Optional
- TODO: Rename this field maybe and reword its description
- Datatype:
- Block Signature
- Datatype:
64 raw bytes
- A hash generated from the forger's private key and the block contents.
- Datatype:
Database Fields in BRS
NOTE: THIS SECTION IS INCOMPLETE.
This is a list of the fields seen in the node database along with their database built-in datatypes. This is unlikely to change with versions of the node unless a new block version is debuted.
-
Database ID
- Field name:
db_id
- Data type:
BIGINT
- Field name:
-
Block ID
- Field name:
id
- Data type:
BIGINT
- Field name:
-
Version
- Field name:
version
- Data type:
INTEGER
- Field name:
-
Timestamp
- Field name:
timestamp
- Data type:
INTEGER
- Field name:
-
Previous Block ID
- Field name:
previous_block_id
- Data type:
INTEGER
- Field name:
-
Total Amount
- Field name:
total_amount
- Data type:
BIGINT
- Field name:
-
Total Fee
- Field name:
total_fee
- Data type:
BIGINT
- Field name:
-
Payload Length
- Field name:
payload_length
- Data type:
INTEGER
- Field name:
-
Generator Public Key
- Field name:
generator_public_key
- Data type:
VARBINARY
- Field name:
-
Previous Block Hash
- Field name:
previous_block_hash
- Data type:
VARBINARY
- Field name:
-
Cumulative Difficulty
- Field name:
cumulative_difficulty
- Data type:
VARBINARY
- Field name:
-
Base Target
- Field name:
base_target
- Data type:
BIGINT
- Field name:
-
Next Block ID
- Field name:
next_block_id
- Data type:
BIGINT
- Field name:
-
Height
- Field name:
height
- Data type:
INTEGER
- Field name:
-
Generation Signature
- Field name:
generation_signature
- Data type:
VARBINARY
- Field name:
-
Block Signature
- Field name:
block_signature
- Data type:
VARBINARY
- Field name:
-
Payload Hash
- Field name:
payload_hash
- Data type:
VARBINARY
- Field name:
-
Generator ID
- Field name:
generator_id
- Data type:
BIGINT
- Field name:
-
Nonce
- Field name:
none
- Data type:
BIGINT
- Field name:
-
Block ATs
- Field name:
ats
- Data type:
VARBINARY
- Field name: