Skip to main content

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.

Important Execution Patterns

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

ParameterTypeDescription
useraddressAddress of the user who owns the stake
serviceaddressAddress of the smart contract performing the staking
isStakingbooltrue = Stake, false = Unstake
amountOfStakinguint256Amount of staking tokens to stake/unstake
nonceuint256Unique nonce for this staking operation
signaturebytesSignature proving authorization for service staking
priorityFee_EVVMuint256EVVM priority fee (only for staking)
nonce_EVVMuint256EVVM nonce (only for staking)
priorityFlag_EVVMboolEVVM priority flag (only for staking)
signature_EVVMbytesEVVM signature (only for staking)
note

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

  1. Public Staking Status: Verifies allowPublicStaking.flag is enabled, reverts with PublicStakingDisabled() if disabled
  2. Service Verification: Confirms the service address contains contract code using extcodesize, reverts with AddressIsNotAService() if no code found
  3. User Authorization: Validates the user's signature authorizing the service to stake on their behalf using verifyMessageSignedForPublicServiceStake(), reverts with InvalidSignatureOnStaking() if invalid
  4. Nonce Validation: Confirms the staking nonce is unused using checkIfStakeNonceUsed(), reverts with StakingNonceAlreadyUsed() if already used
  5. Process Execution: Calls stakingServiceProcess() to handle:
    • Historical record updates
    • Unstaking cooldown management
    • Re-staking restrictions
    • EVVM payment processing
    • Reward distribution
  6. Nonce Update: Marks the staking nonce as used in stakingNonce[user][nonce] = true
info

For detailed information about the stakingServiceProcess function, refer to the stakingServiceProcess.

publicServiceStaking Staking Process - Happy Path publicServiceStaking Staking Process - Failed Path

Unstaking Process

  1. Public Staking Status: Verifies allowPublicStaking.flag is enabled, reverts with PublicStakingDisabled() if disabled
  2. Service Verification: Confirms the service address contains contract code using extcodesize, reverts with AddressIsNotAService() if no code found
  3. Service Authentication: Validates that service == user (the contract is calling for itself), reverts with UserAndServiceMismatch() if they don't match
  4. Nonce Validation: Confirms the staking nonce is unused using checkIfStakeNonceUsed(), reverts with StakingNonceAlreadyUsed() if already used
  5. Process Execution: Calls stakingServiceProcess() to handle:
    • Historical record updates
    • Unstaking cooldown management
    • Re-staking restrictions
    • EVVM payment processing (with default values)
    • Reward distribution
  6. Nonce Update: Marks the staking nonce as used in stakingNonce[user][nonce] = true
info

For detailed information about the stakingServiceProcess function, refer to the stakingServiceProcess.

publicServiceStaking Unstaking Process - Happy Path publicServiceStaking Unstaking Process - Failed Path