Skip to main content

publicStaking

Signature Verification

publicStaking uses Core.sol's centralized verification via validateAndConsumeNonce() with StakingHashUtils.hashDataForPublicStake(). Includes dual-executor parameters: senderExecutor (msg.sender restriction) and originExecutor (tx.origin restriction).

Function Type: external
Function Signature: publicStaking(address user, bool isStaking, uint256 amountOfStaking, address senderExecutor, address originExecutor, uint256 nonce, bytes signature, uint256 priorityFeePay, uint256 noncePay, bytes signaturePay)
Function Selector: 0x21cc1749

The publicStaking function enables universal access to MATE token staking when the allowPublicStaking.flag is enabled, regardless of presale participation status or account type.

info

Note: In this repository's contract implementation the constructor enables allowPublicStaking.flag by default and leaves allowPresaleStaking.flag disabled. Deployments and testnets may use different defaults; consult the deployed contract metadata for runtime flag values.

Parameters

ParameterTypeDescription
useraddressUser address
isStakingbooltrue = Stake, false = Unstake
amountOfStakinguint256Amount of staking tokens to stake/unstake
senderExecutoraddressOptional msg.sender restriction. Use address(0) for any service, or specify address to restrict execution.
originExecutoraddressEOA that will execute the transaction (verified with tx.origin)
nonceuint256Core nonce for this signature (prevents replay attacks)
signaturebytesUser authorization signature
priorityFeePayuint256Optional priority fee for faster processing
noncePayuint256Core nonce for the payment operation
signaturePaybytesUser's signature authorizing the payment
note

Workflow

The function supports two execution paths:

  • Fisher-Mediated: A designated fisher captures the transaction from the fishing spot and submits it to the contract
  • Direct User Submission: The user directly submits the transaction to the contract

Staking Process

  1. Feature Status Verification: Confirms allowPublicStaking.flag is enabled

  2. Centralized Verification: Validates signature and consumes nonce via Core.sol:

core.validateAndConsumeNonce(
user,
senderExecutor,
Hash.hashDataForPublicStake(isStaking, amountOfStaking),
originExecutor,
nonce,
true, // Always async
signature
);

Validates:

  • Signature authenticity via EIP-191
  • Nonce hasn't been consumed
  • msg.sender matches senderExecutor (if specified)
  • Executor is the specified EOA (via tx.origin)

On Failure:

  • Core__InvalidSignature() - Invalid signature
  • Core__NonceAlreadyUsed() - Nonce consumed
  • Core__InvalidExecutor() - Executing EOA doesn't match originExecutor
  1. Process Execution: Calls the internal stakingBaseProcess function with:
    • User address and IsAService=false in AccountMetadata
    • Specified amount of staking tokens
    • Standard EVVM payment processing
    • Historical record updates and reward distribution
info

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

Unstaking Process

  1. Feature Status Verification: Confirms allowPublicStaking.flag is enabled

  2. Centralized Verification: Validates signature and consumes nonce via Core.sol (same as staking)

  3. Process Execution: Calls the internal stakingBaseProcess function with:

    • User address and IsAService=false in AccountMetadata
    • Specified amount of staking tokens
    • Standard EVVM payment processing
    • Historical record updates and reward distribution
info

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