IPChainStakeMirror
Events
MaxUpdatesPerBlockSet
event MaxUpdatesPerBlockSet (
uint256 maxUpdatesPerBlock
)
Event emitted when max updates per block is set.
Parameters
Type
Description
maxUpdatesPerBlock
uint256
new number of max updated per block
StakeConfirmed
event StakeConfirmed (
address owner ,
bytes20 nodeId,
bytes32 txHash ,
uint256 amountWei ,
bytes32 pChainTxId
)
Event emitted when the stake is confirmed.
Parameters
Type
Description
owner
address
The address who opened the stake.
nodeId
bytes20
Node id to which the stake was added.
txHash
bytes32
Unique tx hash - keccak256(abi.encode(PChainStake
.txId, PChainStake
.inputAddress));
amountWei
uint256
Stake amount (in wei).
pChainTxId
bytes32
P-chain transaction id.
StakeEnded
event StakeEnded (
address owner ,
bytes20 nodeId,
bytes32 txHash ,
uint256 amountWei
)
Event emitted when the stake has ended.
Parameters
Type
Description
owner
address
The address whose stake has ended.
nodeId
bytes20
Node id from which the stake was removed.
txHash
bytes32
Unique tx hash - keccak256(abi.encode(PChainStake
.txId, PChainStake
.inputAddress));
amountWei
uint256
Stake amount (in wei).
StakeRevoked
event StakeRevoked (
address owner ,
bytes20 nodeId,
bytes32 txHash ,
uint256 amountWei
)
Event emitted when the stake was revoked.
Parameters
Type
Description
owner
address
The address whose stake has ended.
nodeId
bytes20
Node id from which the stake was removed.
txHash
bytes32
Unique tx hash - keccak256(abi.encode(PChainStake
.txId, PChainStake
.inputAddress));
amountWei
uint256
Stake amount (in wei).
VotePowerCacheCreated
event VotePowerCacheCreated (
bytes20 nodeId,
uint256 blockNumber
)
Emitted when a vote power cache entry is created.
Allows history cleaners to track vote power cache cleanup opportunities off-chain.
Parameters
Type
Description
nodeId
bytes20
The node id whose vote power has just been cached.
blockNumber
uint256
The block number at which the vote power has been cached.
VotePowerChanged
event VotePowerChanged (
address owner ,
bytes20 nodeId,
uint256 priorVotePower ,
uint256 newVotePower
)
Event triggered when a stake is confirmed or at the time it ends.
Definition: votePowerFromTo
(owner, nodeId)is
changedfrom
priorVotePowerto
newVotePower`.
Parameters
Type
Description
owner
address
The account that has changed the amount of vote power it is staking.
nodeId
bytes20
The node id whose received vote power has changed.
priorVotePower
uint256
The vote power originally on that node id.
newVotePower
uint256
The new vote power that triggered this event.
Functions
balanceOf
function balanceOf (
address _owner
) external view returns (
uint256 );
Queries the token balance of _owner
at current block.
Parameters
Type
Description
_owner
address
The address from which the balance will be retrieved.
Returns
Type
Description
[0]
uint256
The current balance.
balanceOfAt
function balanceOfAt (
address _owner ,
uint256 _blockNumber
) external view returns (
uint256 );
Queries the token balance of _owner
at a specific _blockNumber
.
Parameters
Type
Description
_owner
address
The address from which the balance will be retrieved.
_blockNumber
uint256
The block number when the balance is queried.
Returns
Type
Description
[0]
uint256
The balance at _blockNumber
.
batchVotePowerOfAt
function batchVotePowerOfAt (
bytes20[] _nodeIds,
uint256 _blockNumber
) external view returns (
uint256 []);
Return vote powers for several node ids in a batch.
Parameters
Type
Description
_nodeIds
bytes20[]
The list of node ids to fetch vote power of.
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256[]
A list of vote powers.
isActiveStakeMirrored
function isActiveStakeMirrored (
bytes32 _txId ,
bytes20 _inputAddress
) external view returns (
bool );
Method for checking if active stake (stake start time <= block.timestamp < stake end time) was already mirrored.
Parameters
Type
Description
_txId
bytes32
P-chain stake transaction id.
_inputAddress
bytes20
P-chain address that opened stake.
Returns
Type
Description
[0]
bool
True if stake is active and mirrored.
mirrorStake
function mirrorStake (
struct IPChainStakeMirrorVerifier . PChainStake _stakeData,
bytes32 [] _merkleProof
) external ;
Method for P-chain stake mirroring using PChainStake
data and Merkle proof.
Parameters
Type
Description
_stakeData
struct IPChainStakeMirrorVerifier.PChainStake
Information about P-chain stake.
_merkleProof
bytes32[]
Merkle proof that should be used to prove the P-chain stake.
stakesOf
function stakesOf (
address _owner
) external view returns (
bytes20[] _nodeIds,
uint256 [] _amounts);
Get the amounts and node ids being staked to by a vote power owner.
Parameters
Type
Description
_owner
address
The address being queried.
Returns
Type
Description
_nodeIds
bytes20[]
Array of node ids.
_amounts
uint256[]
Array of staked amounts, for each node id.
stakesOfAt
function stakesOfAt (
address _owner ,
uint256 _blockNumber
) external view returns (
bytes20[] _nodeIds,
uint256 [] _amounts);
Get the amounts and node ids being staked to by a vote power owner,
at a given block.
Parameters
Type
Description
_owner
address
The address being queried.
_blockNumber
uint256
The block number being queried.
Returns
Type
Description
_nodeIds
bytes20[]
Array of node ids.
_amounts
uint256[]
Array of staked amounts, for each node id.
totalSupply
function totalSupply (
) external view returns (
uint256 );
Total amount of tokens at current block.
Returns
Type
Description
[0]
uint256
The current total amount of tokens.
totalSupplyAt
function totalSupplyAt (
uint256 _blockNumber
) external view returns (
uint256 );
Total amount of tokens at a specific _blockNumber
.
Parameters
Type
Description
_blockNumber
uint256
The block number when the totalSupply is queried.
Returns
Type
Description
[0]
uint256
The total amount of tokens at _blockNumber
.
totalVotePower
function totalVotePower (
) external view returns (
uint256 );
Get the current total vote power.
Returns
Type
Description
[0]
uint256
The current total vote power (sum of all accounts' vote powers).
totalVotePowerAt
function totalVotePowerAt (
uint256 _blockNumber
) external view returns (
uint256 );
Get the total vote power at block _blockNumber
Parameters
Type
Description
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
The total vote power at the block (sum of all accounts' vote powers).
totalVotePowerAtCached
function totalVotePowerAtCached (
uint256 _blockNumber
) external returns (
uint256 );
Get the total vote power at block _blockNumber
using cache.
It tries to read the cached value and if not found, reads the actual value and stores it in cache.
Can only be used if _blockNumber
is in the past, otherwise reverts.
Parameters
Type
Description
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
The total vote power at the block (sum of all accounts' vote powers).
votePowerFromTo
function votePowerFromTo (
address _owner ,
bytes20 _nodeId
) external view returns (
uint256 );
Get current staked vote power from _owner
staked to _nodeId
.
Parameters
Type
Description
_owner
address
Address of vote power owner.
_nodeId
bytes20
Node id.
Returns
Type
Description
[0]
uint256
The staked vote power.
votePowerFromToAt
function votePowerFromToAt (
address _owner ,
bytes20 _nodeId,
uint256 _blockNumber
) external view returns (
uint256 );
Get current staked vote power from _owner
staked to _nodeId
at _blockNumber
.
Parameters
Type
Description
_owner
address
Address of vote power owner.
_nodeId
bytes20
Node id.
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
The staked vote power.
votePowerOf
function votePowerOf (
bytes20 _nodeId
) external view returns (
uint256 );
Get the current vote power of _nodeId
.
Parameters
Type
Description
_nodeId
bytes20
The node id to get voting power.
Returns
Type
Description
[0]
uint256
Current vote power of _nodeId
.
votePowerOfAt
function votePowerOfAt (
bytes20 _nodeId,
uint256 _blockNumber
) external view returns (
uint256 );
Get the vote power of _nodeId
at block _blockNumber
Parameters
Type
Description
_nodeId
bytes20
The node id to get voting power.
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
Vote power of _nodeId
at _blockNumber
.
votePowerOfAtCached
function votePowerOfAtCached (
bytes20 _owner,
uint256 _blockNumber
) external returns (
uint256 );
Get the vote power of _owner
at block _blockNumber
using cache.
It tries to read the cached value and if not found, reads the actual value and stores it in cache.
Can only be used if _blockNumber is in the past, otherwise reverts.
Parameters
Type
Description
_owner
bytes20
The node id to get voting power.
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
Vote power of _owner
at _blockNumber
.