Skip to main content

DarknodePayment

Reference

Contract: DarknodePayment​

DarknodePayment is responsible for paying off darknodes for their computation.

Inherits from:

  • Claimable
  • Ownable
  • Context
  • Initializable


Variables​

VERSION: string​


ETHEREUM: address​


darknodeRegistry: contract DarknodeRegistryLogicV1​


store: contract DarknodePaymentStore​


cycleChanger: address​


currentCycle: uint256​


previousCycle: uint256​


pendingTokens: address[]​


registeredTokens: address[]​


registeredTokenIndex: mapping(address => uint256)​


unclaimedRewards: mapping(address => uint256)​


previousCycleRewardShare: mapping(address => uint256)​


cycleStartTime: uint256​


nextCyclePayoutPercent: uint256​


currentCyclePayoutPercent: uint256​


rewardClaimed: mapping(address => mapping(uint256 => bool))​



Modifiers​

onlyDarknode(address _darknode)​

Restrict a function registered dark nodes to call a function.


validPercent(uint256 _percent)​

Restrict a function to have a valid percentage.


onlyCycleChanger()​

Restrict a function to be called by cycleChanger.



Functions​

constructor (string _VERSION, contract DarknodeRegistryLogicV1 _darknodeRegistry, contract DarknodePaymentStore _darknodePaymentStore, uint256 _cyclePayoutPercent) (public)​

Params

  • _VERSION: A string defining the contract version.

  • _darknodeRegistry: The address of the DarknodeRegistry contract.

  • _darknodePaymentStore: The address of the DarknodePaymentStore contract.

The contract constructor. Starts the current cycle using the time of deploy.


updateDarknodeRegistry (contract DarknodeRegistryLogicV1 _darknodeRegistry) (external)​

Params

  • _darknodeRegistry: The address of the Darknode Registry contract.

Allows the contract owner to update the address of the darknode registry contract.


withdraw (address _darknode, address _token) (public)​

Params

  • _darknode: The address of the darknode.

  • _token: Which token to transfer.

Transfers the funds allocated to the darknode to the darknode owner.


withdrawMultiple (address[] _darknodes, address[] _tokens) (external)​


fallback () (external)​

Forward all payments to the DarknodePaymentStore.


currentCycleRewardPool (address _token) → uint256 (external)​

The current balance of the contract available as reward for the current cycle.


darknodeBalances (address _darknodeID, address _token) → uint256 (external)​


changeCycle () → uint256 (external)​

Changes the current cycle.


deposit (uint256 _value, address _token) (external)​

Params

  • _value: The amount of token deposit in the token's smallest unit.

  • _token: The token address.

Deposits token into the contract to be paid to the Darknodes.


forward (address _token) (external)​

Params

  • _token: The token address.

Forwards any tokens that have been sent to the DarknodePayment contract probably by mistake, to the DarknodePaymentStore.


claim (address _darknode) (external)​

Params

  • _darknode: The address of the darknode to claim.

Claims the rewards allocated to the darknode last epoch.


registerToken (address _token) (external)​

Params

  • _token: The address of the token to be registered.

Adds tokens to be payable. Registration is pending until next cycle.


tokenPendingRegistration (address _token) → bool (public)​


deregisterToken (address _token) (external)​

Params

  • _token: The address of the token to be deregistered.

Removes a token from the list of supported tokens. Deregistration is pending until next cycle.


updateCycleChanger (address _addr) (external)​

Params

  • _addr: The new CycleChanger contract address.

Updates the CycleChanger contract address.


updatePayoutPercentage (uint256 _percent) (external)​

Params

  • _percent: The percentage of payout for darknodes.

Updates payout percentage.


transferStoreOwnership (contract DarknodePayment _newOwner) (external)​

Params

  • _newOwner: The address to transfer the ownership to.

Allows the contract owner to initiate an ownership transfer of the DarknodePaymentStore.


claimStoreOwnership () (external)​

Claims ownership of the store passed in to the constructor. transferStoreOwnership must have previously been called when transferring from another DarknodePaymentStore.



Events​

LogDarknodeClaim (address _darknode, uint256 _cycle)​

Emitted when a darknode claims their share of reward.

Params

  • _darknode: The darknode which claimed.

  • _cycle: The cycle that the darknode claimed for.


LogPaymentReceived (address _payer, address _token, uint256 _amount)​

Emitted when someone pays the DarknodePayment contract.

Params

  • _payer: The darknode which claimed.

  • _amount: The cycle that the darknode claimed for.

  • _token: The address of the token that was transferred.


LogDarknodeWithdrew (address _darknodeOperator, address _darknodeID, address _token, uint256 _value)​

Emitted when a darknode calls withdraw.

Params

  • _darknodeOperator: The address of the darknode's operator.

  • _darknodeID: The address of the darknode which withdrew.

  • _value: The amount of DAI withdrawn.

  • _token: The address of the token that was withdrawn.


LogPayoutPercentChanged (uint256 _newPercent, uint256 _oldPercent)​

Emitted when the payout percent changes.

Params

  • _newPercent: The new percent.

  • _oldPercent: The old percent.


LogCycleChangerChanged (address _newCycleChanger, address _oldCycleChanger)​

Emitted when the CycleChanger address changes.

Params

  • _newCycleChanger: The new CycleChanger.

  • _oldCycleChanger: The old CycleChanger.


LogTokenRegistered (address _token)​

Emitted when a new token is registered.

Params

  • _token: The token that was registered.

LogTokenDeregistered (address _token)​

Emitted when a token is deregistered.

Params

  • _token: The token that was deregistered.

LogDarknodeRegistryUpdated (contract DarknodeRegistryLogicV1 _previousDarknodeRegistry, contract DarknodeRegistryLogicV1 _nextDarknodeRegistry)​

Emitted when the DarknodeRegistry is updated.

Params

  • _previousDarknodeRegistry: The address of the old registry.

  • _nextDarknodeRegistry: The address of the new registry.