Primitives

E
Last updated 2 months ago

This page describes the various structures of the Ellcrys blockchain.

Overview

A block is a container data structure. It is composed of a header and a collection of transactions. Transactions are collected into a block and cryptographically linked to another block to form a chain of blocks. A block has a limited size; In Bitcoin, a block's size is set at 1MB, whereas In Bitcoin Cash, the size of a block is set at 8MB. The larger the block size, the more transactions can be processed per second. Ellcrys' block size is set at 10MB.

Block Structure

An Ellcrys block is composed of a header, a list of transactions, a block hash and a signature.

The header contains metadata about the block. It includes information about the current block number, proof-of-work proof, current and total difficulty, current state root hash and the hash of the previous block. The following code is an example structure of an Ellcrys header:

header.json
{
creatorPubKey: "48YQpehoRDYsivCbnedrz19DfTvh345PwWAKGN3jdUjPNdG3Lte",
difficulty: "0x989680",
extra: "0x",
nonce: "0x61879fb427b56cef",
number: "0x2",
parentHash: "0x211df3aed05b45d620850f40c9b4eac006da7ee0f76a7fa99d5ac16a2c2ca42c",
stateRoot: "0xc222870b2ca3f71d30b8d06b8e3f633812a8c0473cecc38b6fcc12eb5cad89ec",
timestamp: "0x5bda0ad4",
totalDifficulty: "0x1312d00",
transactionsRoot: "0x0000000000000000000000000000000000000000000000000000000000000000"
}

Field

Type

Description

number

UInt64

This is the current block number.

parentHash

[32]Byte

The hash of the previous block.

nonce

[8]Byte

The unique number derived during proof-of-work that fulfills the current difficulty.

difficulty

BigInt

The block's difficulty.

totalDifficulty

BigInt

The cumulative of all blocks in the chain.

creatorPubKey

String

The public key of the block creator.

stateRoot

[32]Byte

The merkle root of the chain state after processing the block's transactions.

transactionRoot

[32]Byte

The merkle root of the collection of transactions.

timestamp

Int64

The UNIX time of creation of the block.

extra

[32]Byte

An optional 32 bytes field for include additional/future data.

Transactions

In most blockchain systems, transactions are the driving force and initiator of action. They are created by users or (smart contracts) to perform a specific function such as moving money from one account to another account. Transactions are signed and sent to a node on the network and subsequently included into a block.

Types of Transactions

Balance: A balance transaction moves money from one account to another account; It is the most common transaction that is capable of changing the balance of users' account.

var TxTypeBalance = 0x1

Allocation: An allocation transaction is used to allocate new coins to users. They are used extensively in the genesis block to distribute initial coin supply. According to protocol specification, miners are expected to include an allocation transaction for paying transaction fees to themselves.

var TxTypeAlloc = 0x2

Transaction Structure

The structure of a transaction includes information about the type of the transaction, financial information, destination address, authorising signature and more. Here is a sample of a transaction:

transaction.json
{
fee: "0",
from: "eNGGuhVSrXWWFYmVQBid9hFhiNLAfvPwzS",
hash: "0xf91be74146afb8717834f70969d02edff4316508dc62ec8716104968391fc492",
nonce: "0x0",
senderPubKey: "497a8Z5sTvCgFZYyQQ8Uh3tgm726uPBzM4v3fNpcygevyCcTJf6",
sig: "0xe579837d73b45af9cc9e381cfe7009106c5ea6c65a22356a61103e9724b92bbb8a7243a4765d28d9e2aa89d34df585efc08c07fff9eb4a649f60f03f3310890e",
timestamp: "0x5bcc82b7",
to: "eGzzf1HtQL7M9Eh792iGHTvb6fsnnPipad",
type: "0x2",
value: "100"
}

Field

Type

Description

type

Int

The type of transaction (0x1=balance or 0x2=allocation).

from

String

The address of the transaction sender and signer.

to

String

The beneficiary or recipient of the value or asset being transacted.

value

String

The numeric value to be transferred or transacted.

fee

String

The amount of fee to pay.

senderPubKey

String

The public key of the sender/signer.

This is used to verify the transaction's signature.

nonce

UInt64

The number of transactions successfully created by the sender.

This is used to prevent double spend attacks.

hash

[32]Byte

The BLAKE2b-256 hash of the transaction.

timestamp

Int64

The UNIX time of creation.

sig

[64]Byte

The transaction signature.

Hash

The hash is a 32 bytes Blake2b-256 hash. It is composed of a concatenation of the header and transactions. A block is considered invalid if the computed hash does not match the hash included in the block.

Signature

The signature of a block is created using the private key of the block creator to produce a 64 bytes output. The signed data is composed of the block's header and transactions.