Finance
This document is better viewed at https://docs.openzeppelin.com/contracts/api/finance |
This directory includes primitives for financial systems. We currently only offer the PaymentSplitter
contract, but we want to grow this directory so we welcome ideas.
PaymentSplitter
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_)
public
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
.
receive()
external
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.
released(address account) → uint256
public
Getter for the amount of Ether already released to a payee.