Payable functions¶
Native PQAI behaves exactly like ether in the EVM: msg.value is in wei (1 PQAI = 10^18 wei).
function tip(address to) external payable { … } // accepts PQAI with a call
receive() external payable { … } // plain transfers with empty calldata
- A non-payable function reverts if
msg.value > 0. - Pull, don't push. Credit balances and let recipients
withdraw(); set state to zero before sending (TipJar.withdraw,ServiceEscrow.withdraw). A recipient that reverts then cannot block others. - Use
call{value: amount}("")and check the result;transfer/sendforward only 2300 gas. - The tested
TipJarshows a payable function, a basis-point fee via a library and a pull withdrawal. SELFDESTRUCTcan force PQAI into a contract without calling it; never rely onaddress(this).balancefor accounting.
Sources at 72057fe3ec: developers/examples/patterns/src/TipJar.sol · contracts/ai/ServiceEscrow.sol
Found a problem? Report a documentation issue · Build testnet-rc1+72057fe3ec