Skip to main content

CollectionBuyCrowdfund

A crowdfund that purchases any NFT from a collection (i.e., any token ID) from a collection for a known price. Like BuyCrowdfund but allows any token ID to be bought within a collection.

Code

CollectionBuyCrowdfund.sol

Roles

Contributors

Users who have contributed to the crowdfund.

Hosts

Trusted addresses with the ability to unilaterally veto proposals and configure Rage Quit in the Party that is created after the crowdfund is won. Will be the only role that can execute a call for the crowdfund to buy an NFT with a tokenId of their choosing when enough funds are raised.

Split Recipient

An optional address that can claim a Party Card with a reserved percentage of voting power after the crowdfund wins without needing to contribute. If they contribute, the reserved voting power reserved for them will be added to the voting power they would be entitled to from their contribution.

States

Active

The crowdfund has been created and contributions can be made. Hosts of the crowdfund can buy an NFT for the crowdfund once enough pooled funds have been raised and transition the crowdfund to the “Won” state.

Busy

A temporary state set by the contract during operations (e.g. while buying the NFT) to act as a reentrancy guard.

Won

The crowdfund has successfully acquired the NFT and a Party has been created around the NFT. Contributors can now claim their Party Cards and/or reclaim any unused contributions that did not go towards acquiring the NFT.

Lost

The crowdfund has expired and failed to acquire the NFT. Contributors can now reclaim their original contributions from the crowdfund.

Functions

contribute

Contribute to this crowdfund and/or update your delegation for the governance phase should the crowdfund succeed. For restricted crowdfunds, gateData can be provided to prove membership to the gatekeeper.

function contribute(address delegate, bytes memory gateData) external payable onlyDelegateCall;

Parameters

NameTypeDescription
delegateaddressThe address to delegate to for the governance phase.
gateDatabytesData to pass to the gatekeeper to prove eligibility.

contributeFor

Contribute to this crowdfund on behalf of another address.

function contributeFor(address recipient, address initialDelegate, bytes memory gateData)
external
payable
onlyDelegateCall;

Parameters

NameTypeDescription
recipientaddressThe address to record the contribution under.
initialDelegateaddressThe address to delegate to for the governance phase if recipient hasn't delegated.
gateDatabytesData to pass to the gatekeeper to prove eligibility.

batchContributeFor

contributeFor() in batch form. May not revert if any individual contribution fails.

function batchContributeFor(
address[] memory recipients,
address[] memory initialDelegates,
uint256[] memory values,
bytes[] memory gateDatas,
bool revertOnFailure
) external payable;

Parameters

NameTypeDescription
recipientsaddress[]The addresses to record the contributions under.
initialDelegatesaddress[]The addresses to delegate to for each recipient.
valuesuint256[]The ETH to contribute for each recipient.
gateDatasbytes[]Data to pass to the gatekeeper to prove eligibility.
revertOnFailureboolIf true, revert if any contribution fails.

buy

Execute arbitrary calldata to perform a buy, creating a Party if it successfully buys the NFT. Only a host may call this.

function buy(
uint256 tokenId,
address payable callTarget,
uint96 callValue,
bytes memory callData,
FixedGovernanceOpts memory governanceOpts,
uint256 hostIndex
) external onlyDelegateCall returns (Party party_);

Parameters

NameTypeDescription
tokenIduint256The token ID of the NFT in the collection to buy.
callTargetaddress payableThe target contract to call to buy the NFT.
callValueuint96The amount of ETH to send with the call.
callDatabytesThe calldata to execute.
governanceOptsFixedGovernanceOptsThe options used to initialize governance in the Party instance created if the buy was successful.
hostIndexuint256This is the index of the caller in the governanceOpts.hosts array.

Returns

NameTypeDescription
party_PartyAddress of the Party instance created after its bought.

activateOrRefund

Burn the participation NFT for contributor, potentially minting voting power and/or refunding unused ETH. contributor may also be the split recipient, regardless of whether they are also a contributor or not. This can be called by anyone on a contributor's behalf to unlock their voting power in the governance stage ensuring delegates receive their voting power and governance is not stalled.

function activateOrRefund(address payable contributor) external;

NameTypeDescription
contributoraddress payableThe contributor whose NFT to burn for.

batchActivateOrRefund

activateOrRefund() in batch form. Will not revert if any individual burn fails.

function batchActivateOrRefund(address payable[] calldata contributors, bool revertOnFailure) external;

NameTypeDescription
contributorsaddress payable[]The contributors whose NFT to burn for.
revertOnFailureboolIf true, revert if any burn fails.

claim

Claim a Party Card or refund that is owed back but could not be given due to error in _burn() (eg. a contract that does not implement onERC721Received() or cannot receive ETH). Only call this if refund and Party Card minting could not be returned with burn().

function claim(address payable receiver) external;

Parameters

NameTypeDescription
receiveraddress payableThe address to receive the NFT or refund.

getContributorInfo

Retrieve info about a participant's contributions.

This will only be called off-chain so doesn't have to be optimal.

function getContributorInfo(address contributor)
external
view
returns (uint256 ethContributed, uint256 ethUsed, uint256 ethOwed, uint256 votingPower);

Parameters

NameTypeDescription
contributoraddressThe contributor to retrieve contributions for.

Returns

NameTypeDescription
ethContributeduint256The total ETH contributed by contributor.
ethUseduint256The total ETH used by contributor to acquire the NFT.
ethOweduint256The total ETH refunded back to contributor.
votingPoweruint256The total voting power minted to contributor.

getCrowdfundLifecycle

Get the current lifecycle of the crowdfund.

function getCrowdfundLifecycle() public view virtual returns (CrowdfundLifecycle lifecycle);