Skip to main content


Contract: JBETHERC20ProjectPayer

Make a payment to the specified project.


function _pay(
uint256 _projectId,
address _token,
uint256 _amount,
uint256 _decimals,
address _beneficiary,
uint256 _minReturnedTokens,
bool _preferClaimedTokens,
string memory _memo,
bytes memory _metadata
) internal virtual { ... }
  • Arguments:
    • _projectId is the ID of the project that is being paid.
    • _token is the token being paid in. Use JBTokens.ETH if paying in ETH.
    • _amount is the amount of tokens being paid, as a fixed point number. If the token is ETH, this is ignored and msg.value is used in its place.
    • _decimals is the number of decimals in the _amount fixed point number. If the token is ETH, this is ignored and 18 is used in its place, which corresponds to the amount of decimals expected in msg.value.
    • _beneficiary is the address who will receive tokens from the payment.
    • _minReturnedTokens is the minimum number of project tokens expected in return, as a fixed point number with 18 decimals.
    • _preferClaimedTokens is a flag indicating whether the request prefers to mint project tokens into the beneficiaries wallet rather than leaving them unclaimed. This is only possible if the project has an attached token contract. Leaving them unclaimed saves gas.
    • _memo is a memo to pass along to the emitted event, and passed along the the funding cycle's data source and delegate. A data source can alter the memo before emitting in the event and forwarding to the delegate.
    • _metadata are bytes to send along to the data source, delegate, and emitted event, if provided.
  • The function is private to this contract.
  • The function doesn't return anything.


  1. Get a reference to the terminal that should be sent the payment by checking for the project's stored primary terminal for the token being paid.

    // Find the terminal for the specified project.
    IJBPaymentTerminal _terminal = directory.primaryTerminalOf(_projectId, _token);

    Internal references:

    External references:

  2. Make sure there is a terminal to make a payment towards.

    // There must be a terminal.
    if (_terminal == IJBPaymentTerminal(address(0))) revert TERMINAL_NOT_FOUND();
  3. Make sure the number of decimals in the amount being paid matches the number of decimals expected by the terminal.

    // The amount's decimals must match the terminal's expected decimals.
    if (_terminal.decimalsForToken(_token) != _decimals) revert INCORRECT_DECIMAL_AMOUNT();

    External references:

  4. If the token being paid is an ERC20, approve the terminal to spend the amount of tokens from this terminal.

    // Approve the `_amount` of tokens from the destination terminal to transfer tokens from this contract.
    if (_token != JBTokens.ETH) IERC20(_token).safeApprove(address(_terminal), _amount);

    Library references:

    External references:

  5. Keep a reference to the amount to send in the transaction. If the token being paid is ETH, send the value along with the tx.

    // If the token is ETH, send it in msg.value.
    uint256 _payableValue = _token == JBTokens.ETH ? _amount : 0;

    Library references:

  6. Send the payment to the terminal with the provided properties. If no beneficiary was specified, set the message sender as the beneficiary.

    // Send funds to the terminal.
    // If the token is ETH, send it in msg.value.{value: _payableValue}(
    _amount, // ignored if the token is JBTokens.ETH.
    _beneficiary != address(0) ? _beneficiary : tx.origin,

    External references: