Simple Staking Interface
相关视频
正文
Abstract
The following standard describes a common staking interface allowing for easy to use staking systems. The interface is kept simple allowing for various use cases to be implemented. This standard describes the common functionality for staking as well as providing information on stakes.
Motivation
As we move to more token models, having a common staking interface which is familiar to users can be useful. The common interface can be used by a variety of applications, this common interface could be beneficial especially to things like Token curated registries which have recently gained popularity.
Specification
interface Staking { event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); function stake(uint256 amount, bytes data) public; function stakeFor(address user, uint256 amount, bytes data) public; function unstake(uint256 amount, bytes data) public; function totalStakedFor(address addr) public view returns (uint256); function totalStaked() public view returns (uint256); function token() public view returns (address); function supportsHistory() public pure returns (bool); // optional function lastStakedFor(address addr) public view returns (uint256); function totalStakedForAt(address addr, uint256 blockNumber) public view returns (uint256); function totalStakedAt(uint256 blockNumber) public view returns (uint256); }
stake
Stakes a certain amount of tokens, this MUST transfer the given amount from the user.
The data field can be used to add signalling information in more complex staking applications
MUST trigger Staked
event.
stakeFor
Stakes a certain amount of tokens, this MUST transfer the given amount from the caller.
The data field can be used to add signalling information in more complex staking applications
MUST trigger Staked
event.
unstake
Unstakes a certain amount of tokens, this SHOULD return the given amount of tokens to the user, if unstaking is currently not possible the function MUST revert.
The data field can be used to remove signalling information in more complex staking applications
MUST trigger Unstaked
event.
totalStakedFor
Returns the current total of tokens staked for an address.
totalStaked
Returns the current total of tokens staked.
token
Address of the token being used by the staking interface.
supportsHistory
MUST return true if the optional history functions are implemented, otherwise false.
lastStakedFor
OPTIONAL: As not all staking systems require a complete history, this function is optional.
Returns last block address staked at.
totalStakedForAt
OPTIONAL: As not all staking systems require a complete history, this function is optional.
Returns total amount of tokens staked at block for address.
totalStakedAt
OPTIONAL: As not all staking systems require a complete history, this function is optional.
Returns the total tokens staked at block.
Implementation
Copyright
Copyright and related rights waived via CC0.