Deploying a CrowdFi Contract
CrowdFi contracts are deployed by invoking the deployCampaign
function on
the factory contract for a given network. The function uses OpenZeppelin Clones to create a proxy and initialize
the contract with campaign parameters.
Campaign Parameters
Name | Type | Description |
---|---|---|
recipient | address | the address of the recipient, where funds are sent on success |
minGoal | uint256 | the minimum funding amount acceptable for successful financing |
maxGoal | uint256 | the maximum funding amount accepted for the financing round |
minContribution | uint256 | the minimum deposit an account can make in one deposit |
maxContribution | uint256 | the maximum deposit an account can make in one or more deposits |
holdOff | uint32 | the number of seconds to wait until the campaign starts |
duration | uint32 | the runtime of the campaign, in seconds |
erc20TokenAddr | address | the address of the ERC-20 token used for payments, or 0 address for native token |
Native Token vs ERC-20
CrowdFi contracts support native tokens as well as ERC-20 compliant tokens. The contribute and yield functions are different depending on whether the contract is native token or ERC-20 denominated.
️🚫
CrowdFi contracts do not support rebasing tokens! Do not use them as the denominated token.
⚠️
CrowdFi contracts support fee taking tokens. The number of CrowdFi tokens minted on contribution will factor in the fee.
Factory Addresses
Network | Address |
---|---|
Ethereum Mainnet | 0x8e78d80599197c501353453f73b0b92a402077d6 |
Ethereum Sepolia | 0x83a322729C3172B0cc6Bf3a3204Fa83E683c584E |
Polygon | 0xf53e3729aC1caDd24D5986b2738D0DEE5f4eD30A |
Arbitrum | 0x24379629781d03a0Fe67D9712FD2d76a92EfEF14 |
Example Deployment
import { Contract, Signer } from 'ethers';
const abi = require('path/to/CrowdFinancingV1Factory.abi.json');
const contract = new Contract(factoryContractAddress, abi, signer);
// Native token (ETH)
const erc20TokenAddress = '0x0000000000000000000000000000000000000000';
const tx = await contract.deployCampaign(
recipientAddress,
minGoal,
maxGoal,
minContribution,
maxContribution,
holdOffSeconds,
durationSeconds,
erc20TokenAddress,
);
console.log('deploy tx', tx);