Payment

This page is incomplete. We’re working to improve it for the next release. Stay tuned!

Utilities

PaymentSplitter

This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware that the Ether will be split in this way, since it is handled transparently by the contract.

The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim an amount proportional to the percentage of total shares they were assigned.

PaymentSplitter follows a pull payment model. This means that payments are not automatically forwarded to the accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the release function.

constructor(address[] payees, uint256[] shares)

Creates an instance of PaymentSplitter where each account in payees is assigned the number of shares at the matching position in the shares array.

All addresses in payees must be non-zero. Both arrays must have the same non-zero length, and there must be no duplicates in payees.

fallback()

The Ether received will be logged with PaymentReceived events. Note that these events are not fully reliable: it’s possible for a contract to receive Ether without triggering this function. This only affects the reliability of the events, and not the actual splitting of Ether.

To learn more about this see the Solidity documentation for fallback functions.

totalShares() → uint256

Getter for the total shares held by payees.

totalReleased() → uint256

Getter for the total amount of Ether already released.

shares(address account) → uint256

Getter for the amount of shares held by an account.

released(address account) → uint256

Getter for the amount of Ether already released to a payee.

payee(uint256 index) → address

Getter for the address of the payee number index.

release(address payable account)

Triggers a transfer to account of the amount of Ether they are owed, according to their percentage of the total shares and their previous withdrawals.

PayeeAdded(address account, uint256 shares)

PaymentReleased(address to, uint256 amount)

PaymentReceived(address from, uint256 amount)

PullPayment

Base contract supporting async send for pull payments. Inherit from this contract and use _asyncTransfer instead of send or transfer.

constructor()

withdrawPayments(address payable payee)

Withdraw accumulated balance.

payments(address dest) → uint256

Returns the credit owed to an address.

_asyncTransfer(address dest, uint256 amount)

Called by the payer to store the sent amount as credit to be pulled.

Escrow

Escrow

Base escrow contract, holds funds designated for a payee until they withdraw them.

Intended usage: This contract (and derived escrow contracts) should be a standalone contract, that only interacts with the contract that instantiated it. That way, it is guaranteed that all Ether will be handled according to the Escrow rules, and there is no need to check for payable functions or transfers in the inheritance tree. The contract that uses the escrow as its payment method should be its primary, and provide public methods redirecting to the escrow’s deposit and withdraw.

Modifiers

depositsOf(address payee) → uint256

deposit(address payee)

Stores the sent amount as credit to be withdrawn.

withdraw(address payable payee)

Withdraw accumulated balance for a payee.

Deposited(address payee, uint256 weiAmount)

Withdrawn(address payee, uint256 weiAmount)

ConditionalEscrow

Base abstract escrow to only allow withdrawal if a condition is met. Intended usage: See Escrow. Same usage guidelines apply here.

Modifiers

withdrawalAllowed(address payee) → bool

Returns whether an address is allowed to withdraw their funds. To be implemented by derived contracts.

withdraw(address payable payee)

RefundEscrow

Escrow that holds funds for a beneficiary, deposited from multiple parties. Intended usage: See Escrow. Same usage guidelines apply here. The primary account (that is, the contract that instantiates this contract) may deposit, close the deposit period, and allow for either withdrawal by the beneficiary, or refunds to the depositors. All interactions with RefundEscrow will be made through the primary contract. See the RefundableCrowdsale contract for an example of RefundEscrow’s use.

Modifiers

constructor(address payable beneficiary)

Constructor.

state() → enum RefundEscrow.State

beneficiary() → address

deposit(address refundee)

Stores funds that may later be refunded.

close()

Allows for the beneficiary to withdraw their funds, rejecting further deposits.

enableRefunds()

Allows for refunds to take place, rejecting further deposits.

beneficiaryWithdraw()

Withdraws the beneficiary’s funds.

withdrawalAllowed(address) → bool

Returns whether refundees can withdraw their deposits (be refunded). The overridden function receives a 'payee' argument, but we ignore it here since the condition is global, not per-payee.

RefundsClosed()

RefundsEnabled()