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_sync
function. - 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
signature
against thefrom
address and other parameters usingverifyMessageSignedForPay
. This includes checking that the synchronous nonce matches the expected next nonce for thefrom
address. Reverts withInvalidSignature
on failure. - Executor Validation: If
executor
is notaddress(0)
, checks thatmsg.sender
matches theexecutor
address. Reverts withSenderIsNotTheExecutor
if they don't match. - Staker Verification: Verifies that the
msg.sender
(executor) is a registered staker using theisAddressStaker
function. Reverts withNotAnStaker
ifmsg.sender
is not a staker. - Resolve Recipient Address: Determines the final recipient address:
- If
to_identity
is provided (not empty), resolves the identity to an owner address usingverifyStrictAndGetOwnerOfIdentity
from the NameService contract. - If
to_identity
is empty, uses the providedto_address
.
- If
- Balance Update: Executes the main payment transfer using the
_updateBalance
function, sendingamount
oftoken
from thefrom
address to the resolved recipient address. Reverts withUpdateBalanceFailed
on transfer failure. - Priority Fee Distribution: If
priorityFee > 0
, transfers thepriorityFee
amount oftoken
from thefrom
address to themsg.sender
(executor) as a staker reward. Reverts withUpdateBalanceFailed
on transfer failure. - Principal Token Reward: Grants 1 principal token reward to the
msg.sender
(executor) using the_giveMateReward
function. - Nonce Increment: Increments the synchronous nonce counter for the
from
address 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_async
function. - 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
signature
against thefrom
address and other parameters usingverifyMessageSignedForPay
. Reverts withInvalidSignature
on failure. - Executor Validation: If
executor
is notaddress(0)
, checks thatmsg.sender
matches theexecutor
address. Reverts withSenderIsNotTheExecutor
if they don't match. - Staker Verification: Verifies that the
msg.sender
(executor) is a registered staker using theisAddressStaker
function. Reverts withNotAnStaker
ifmsg.sender
is not a staker. - Async Nonce Verification: Checks if the provided
nonce
has already been used for thefrom
address by consulting theasyncUsedNonce
mapping. Reverts withInvalidAsyncNonce
if the nonce has already been used. - Resolve Recipient Address: Determines the final recipient address:
- If
to_identity
is provided (not empty), resolves the identity to an owner address usingverifyStrictAndGetOwnerOfIdentity
from the NameService contract. - If
to_identity
is empty, uses the providedto_address
.
- If
- Balance Update: Executes the main payment transfer using the
_updateBalance
function, sendingamount
oftoken
from thefrom
address to the resolved recipient address. Reverts withUpdateBalanceFailed
on transfer failure. - Priority Fee Distribution: If
priorityFee > 0
, transfers thepriorityFee
amount oftoken
from thefrom
address to themsg.sender
(executor) as a staker reward. Reverts withUpdateBalanceFailed
on transfer failure. - Principal token Reward: Grants 1 principal token reward to the
msg.sender
(executor) using the_giveMateReward
function. Reverts withUpdateBalanceFailed
on failure. - Nonce Marking: Marks the specific asynchronous
nonce
as used (true
) for thefrom
address in theasyncUsedNonce
mapping to prevent replay attacks.
For more information about the signature structure, refer to the Payment Signature Structure section.