Wallets
Contract contains logic to perform automatic self-recharging ether for nodes
receive receive()
external
Is executed on a call to the contract with empty calldata. This is the function that is executed on plain Ether transfers, so validator or schain owner can use usual transfer ether to recharge wallet.
refundGasByValidator refundGasByValidator(uint256 validatorId, address payable spender, uint256 spentGas)
external
Reimburse gas for node by validator wallet. If validator wallet has not enough funds
the node will receive the entire remaining amount in the validator’s wallet.
validatorId
- validator that will reimburse desired transaction
spender
- address to send reimbursed funds
spentGas
- amount of spent gas that should be reimbursed to desired node
Emits a NodeRefundedByValidator
event.
Requirements: - Given validator should exist
refundGasByValidatorToSchain refundGasByValidatorToSchain(uint256 validatorId, bytes32 schainHash)
external
Returns the amount owed to the owner of the chain by the validator, if the validator does not have enough funds, then everything that the validator has will be returned to the owner of the chain.
refundGasBySchain refundGasBySchain(bytes32 schainHash, address payable spender, uint256 spentGas, bool isDebt)
external
Reimburse gas for node by schain wallet. If schain wallet has not enough funds
than transaction will be reverted.
schainHash
- schain that will reimburse desired transaction
spender
- address to send reimbursed funds
spentGas
- amount of spent gas that should be reimbursed to desired node
isDebt
- parameter that indicates whether this amount should be recorded as debt for the validator
Emits a NodeRefundedBySchain
event.
Requirements: - Given schain should exist - Schain wallet should have enough funds
withdrawFundsFromSchainWallet withdrawFundsFromSchainWallet(address payable schainOwner, bytes32 schainHash)
external
Withdraws money from schain wallet. Possible to execute only after deleting schain.
schainOwner
- address of schain owner that will receive rest of the schain balance
schainHash
- schain wallet from which money is withdrawn
Requirements: - Executable only after initializing delete schain
withdrawFundsFromValidatorWallet withdrawFundsFromValidatorWallet(uint256 amount)
external
Withdraws money from validator wallet.
amount
- the amount of money in wei
Requirements: - Validator must have sufficient withdrawal amount
getSchainBalance getSchainBalance(bytes32 schainHash) → uint256
external
getValidatorBalance getValidatorBalance(uint256 validatorId) → uint256
external
rechargeValidatorWallet rechargeValidatorWallet(uint256 validatorId)
public
Recharge the validator wallet by id.
validatorId
- id of existing validator.
Emits a ValidatorWalletRecharged
event.
Requirements: - Given validator must exist
rechargeSchainWallet rechargeSchainWallet(bytes32 schainHash)
public
Recharge the schain wallet by schainHash (hash of schain name).
schainHash
- id of existing schain.
Emits a SchainWalletRecharged
event.
Requirements: - Given schain must be created
initialize initialize(address contractsAddress)
public
ValidatorWalletRecharged ValidatorWalletRecharged(address sponsor, uint256 amount, uint256 validatorId)
event
Emitted when the validator wallet was funded
SchainWalletRecharged SchainWalletRecharged(address sponsor, uint256 amount, bytes32 schainHash)
event
Emitted when the schain wallet was funded
NodeRefundedByValidator NodeRefundedByValidator(address node, uint256 validatorId, uint256 amount)
event
Emitted when the node received a refund from validator to its wallet
NodeRefundedBySchain NodeRefundedBySchain(address node, bytes32 schainHash, uint256 amount)
event
Emitted when the node received a refund from schain to its wallet