Pull Payment
Last updated
Last updated
Simple implementation of a https://consensys.github.io/smart-contract-best-practices/recommendations/#favor-pull-over-push-for-external-calls[pull-payment] strategy, where the paying contract doesn't interact directly with the receiver account, which must withdraw its payments itself. Pull-payments are often considered the best practice when it comes to sending Ether, security-wise. It prevents recipients from blocking execution, and eliminates reentrancy concerns. TIP: If you would like to learn more about reentrancy and alternative ways to protect against it, check out our blog post https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. To use, derive from the PullPayment
contract, and use {_asyncTransfer} instead of Solidity's transfer
function. Payees can query their due payments with {payments}, and retrieve them with {withdrawPayments}.
Returns the payments owed to an address.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Withdraw accumulated payments, forwarding all gas to the recipient. Note that any account can call this function, not just the payee
. This means that contracts unaware of the PullPayment
protocol can still receive funds this way, by having a separate account call {withdrawPayments}. WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities. Make sure you trust the recipient, or are either following the checks-effects-interactions pattern or using {ReentrancyGuard}.
Name | Type | Description |
---|---|---|
dest
address
The creditor's address.
_0
uint256
undefined
payee
address payable
Whose payments will be withdrawn.