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
| Field | Type | Description |
|---|---|---|
to | address | The recipient's address for the token transfer. |
token | address | The token address to transfer. |
amount | uint256 | The quantity of tokens to transfer from the calling contract. |
Workflow
-
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 withUserCannotExecuteTransaction(). -
Balance Update: Executes the token transfer using the
_updateBalancefunction:- Verifies the calling contract has sufficient token balance
- Debits the
amountfrom the calling contract's balance - Credits the
amountto the recipient's balance - Reverts with
UpdateBalanceFailedif the transfer fails
-
Staker Reward: If the calling contract is a registered staker (
isAddressStaker(msg.sender)), grants 1 principal token reward using_giveReward.