Skip to main content

JBETHERC20SplitsPayer

Sends ETH or ERC20's to a group of splits as it receives direct payments or has its functions called.

Inherit from this contract or borrow from its logic to forward ETH or ERC20's to a group of splits from within other contracts.

Code

https://github.com/jbx-protocol/juice-contracts-v2/blob/main/contracts/JBETHERC20SplitsPayer.sol

Addresses

There can be several instances of this contract deployed.

Interfaces

NameDescription
IJBSplitsPayerGeneral interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.

Inheritance

ContractDescription
JBETHERC20ProjectPayerSends ETH or ERC20's to a project treasury as it receives direct payments or has it's functions called.
ReentrancyGuardContract module that helps prevent reentrant calls to a function.
ERC165Introspection on interface adherance.

Constructor

/**
@param _defaultSplitsProjectId The ID of project for which the default splits are stored.
@param _defaultSplitsDomain The splits domain to payout when this contract receives direct payments.
@param _defaultSplitsGroup The splits group to payout when this contract receives direct payments.
@param _splitsStore A contract that stores splits for each project.
@param _defaultProjectId The ID of the project whose treasury should be forwarded the splits payer contract's received payment leftovers after distributing to the default splits group.
@param _defaultBeneficiary The address that'll receive the project's tokens.
@param _defaultPreferClaimedTokens A flag indicating whether issued tokens should be automatically claimed into the beneficiary's wallet.
@param _defaultMemo 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.
@param _defaultMetadata Bytes to send along to the project's data source and delegate, if provided.
@param _preferAddToBalance A flag indicating if received payments should call the `pay` function or the `addToBalance` function of a project.
@param _owner The address that will own the contract.
*/
constructor(
uint256 _defaultSplitsProjectId,
uint256 _defaultSplitsDomain,
uint256 _defaultSplitsGroup,
IJBSplitsStore _splitsStore,
uint256 _defaultProjectId,
address payable _defaultBeneficiary,
bool _defaultPreferClaimedTokens,
string memory _defaultMemo,
bytes memory _defaultMetadata,
bool _preferAddToBalance,
address _owner
)
JBETHERC20ProjectPayer(
_defaultProjectId,
_defaultBeneficiary,
_defaultPreferClaimedTokens,
_defaultMemo,
_defaultMetadata,
_preferAddToBalance,
_splitsStore.directory(),
_owner
)
{
defaultSplitsProjectId = _defaultSplitsProjectId;
defaultSplitsDomain = _defaultSplitsDomain;
defaultSplitsGroup = _defaultSplitsGroup;
splitsStore = _splitsStore;
}
  • _defaultSplitsProjectId is the ID of project for which the default splits are stored.
  • _defaultSplitsDomain is the splits domain to payout when this contract receives direct payments.
  • _defaultSplitsGroup is the splits group to payout when this contract receives direct payments.
  • _splitsStore is a contract that stores splits for each project.
  • _defaultProjectId is the ID of the project whose treasury should be forwarded the splits payer contract's received payment leftovers after distributing to the default splits group.
  • _defaultBeneficiary is the address that'll receive the project's tokens.
  • _defaultPreferClaimedTokens is a flag indicating whether issued tokens should be automatically claimed into the beneficiary's wallet.
  • _defaultMemo 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.
  • _defaultMetadata are bytes to send along to the project's data source and delegate, if provided.
  • _defaultPreferAddToBalance is a flag indicating if received payments should call the pay function or the addToBalance function of a project.
  • _owner is the address that will own the contract.

Events

NameData
SetDefaultSplits
  • uint256 indexed projectId
  • uint256 indexed domain
  • uint256 indexed group
  • address caller
Pay
  • uint256 indexed projectId
  • address beneficiary
  • address token
  • uint256 amount
  • uint256 decimals
  • uint256 leftoverAmount
  • uint256 minReturnedTokens
  • bool preferClaimedTokens
  • string memo
  • bytes metadata
  • address caller
AddToBalance
  • uint256 indexed projectId
  • address beneficiary
  • address token
  • uint256 amount
  • uint256 decimals
  • uint256 leftoverAmount
  • string memo
  • bytes metadata
  • address caller
DistributeToSplitGroup
  • uint256 indexed projectId
  • uint256 indexed domain
  • uint256 indexed group
  • address caller
DistributeToSplit
  • JBSplit split
  • uint256 amount
  • address caller

Properties

NameDefinition
splitsStore

Returns

defaultSplitsProjectId

Returns

  • uint256
defaultSplitsDomain

Returns

  • uint256
defaultSplitsGroup

Returns

  • uint256

Read

FunctionDefinition
supportsInterface

Params

  • uint256 _interfaceId

Returns

  • bool

Write

FunctionDefinition
receive

Traits

  • payable
  • virtual
setDefaultSplits

Traits

Params

  • uint256 _projectId
  • uint256 _domain
  • uint256 _group
pay

Traits

  • payable
  • virtual

Params

  • uint256 _projectId
  • address _token
  • uint256 _amount
  • uint256 _decimals
  • address _beneficiary
  • uint256 _minReturnedTokens
  • bool _preferClaimedTokens
  • string _memo
  • bytes _metadata
addToBalanceOf

Traits

  • payable
  • virtual

Params

  • uint256 _projectId
  • address _token
  • uint256 _amount
  • uint256 _decimals
  • string _memo
  • bytes _metadata
_payToSplits

Traits

  • internal
  • virtual

Params

  • uint256 _splitsProjectId
  • uint256 _splitsDomain
  • uint256 _splitsGroup
  • address _token
  • uint256 _amount
  • uint256 _decimals