Skip to main content

receive

Contract: JBETHERC20SplitsPayer

Interface: IJBSplitsPayer

Received funds are paid to the default split group using the stored default properties.

This function is called automatically when the contract receives an ETH payment.

Definition​

receive() external payable virtual override { ... }
  • The function is triggered when the contract receives ETH.
  • The function can be accessed externally by anyone.
  • The function doesn't return anything.

Body​

  1. Pay the splits and get a reference to the leftover amount.

    // Pay the splits and get a reference to the amount leftover.
    uint256 _leftoverAmount = _payToSplits(
    defaultSplitsProjectId,
    defaultSplitsDomain,
    defaultSplitsGroup,
    JBTokens.ETH,
    address(this).balance,
    18, // decimals.
    defaultBeneficiary != address(0) ? defaultBeneficiary : tx.origin
    );

    Internal references:

  2. If there's no leftover amount, there's nothing left to do.

    // If there is no leftover amount, nothing left to pay.
    if (_leftoverAmount == 0) return;
  3. Pay the leftover ETH to the default project ID using the default parameters. Use the addToBalance function if there's a preference to do so. If there's no default project ID, send to the default beneficiary if there is one, otherwise send to the message sender.

    // If there's a default project ID, try to pay it.
    if (defaultProjectId != 0)
    if (defaultPreferAddToBalance)
    // Pay the project by adding to its balance if prefered.
    _addToBalanceOf(
    defaultProjectId,
    JBTokens.ETH,
    _leftoverAmount,
    18, // decimals.
    defaultMemo,
    defaultMetadata
    );
    // Otherwise, issue a payment to the project.
    else
    _pay(
    defaultProjectId,
    JBTokens.ETH,
    _leftoverAmount,
    18, // decimals.
    defaultBeneficiary != address(0) ? defaultBeneficiary : tx.origin,
    0, // min returned tokens.
    defaultPreferClaimedTokens,
    defaultMemo,
    defaultMetadata
    );
    // If no project was specified, send the funds directly to the beneficiary or the tx.origin.
    else
    Address.sendValue(
    defaultBeneficiary != address(0) ? payable(defaultBeneficiary) : payable(tx.origin),
    _leftoverAmount
    );

    Library references:

    Internal references:

* [`defaultProjectId`](/dev/api/contracts/or-utilities/jbetherc20projectpayer/properties/defaultprojectid)
* [`defaultPreferClaimedTokens`](/dev/api/contracts/or-utilities/jbetherc20projectpayer/properties/defaultpreferclaimedtokens)
* [`defaultMemo`](/dev/api/contracts/or-utilities/jbetherc20projectpayer/properties/defaultmemo)
* [`defaultMetadata`](/dev/api/contracts/or-utilities/jbetherc20projectpayer/properties/defaultmetadata)
* [`defaultBeneficiary`](/dev/api/contracts/or-utilities/jbetherc20projectpayer/properties/defaultbeneficiary)
* [`_addToBalanceOf`](/dev/api/contracts/or-utilities/jbetherc20projectpayer/write/-_addtobalanceof)
* [`_pay`](/dev/api/contracts/or-utilities/jbetherc20projectpayer/write/-_pay)