Class: Policy
Constructors
new Policy()
new Policy():
Policy
Returns
Properties
BATCHES_PER_EPOCH
readonly
static
BATCHES_PER_EPOCH:number
How many batches constitute an epoch
Defined in
@nimiq/core/types/wasm/web.d.ts:1499
BLOCK_SEPARATION_TIME
readonly
static
BLOCK_SEPARATION_TIME:bigint
The optimal time in milliseconds between blocks (1s)
Defined in
@nimiq/core/types/wasm/web.d.ts:1511
BLOCKS_PER_BATCH
readonly
static
BLOCKS_PER_BATCH:number
Length of a batch including the macro block
Defined in
@nimiq/core/types/wasm/web.d.ts:1503
BLOCKS_PER_EPOCH
readonly
static
BLOCKS_PER_EPOCH:number
Length of an epoch including the election block
Defined in
@nimiq/core/types/wasm/web.d.ts:1507
BLS_CACHE_MAX_CAPACITY
readonly
static
BLS_CACHE_MAX_CAPACITY:number
The maximum size of the BLS public key cache.
Defined in
@nimiq/core/types/wasm/web.d.ts:1515
COINBASE_ADDRESS
readonly
static
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
@nimiq/core/types/wasm/web.d.ts:1520
F_PLUS_ONE
readonly
static
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
@nimiq/core/types/wasm/web.d.ts:1527
GENESIS_BLOCK_NUMBER
readonly
static
GENESIS_BLOCK_NUMBER:number
Genesis block number
Defined in
@nimiq/core/types/wasm/web.d.ts:1531
HISTORY_CHUNKS_MAX_SIZE
readonly
static
HISTORY_CHUNKS_MAX_SIZE:bigint
Maximum size of history chunks. 25 MB.
Defined in
@nimiq/core/types/wasm/web.d.ts:1536
JAIL_EPOCHS
readonly
static
JAIL_EPOCHS:number
The number of epochs a validator is put in jail for. The jailing only happens for severe offenses.
Defined in
@nimiq/core/types/wasm/web.d.ts:1540
MAX_SIZE_MICRO_BODY
readonly
static
MAX_SIZE_MICRO_BODY:number
The maximum allowed size, in bytes, for a micro block body.
Defined in
@nimiq/core/types/wasm/web.d.ts:1544
MIN_EPOCHS_STORED
readonly
static
MIN_EPOCHS_STORED:number
Minimum number of epochs that the ChainStore will store fully
Defined in
@nimiq/core/types/wasm/web.d.ts:1552
MIN_PRODUCER_TIMEOUT
readonly
static
MIN_PRODUCER_TIMEOUT:bigint
The minimum timeout in milliseconds for a validator to produce a block (4s)
Defined in
@nimiq/core/types/wasm/web.d.ts:1556
MINIMUM_REWARDS_PERCENTAGE
readonly
static
MINIMUM_REWARDS_PERCENTAGE:number
The minimum rewards percentage that we allow
Defined in
@nimiq/core/types/wasm/web.d.ts:1548
SLOTS
readonly
static
SLOTS:number
Number of available validator slots. Note that a single validator may own several validator slots.
Defined in
@nimiq/core/types/wasm/web.d.ts:1560
STAKING_CONTRACT_ADDRESS
readonly
static
STAKING_CONTRACT_ADDRESS:string
This is the address for the staking contract.
Defined in
@nimiq/core/types/wasm/web.d.ts:1564
STATE_CHUNKS_MAX_SIZE
readonly
static
STATE_CHUNKS_MAX_SIZE:number
Maximum size of accounts trie chunks.
Defined in
@nimiq/core/types/wasm/web.d.ts:1568
TIMESTAMP_MAX_DRIFT
readonly
static
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
@nimiq/core/types/wasm/web.d.ts:1573
TOTAL_SUPPLY
readonly
static
TOTAL_SUPPLY:bigint
Total supply in units.
Defined in
@nimiq/core/types/wasm/web.d.ts:1577
TRANSACTION_VALIDITY_WINDOW
readonly
static
TRANSACTION_VALIDITY_WINDOW:number
Number of batches a transaction is valid with Albatross consensus.
Defined in
@nimiq/core/types/wasm/web.d.ts:1581
TRANSACTION_VALIDITY_WINDOW_BLOCKS
readonly
static
TRANSACTION_VALIDITY_WINDOW_BLOCKS:number
Number of blocks a transaction is valid with Albatross consensus.
Defined in
@nimiq/core/types/wasm/web.d.ts:1585
TWO_F_PLUS_ONE
readonly
static
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
@nimiq/core/types/wasm/web.d.ts:1597
VALIDATOR_DEPOSIT
readonly
static
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
@nimiq/core/types/wasm/web.d.ts:1603
VERSION
readonly
static
VERSION:number
The current version number of the protocol. Changing this always results in a hard fork.
Defined in
@nimiq/core/types/wasm/web.d.ts:1607
Methods
free()
free():
void
Returns
void
Defined in
@nimiq/core/types/wasm/web.d.ts:1331
batchAt()
static
batchAt(block_number
):number
Returns the batch number at a given block_number
(height)
Parameters
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1350
batchDelayPenalty()
static
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) * BLOCKS_DELAY_DECAY ^ (t^2)] + MINIMUM_REWARDS_PERCENTAGE
Parameters
• delay: bigint
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1495
batchIndexAt()
static
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
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1357
blockAfterJail()
static
blockAfterJail(block_number
):number
Returns the first block after the jail period of a given block number has ended.
Parameters
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1471
blockAfterReportingWindow()
static
blockAfterReportingWindow(block_number
):number
Returns the first block after the reporting window of a given block number has ended.
Parameters
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1465
electionBlockAfter()
static
electionBlockAfter(block_number
):number
Returns the number (height) of the next election macro block after a given block number (height).
Parameters
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1363
electionBlockBefore()
static
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
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1370
electionBlockOf()
static
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
• epoch: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1437
epochAt()
static
epochAt(block_number
):number
Returns the epoch number at a given block number (height).
Parameters
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1337
epochIndexAt()
static
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
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1344
firstBatchOfEpoch()
static
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
• block_number: number
Returns
boolean
Defined in
@nimiq/core/types/wasm/web.d.ts:1452
firstBlockOf()
static
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
• epoch: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1423
firstBlockOfBatch()
static
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
• batch: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1430
isElectionBlockAt()
static
isElectionBlockAt(block_number
):boolean
Returns a boolean expressing if the block at a given block number (height) is an election macro block.
Parameters
• block_number: number
Returns
boolean
Defined in
@nimiq/core/types/wasm/web.d.ts:1383
isMacroBlockAt()
static
isMacroBlockAt(block_number
):boolean
Returns a boolean expressing if the block at a given block number (height) is a macro block.
Parameters
• block_number: number
Returns
boolean
Defined in
@nimiq/core/types/wasm/web.d.ts:1410
isMicroBlockAt()
static
isMicroBlockAt(block_number
):boolean
Returns a boolean expressing if the block at a given block number (height) is a micro block.
Parameters
• block_number: number
Returns
boolean
Defined in
@nimiq/core/types/wasm/web.d.ts:1416
lastBlockOfReportingWindow()
static
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
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1459
lastElectionBlock()
static
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
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1377
lastMacroBlock()
static
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
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1404
macroBlockAfter()
static
macroBlockAfter(block_number
):number
Returns the block number (height) of the next macro block after a given block number (height). If the given block number is a macro block, it returns the macro block after it.
Parameters
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1390
macroBlockBefore()
static
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
• block_number: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1397
macroBlockOf()
static
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
• batch: number
Returns
number
Defined in
@nimiq/core/types/wasm/web.d.ts:1445
supplyAt()
static
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) = total_supply - (total_supply - genesis_supply) * supply_decay^t
Where t is the time in milliseconds since the PoS genesis block and genesis_supply
is the supply at the genesis of the Nimiq 2.0 chain.
Parameters
• genesis_supply: bigint
• genesis_time: bigint
• current_time: bigint
Returns
bigint
Defined in
@nimiq/core/types/wasm/web.d.ts:1485