Address: 0x0000000000000000000000000000000000001003
Interface: IStaking
ABI: IStaking
use staking precompiled contract to call some functions of the staking module, such as: delegate, undelegate, withdraw, etc.
delegate token to validator, get shares and reward
{% hint style="info" %} delegate to different validators, the shares obtained are essentially different and cannot be added {% endhint %}
function delegate(
string memory _val
) external payable returns (uint256 _shares, uint256 _reward);
-
msg.value
: payable method, the amount of the token to be delegated -
_val
: the validator address -
_shares
: the shares of the delegate token -
_reward
: the reward of the delegate
{% hint style="info" %} only can delegate origin token, must be input msg.value {% endhint %}
{% hint style="info" %} only delegate validator who has participated in block generation, delegate again, will get reward {% endhint %}
delegate event
event Delegate(
address indexed delegator,
string validator,
uint256 amount,
uint256 shares
);
delegator
: the delegator addressvalidator
: the validator address to be delegatedamount
: the amount of the token to be delegatedshares
: the shares of the delegate token
undelegate token from validator, get token, reward, and completion time
function undelegate(
string memory _val,
uint256 _shares
)
external
returns (uint256 _amount, uint256 _reward, uint256 _completionTime);
-
_val
: the validator address to be undelegated -
_shares
: the shares to undelegate -
_amount
: the amount of the shares undelegated -
_reward
: the reward of undelegated -
_completionTime
: the completion time of undelegated
undelegate event
event Undelegate(
address indexed sender,
string validator,
uint256 shares,
uint256 amount,
uint256 completionTime
);
sender
: the sender addressvalidator
: the validator address to be undelegatedshares
: the shares to undelegateamount
: the amount of the shares undelegatedcompletionTime
: the completion time of undelegated
redelegate token from validator to other validator, get shares and reward
function redelegate(
string memory _valSrc,
string memory _valDst,
uint256 _shares
) external returns (uint256 _amount, uint256 _reward, uint256 _completionTime);
_valSrc
: the validator address to be redelegated_valDst
: the validator address to be redelegated to_shares
: the shares to redelegate_amount
: the amount of the shares redelegated_reward
: the reward of redelegated_completionTime
: the completion time of redelegated
redelegate event
event Redelegate(
address indexed sender,
string valSrc,
string valDst,
uint256 shares,
uint256 amount,
uint256 completionTime
);
sender
: the sender addressvalSrc
: the validator address to be redelegatedvalDst
: the validator address to be redelegated toshares
: the shares to redelegateamount
: the amount of the shares redelegatedcompletionTime
: the completion time of redelegated
withdraw delegate reward
function withdraw(string memory _val) external returns (uint256 _reward);
-
_val
: the validator address to be withdraw -
_reward
: reward amount
withdraw event
event Withdraw(address indexed sender, string validator, uint256 reward);
withdrawer
: the withdraw addressvalidator
: the validator address to be withdrawreward
: reward amount
approve transferFrom shares amount
function approveShares(
string memory _val,
address _spender,
uint256 _shares
) external returns (bool _result);
-
_val
: the validator address to be approved -
_spender
: the spender address -
_shares
: the shares amount to be approved -
_result
: the result of approve
approveShares event
event ApproveShares(
address indexed owner,
address indexed spender,
string validator,
uint256 shares
);
owner
: the shares owner addressspender
: the spender addressvalidator
: the validator address to be approvedshares
: the shares amount to be approved
transfer shares to other address
function transferShares(
string memory _val,
address _to,
uint256 _shares
) external returns (uint256 _token, uint256 _reward);
-
_val
: the validator address to be transfer -
_to
: the receiver address -
_shares
: the shares amount to be transfer -
_token
: the token amount of transfer shares -
_reward
: the reward amount of to address when transfer shares
transferShares event
event TransferShares(
address indexed from,
address indexed to,
string validator,
uint256 shares,
uint256 token
);
from
: the shares owner addressto
: the receiver addressvalidator
: the validator address to be transfershares
: the shares amount to be transfertoken
: the token amount of transfer shares
transfer shares with approval
{% hint style="info" %} transfer shares from other address, need to approve first {% endhint %}
function transferFromShares(
string memory _val,
address _from,
address _to,
uint256 _shares
) external returns (uint256 _token, uint256 _reward);
-
_val
: the validator address to be transfer -
_from
: the shares owner address -
_to
: the receiver address -
_shares
: the shares amount to be transfer -
_token
: the token amount of transfer shares -
_reward
: the reward amount of to address when transfer shares
transferFromShares event(same as transferShares)
event TransferShares(
address indexed from,
address indexed to,
string validator,
uint256 shares,
uint256 token
);
from
: the shares owner addressto
: the receiver addressvalidator
: the validator address to be transfershares
: the shares amount to be transfertoken
: the token amount of transfer shares
query delegation
function delegation(
string memory _val,
address _del
) external view returns (uint256 _shares, uint256 _delegateAmount);
-
_val
: the validator address to be query -
_del
: the delegator address to be query -
_shares
: the shares of the delegator in the validator -
_delegateAmount
: the amount of the delegator in the validator
query delegation rewards
function delegationRewards(
string memory _val,
address _del
) external view returns (uint256 _reward);
-
_val
: the validator address to be query -
_del
: the delegator address to be query -
_reward
: the reward of the delegator in the validator
query allowance shares
function allowanceShares(
string memory _val,
address _owner,
address _spender
) external view returns (uint256 _shares);
-
_val
: the validator address to be query -
_owner
: the owner address to be query -
_spender
: the spender address to be query -
_shares
: the allowance shares in the validator