Skip to content

Class: Policy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Policy(): Policy

Returns

Policy

Properties

BATCHES_PER_EPOCH

Static Readonly BATCHES_PER_EPOCH: number

How many batches constitute an epoch

Defined in

web.d.ts:1263


BLOCKS_DELAY_DECAY

Static Readonly BLOCKS_DELAY_DECAY: number

The slope of the exponential decay used to punish validators for not producing block in time

Defined in

web.d.ts:1267


BLOCKS_PER_BATCH

Static Readonly BLOCKS_PER_BATCH: number

Length of a batch including the macro block

Defined in

web.d.ts:1271


BLOCKS_PER_EPOCH

Static Readonly BLOCKS_PER_EPOCH: number

Length of an epoch including the election block

Defined in

web.d.ts:1275


BLOCK_PRODUCER_TIMEOUT

Static Readonly BLOCK_PRODUCER_TIMEOUT: bigint

The timeout in milliseconds for a validator to produce a block (2s)

Defined in

web.d.ts:1279


BLOCK_SEPARATION_TIME

Static Readonly BLOCK_SEPARATION_TIME: bigint

The optimal time in milliseconds between blocks (1s)

Defined in

web.d.ts:1283


BLS_CACHE_MAX_CAPACITY

Static Readonly BLS_CACHE_MAX_CAPACITY: number

The maximum size of the BLS public key cache.

Defined in

web.d.ts:1287


COINBASE_ADDRESS

Static Readonly COINBASE_ADDRESS: string

This is the address for the coinbase. Note that this is not a real account, it is just the address we use to denote that some coins originated from a coinbase event.

Defined in

web.d.ts:1292


F_PLUS_ONE

Static Readonly F_PLUS_ONE: number

Calculates f+1 slots which is the minimum number of slots necessary to be guaranteed to have at least one honest slots. That's because from a total of 3f+1 slots at most f will be malicious. It is calculated as ceil(SLOTS/3) and we use the formula ceil(x/y) = (x+y-1)/y for the ceiling division.

Defined in

web.d.ts:1299


GENESIS_BLOCK_NUMBER

Static Readonly GENESIS_BLOCK_NUMBER: number

Genesis block number

Defined in

web.d.ts:1303


HISTORY_CHUNKS_MAX_SIZE

Static Readonly HISTORY_CHUNKS_MAX_SIZE: bigint

Maximum size of history chunks. 25 MB.

Defined in

web.d.ts:1308


INITIAL_SUPPLY_VELOCITY

Static Readonly INITIAL_SUPPLY_VELOCITY: number

This is the number of Lunas (1 NIM = 100,000 Lunas) created by millisecond at the genesis of the Nimiq 2.0 chain. The velocity then decreases following the formula: Supply_velocity (t) = Initial_supply_velocity * e^(- Supply_decay * t) Where e is the exponential function and t is the time in milliseconds since the genesis block.

Defined in

web.d.ts:1315


JAIL_EPOCHS

Static Readonly JAIL_EPOCHS: number

The number of epochs a validator is put in jail for. The jailing only happens for severe offenses.

Defined in

web.d.ts:1319


MAX_SIZE_MICRO_BODY

Static Readonly MAX_SIZE_MICRO_BODY: number

The maximum allowed size, in bytes, for a micro block body.

Defined in

web.d.ts:1323


MINIMUM_REWARDS_PERCENTAGE

Static Readonly MINIMUM_REWARDS_PERCENTAGE: number

The minimum rewards percentage that we allow

Defined in

web.d.ts:1327


MIN_EPOCHS_STORED

Static Readonly MIN_EPOCHS_STORED: number

Minimum number of epochs that the ChainStore will store fully

Defined in

web.d.ts:1331


SLOTS

Static Readonly SLOTS: number

Number of available validator slots. Note that a single validator may own several validator slots.

Defined in

web.d.ts:1335


STAKING_CONTRACT_ADDRESS

Static Readonly STAKING_CONTRACT_ADDRESS: string

This is the address for the staking contract.

Defined in

web.d.ts:1339


STATE_CHUNKS_MAX_SIZE

Static Readonly STATE_CHUNKS_MAX_SIZE: number

Maximum size of accounts trie chunks.

Defined in

web.d.ts:1343


SUPPLY_DECAY

Static Readonly SUPPLY_DECAY: number

The supply decay is a constant that is calculated so that the supply velocity decreases at a steady 1.47% per year.

Defined in

web.d.ts:1348


TENDERMINT_TIMEOUT_DELTA

Static Readonly TENDERMINT_TIMEOUT_DELTA: bigint

Tendermint's timeout delta, in milliseconds.

See https://arxiv.org/abs/1807.04938v3 for more information.

Defined in

web.d.ts:1354


TENDERMINT_TIMEOUT_INIT

Static Readonly TENDERMINT_TIMEOUT_INIT: bigint

Tendermint's initial timeout, in milliseconds.

See https://arxiv.org/abs/1807.04938v3 for more information.

Defined in

web.d.ts:1360


TIMESTAMP_MAX_DRIFT

Static Readonly TIMESTAMP_MAX_DRIFT: bigint

The maximum drift, in milliseconds, that is allowed between any block's timestamp and the node's system time. We only care about drifting to the future.

Defined in

web.d.ts:1365


TOTAL_SUPPLY

Static Readonly TOTAL_SUPPLY: bigint

Total supply in units.

Defined in

web.d.ts:1369


TRANSACTION_VALIDITY_WINDOW

Static Readonly TRANSACTION_VALIDITY_WINDOW: number

Number of batches a transaction is valid with Albatross consensus.

Defined in

web.d.ts:1373


TRANSACTION_VALIDITY_WINDOW_BLOCKS

Static Readonly TRANSACTION_VALIDITY_WINDOW_BLOCKS: number

Number of blocks a transaction is valid with Albatross consensus.

Defined in

web.d.ts:1377


TWO_F_PLUS_ONE

Static Readonly TWO_F_PLUS_ONE: number

Calculates 2f+1 slots which is the minimum number of slots necessary to produce a macro block, a skip block and other actions. It is also the minimum number of slots necessary to be guaranteed to have a majority of honest slots. That's because from a total of 3f+1 slots at most f will be malicious. If in a group of 2f+1 slots we have f malicious ones (which is the worst case scenario), that still leaves us with f+1 honest slots. Which is more than the f slots that are not in this group (which must all be honest). It is calculated as ceil(SLOTS*2/3) and we use the formula ceil(x/y) = (x+y-1)/y for the ceiling division.

Defined in

web.d.ts:1389


VALIDATOR_DEPOSIT

Static Readonly VALIDATOR_DEPOSIT: bigint

The deposit necessary to create a validator in Lunas (1 NIM = 100,000 Lunas). A validator is someone who actually participates in block production. They are akin to miners in proof-of-work.

Defined in

web.d.ts:1395


VERSION

Static Readonly VERSION: number

The current version number of the protocol. Changing this always results in a hard fork.

Defined in

web.d.ts:1399

Methods

free

free(): void

Returns

void

Defined in

web.d.ts:1098


batchAt

batchAt(block_number): number

Returns the batch number at a given block_number (height)

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1117


batchDelayPenalty

batchDelayPenalty(delay): number

Returns the percentage reduction that should be applied to the rewards due to a delayed batch. This function returns a float in the range [0, 1] I.e 1 means that the full rewards should be given, whereas 0.5 means that half of the rewards should be given The input to this function is the batch delay, in milliseconds The function is: [(1 - MINIMUM_REWARDS_PERCENTAGE) * e ^(-BLOCKS_DELAY_DECAY * t^2)] + MINIMUM_REWARDS_PERCENTAGE

Parameters

NameType
delaybigint

Returns

number

Defined in

web.d.ts:1259


batchIndexAt

batchIndexAt(block_number): number

Returns the batch index at a given block number. The batch index is the number of a block relative to the batch it is in. For example, the first block of any batch always has an batch index of 0.

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1124


blockAfterJail

blockAfterJail(block_number): number

Returns the first block after the jail period of a given block number has ended.

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1237


blockAfterReportingWindow

blockAfterReportingWindow(block_number): number

Returns the first block after the reporting window of a given block number has ended.

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1231


electionBlockAfter

electionBlockAfter(block_number): number

Returns the number (height) of the next election macro block after a given block number (height).

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1130


electionBlockBefore

electionBlockBefore(block_number): number

Returns the block number (height) of the preceding election macro block before a given block number (height). If the given block number is an election macro block, it returns the election macro block before it.

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1137


electionBlockOf

electionBlockOf(epoch): number

Returns the block number of the election macro block of the given epoch (which is always the last block). If the index is out of bounds, None is returned

Parameters

NameType
epochnumber

Returns

number

Defined in

web.d.ts:1203


epochAt

epochAt(block_number): number

Returns the epoch number at a given block number (height).

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1104


epochIndexAt

epochIndexAt(block_number): number

Returns the epoch index at a given block number. The epoch index is the number of a block relative to the epoch it is in. For example, the first block of any epoch always has an epoch index of 0.

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1111


firstBatchOfEpoch

firstBatchOfEpoch(block_number): boolean

Returns a boolean expressing if the batch at a given block number (height) is the first batch of the epoch.

Parameters

NameType
block_numbernumber

Returns

boolean

Defined in

web.d.ts:1218


firstBlockOf

firstBlockOf(epoch): number

Returns the block number of the first block of the given epoch (which is always a micro block). If the index is out of bounds, None is returned

Parameters

NameType
epochnumber

Returns

number

Defined in

web.d.ts:1189


firstBlockOfBatch

firstBlockOfBatch(batch): number

Returns the block number of the first block of the given batch (which is always a micro block). If the index is out of bounds, None is returned

Parameters

NameType
batchnumber

Returns

number

Defined in

web.d.ts:1196


isElectionBlockAt

isElectionBlockAt(block_number): boolean

Returns a boolean expressing if the block at a given block number (height) is an election macro block.

Parameters

NameType
block_numbernumber

Returns

boolean

Defined in

web.d.ts:1150


isMacroBlockAt

isMacroBlockAt(block_number): boolean

Returns a boolean expressing if the block at a given block number (height) is a macro block.

Parameters

NameType
block_numbernumber

Returns

boolean

Defined in

web.d.ts:1176


isMicroBlockAt

isMicroBlockAt(block_number): boolean

Returns a boolean expressing if the block at a given block number (height) is a micro block.

Parameters

NameType
block_numbernumber

Returns

boolean

Defined in

web.d.ts:1182


lastBlockOfReportingWindow

lastBlockOfReportingWindow(block_number): number

Returns the block height for the last block of the reporting window of a given block number. Note: This window is meant for reporting malicious behaviour (aka jailable behaviour).

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1225


lastElectionBlock

lastElectionBlock(block_number): number

Returns the block number (height) of the last election macro block at a given block number (height). If the given block number is an election macro block, then it returns that block number.

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1144


lastMacroBlock

lastMacroBlock(block_number): number

Returns the block number (height) of the last macro block at a given block number (height). If the given block number is a macro block, then it returns that block number.

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1170


macroBlockAfter

macroBlockAfter(block_number): number

Returns the block number (height) of the next macro block after a given block number (height).

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1156


macroBlockBefore

macroBlockBefore(block_number): number

Returns the block number (height) of the preceding macro block before a given block number (height). If the given block number is a macro block, it returns the macro block before it.

Parameters

NameType
block_numbernumber

Returns

number

Defined in

web.d.ts:1163


macroBlockOf

macroBlockOf(batch): number

Returns the block number of the macro block (checkpoint or election) of the given batch (which is always the last block). If the index is out of bounds, None is returned

Parameters

NameType
batchnumber

Returns

number

Defined in

web.d.ts:1211


supplyAt

supplyAt(genesis_supply, genesis_time, current_time): bigint

Returns the supply at a given time (as Unix time) in Lunas (1 NIM = 100,000 Lunas). It is calculated using the following formula: Supply (t) = Genesis_supply + Initial_supply_velocity / Supply_decay * (1 - e^(- Supply_decay * t)) Where e is the exponential function, t is the time in milliseconds since the genesis block and Genesis_supply is the supply at the genesis of the Nimiq 2.0 chain.

Parameters

NameType
genesis_supplybigint
genesis_timebigint
current_timebigint

Returns

bigint

Defined in

web.d.ts:1249