Skip to main content

caPay Function

Function Type: external
Function Signature: caPay(address,address,uint256)

Contract-to-address payment function designed for authorized smart contracts to distribute tokens without signature verification. This function allows registered smart contracts to efficiently transfer tokens using direct balance manipulation, primarily for automated distributions and system payouts.

Key Features

  • Execution Control: Execution is controlled by the UserValidator system. If a UserValidator is configured, only addresses allowed by the validator can call this function.
  • No Signature Required: Bypasses signature verification as authorization is implicit through contract execution
  • No Nonce Management: Does not use EVVM nonce systems since contracts rely on blockchain transaction nonces
  • Automated Distributions: Designed for staking rewards, NameService fees, and other automated system payouts
  • Staker Rewards: Contracts that are registered stakers receive principal token rewards for successful transfers

Parameters

FieldTypeDescription
toaddressThe recipient's address for the token transfer.
tokenaddressThe token address to transfer.
amountuint256The quantity of tokens to transfer from the calling contract.

Workflow

  1. User Validation: Checks if the caller is allowed to execute transactions via canExecuteUserTransaction(). If a UserValidator is configured and the caller is not allowed, reverts with UserCannotExecuteTransaction().

  2. Balance Update: Executes the token transfer using the _updateBalance function:

    • Verifies the calling contract has sufficient token balance
    • Debits the amount from the calling contract's balance
    • Credits the amount to the recipient's balance
    • Reverts with UpdateBalanceFailed if the transfer fails
  3. Staker Reward: If the calling contract is a registered staker (isAddressStaker(msg.sender)), grants 1 principal token reward using _giveReward.