caPay Function
Function Type: external
Function Signature: caPay(address,address,uint256)
Function Selector: 0xc898a6e9
The caPay
function facilitates single payments initiated directly by a smart contract address (CA), which acts as the msg.sender
. This function bypasses several requirements typically imposed on user-initiated payments.
Key Features:
- Executor must be a Contract: The
msg.sender
calling this function must be a smart contract (verified viaextcodesize
). - No sMATE Required (but Rewarded): The calling contract (
msg.sender
) does not need to be an sMATE staker to execute the payment. However, if it is a staker, it can receive MATE rewards. - No EVVM Nonce: Does not use the nonce system (
sync
orasync
) for replay protection, as contract calls rely on standard blockchain transaction nonces. - No MNS Signature: Does not require an EIP-191 signature from the
msg.sender
(the contract) to authorize the payment. Authorization is implicit by the contract calling the function. - No Priority Fee: Does not include a mechanism for processing a separate priority fee for the payment.
Parameters
Field | Type | Description |
---|---|---|
to | address | The recipient's direct address. |
token | address | The specific token address for this individual transfer. |
amount | uint256 | The quantity of token to transfer from from to the recipient. |
Workflow
- CA Verification: Validates that the transaction sender (
msg.sender
) is indeed a smart contract by checking if itsextcodesize
is greater than 0. Reverts ifmsg.sender
is an Externally Owned Account (EOA). - Balance Check and Payment Transfer: Executes the payment using an internal function
_updateBalance
. This function first verifies that the calling contract (msg.sender
) has a sufficient balance of the specifiedtoken
to cover theamount
. If the balance is sufficient, it then debitsamount
oftoken
from themsg.sender
's internal balance and credits it to the resolved recipient's internal balance. Reverts if the balance check fails or if the transfer itself encounters an error. - Executor Reward (Conditional):
- Checks if the calling contract (
msg.sender
) is an sMATE staker usingisMateStaker(msg.sender)
. - If
msg.sender
is a staker, grants 1 MATE token reward to themsg.sender
using the_giveMateReward
function.
- Checks if the calling contract (