Skip to main content

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 via extcodesize).
  • 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 or async) 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

FieldTypeDescription
toaddressThe recipient's direct address.
tokenaddressThe specific token address for this individual transfer.
amountuint256The quantity of token to transfer from from to the recipient.

Workflow

  1. CA Verification: Validates that the transaction sender (msg.sender) is indeed a smart contract by checking if its extcodesize is greater than 0. Reverts if msg.sender is an Externally Owned Account (EOA).
  2. 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 specified token to cover the amount. If the balance is sufficient, it then debits amount of token from the msg.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.
  3. Executor Reward (Conditional):
    • Checks if the calling contract (msg.sender) is an sMATE staker using isMateStaker(msg.sender).
    • If msg.sender is a staker, grants 1 MATE token reward to the msg.sender using the _giveMateReward function.

caPay