publicServiceStaking
Function Type: external
Function Signature: publicServiceStaking(address,address,bool,uint256,uint256,bytes,uint256,uint256,bool,bytes)
Function Selector: 0xe2ccd470
The publicServiceStaking
function allows smart contracts (services) to stake on behalf of users when public staking is enabled. This function includes additional verification to ensure the service address contains contract code.
Staking Operations: The user executes the transaction, authorizing a service contract to stake on their behalf. The user provides their signature to delegate staking authority to the service.
Unstaking Operations: Only the service contract itself can execute unstaking operations. The service must call this function where service == user
(the contract is both the caller and the beneficiary).
Parameters
Parameter | Type | Description |
---|---|---|
user | address | Address of the user who owns the stake |
service | address | Address of the smart contract performing the staking |
isStaking | bool | true = Stake, false = Unstake |
amountOfStaking | uint256 | Amount of staking tokens to stake/unstake |
nonce | uint256 | Unique nonce for this staking operation |
signature | bytes | Signature proving authorization for service staking |
priorityFee_EVVM | uint256 | EVVM priority fee (only for staking) |
nonce_EVVM | uint256 | EVVM nonce (only for staking) |
priorityFlag_EVVM | bool | EVVM priority flag (only for staking) |
signature_EVVM | bytes | EVVM signature (only for staking) |
- If you want to know more about the signature structure for public service staking, refer to the Public Service Staking Signature Structure.
- The EVVM payment signature (
signature_EVVM
) follows the Single Payment Signature Structure.
Workflow
The function supports two execution paths based on the operation type:
- Staking Operations: User executes transaction to authorize service contract staking
- Unstaking Operations: Service contract directly executes its own unstaking operations
Staking Process
- Public Staking Status: Verifies
allowPublicStaking.flag
is enabled, reverts withPublicStakingDisabled()
if disabled - Service Verification: Confirms the service address contains contract code using
extcodesize
, reverts withAddressIsNotAService()
if no code found - User Authorization: Validates the user's signature authorizing the service to stake on their behalf using
verifyMessageSignedForPublicServiceStake()
, reverts withInvalidSignatureOnStaking()
if invalid - Nonce Validation: Confirms the staking nonce is unused using
checkIfStakeNonceUsed()
, reverts withStakingNonceAlreadyUsed()
if already used - Process Execution: Calls
stakingServiceProcess()
to handle:- Historical record updates
- Unstaking cooldown management
- Re-staking restrictions
- EVVM payment processing
- Reward distribution
- Nonce Update: Marks the staking nonce as used in
stakingNonce[user][nonce] = true
For detailed information about the stakingServiceProcess
function, refer to the stakingServiceProcess.
Unstaking Process
- Public Staking Status: Verifies
allowPublicStaking.flag
is enabled, reverts withPublicStakingDisabled()
if disabled - Service Verification: Confirms the service address contains contract code using
extcodesize
, reverts withAddressIsNotAService()
if no code found - Service Authentication: Validates that
service == user
(the contract is calling for itself), reverts withUserAndServiceMismatch()
if they don't match - Nonce Validation: Confirms the staking nonce is unused using
checkIfStakeNonceUsed()
, reverts withStakingNonceAlreadyUsed()
if already used - Process Execution: Calls
stakingServiceProcess()
to handle:- Historical record updates
- Unstaking cooldown management
- Re-staking restrictions
- EVVM payment processing (with default values)
- Reward distribution
- Nonce Update: Marks the staking nonce as used in
stakingNonce[user][nonce] = true
For detailed information about the stakingServiceProcess
function, refer to the stakingServiceProcess.