payStaker Functions
The payStaker functions process single payments where the transaction executor (msg.sender) must be a token staker. These functions provide enhanced benefits including priority fee rewards and principal token rewards for stakers who process transactions.
Staker benefits include receiving priority fees as rewards for transaction processing and earning principal token rewards upon successful execution. These functions support both direct addresses and identity-based payments through the NameService.
For detailed information on nonce types, please refer to the Nonce Types in EVVM section. The signature structure for these payments is detailed in the Payment Signature Structure section.
payStaker_sync
Function Type: external
Function Signature: payStaker_sync(address,address,string,address,uint256,uint256,address,bytes)
Function Selector: 0x4faa1fa2
Processes synchronous payments for principal token stakers with enhanced benefits and rewards. This function provides staker benefits including priority fee rewards and principal token rewards, while using automatic nonce increment for sequential transaction ordering.
Parameters
| Field | Type | Description |
|---|---|---|
from | address | The address of the payment sender whose funds are being transferred and whose signature/nonce are validated. |
to_address | address | Direct recipient address. Used when to_identity is empty. |
to_identity | string | Username/identity of the recipient. If provided, the contract resolves it to an address via the NameService. |
token | address | The token address for the transfer. |
amount | uint256 | The quantity of tokens to transfer from from to the recipient. |
priorityFee | uint256 | Fee amount distributed to stakers as reward for processing the transaction. |
executor | address | Address authorized to execute this transaction (must be a staker). Use address(0) to allow any staker to execute. |
signature | bytes | Cryptographic signature (EIP-191) from the from address authorizing this payment. |
There is no explicit nonce parameter; the synchronous nonce is automatically managed and validated as part of the signature verification process.
Execution Methods
This function can only be executed by principal token stakers:
Fisher Execution
- A user signs the payment details and sends the request (parameters + signature) to a fishing spot.
- The fisher (who must be a registered staker) captures the transaction and validates the request.
- The fisher submits the transaction to the function for processing and receives rewards.
Direct Execution
When the executor is a staker user or service:
- The staker user/service directly calls the
payStaker_syncfunction. - The executor receives priority fee rewards and principal token rewards for processing.
When using a service as the executor, we recommend specifying the service's address in the executor parameter for additional security.
Workflow
- Signature Verification: Validates the
signatureagainst thefromaddress and other parameters usingverifyMessageSignedForPay. This includes checking that the synchronous nonce matches the expected next nonce for thefromaddress. Reverts withInvalidSignatureon failure. - Executor Validation: If
executoris notaddress(0), checks thatmsg.sendermatches theexecutoraddress. Reverts withSenderIsNotTheExecutorif they don't match. - Staker Verification: Verifies that the
msg.sender(executor) is a registered staker using theisAddressStakerfunction. Reverts withNotAnStakerifmsg.senderis not a staker. - Resolve Recipient Address: Determines the final recipient address:
- If
to_identityis provided (not empty), resolves the identity to an owner address usingverifyStrictAndGetOwnerOfIdentityfrom the NameService contract. - If
to_identityis empty, uses the providedto_address.
- If
- Balance Update: Executes the main payment transfer using the
_updateBalancefunction, sendingamountoftokenfrom thefromaddress to the resolved recipient address. Reverts withUpdateBalanceFailedon transfer failure. - Priority Fee Distribution: If
priorityFee > 0, transfers thepriorityFeeamount oftokenfrom thefromaddress to themsg.sender(executor) as a staker reward. Reverts withUpdateBalanceFailedon transfer failure. - Principal Token Reward: Grants 1 principal token reward to the
msg.sender(executor) using the_giveMateRewardfunction. - Nonce Increment: Increments the synchronous nonce counter for the
fromaddress to prevent replay attacks.
For more information about the signature structure, refer to the Payment Signature Structure section.
payStaker_async
Function Type: external
Function Signature: payStaker_async(address,address,string,address,uint256,uint256,uint256,address,bytes)
Function Selector: 0xf4e1895b
Processes asynchronous payments for principal token stakers with enhanced benefits and custom nonce management. This function provides staker benefits including priority fee rewards and principal token rewards, while using custom nonces for flexible transaction ordering and replay protection.
Parameters
| Field | Type | Description |
|---|---|---|
from | address | The address of the payment sender whose funds are being transferred and whose signature/nonce are validated. |
to_address | address | Direct recipient address. Used when to_identity is empty. |
to_identity | string | Username/identity of the recipient. If provided, the contract resolves it to an address via the NameService. |
token | address | The token contract address for the transfer. |
amount | uint256 | The quantity of tokens to transfer from from to the recipient. |
priorityFee | uint256 | Fee amount distributed to stakers as reward for processing the transaction. |
nonce | uint256 | Custom nonce value for transaction ordering and replay protection. |
executor | address | Address authorized to execute this transaction (must be a staker). Use address(0) to allow any staker to execute. |
signature | bytes | Cryptographic signature (EIP-191) from the from address authorizing this payment. |
Execution Methods
This function can only be executed by principal token stakers:
Fisher Execution
- A user signs the payment details and sends the request (parameters + signature) to a fishing spot.
- The fisher (who must be a registered staker) captures the transaction and validates the request.
- The fisher submits the transaction to the function for processing and receives rewards.
Direct Execution
When the executor is a staker user or service:
- The staker user/service directly calls the
payStaker_asyncfunction. - The executor receives priority fee rewards and principal token rewards for processing.
When using a service as the executor, we recommend specifying the service's address in the executor parameter for additional security.
Workflow
- Signature Verification: Validates the
signatureagainst thefromaddress and other parameters usingverifyMessageSignedForPay. Reverts withInvalidSignatureon failure. - Executor Validation: If
executoris notaddress(0), checks thatmsg.sendermatches theexecutoraddress. Reverts withSenderIsNotTheExecutorif they don't match. - Staker Verification: Verifies that the
msg.sender(executor) is a registered staker using theisAddressStakerfunction. Reverts withNotAnStakerifmsg.senderis not a staker. - Async Nonce Verification: Checks if the provided
noncehas already been used for thefromaddress by consulting theasyncUsedNoncemapping. Reverts withInvalidAsyncNonceif the nonce has already been used. - Resolve Recipient Address: Determines the final recipient address:
- If
to_identityis provided (not empty), resolves the identity to an owner address usingverifyStrictAndGetOwnerOfIdentityfrom the NameService contract. - If
to_identityis empty, uses the providedto_address.
- If
- Balance Update: Executes the main payment transfer using the
_updateBalancefunction, sendingamountoftokenfrom thefromaddress to the resolved recipient address. Reverts withUpdateBalanceFailedon transfer failure. - Priority Fee Distribution: If
priorityFee > 0, transfers thepriorityFeeamount oftokenfrom thefromaddress to themsg.sender(executor) as a staker reward. Reverts withUpdateBalanceFailedon transfer failure. - Principal token Reward: Grants 1 principal token reward to the
msg.sender(executor) using the_giveMateRewardfunction. Reverts withUpdateBalanceFailedon failure. - Nonce Marking: Marks the specific asynchronous
nonceas used (true) for thefromaddress in theasyncUsedNoncemapping to prevent replay attacks.
For more information about the signature structure, refer to the Payment Signature Structure section.