πŸ’°Fundraising Smart Contract

The Fundraising contract is a Solidity smart contract designed for conducting RWA fundraising campaigns on the Ethereum blockchain. It allows contributors to participate in fractional ownership fundraising campaings by contributing stablecoins (ERC20 tokens) in exchange for project-specific tokens. The contract supports features such as setting fundraising goals, defining ticket sizes, setting fundraising deadlines, and distributing project tokens to contributors based on their contributions.

The contract consists of the following main components:

  1. Stablecoin and Project Token Interfaces: Interfaces for interacting with ERC20-compliant stablecoin and project tokens.

  2. State Variables:

    • fundraisingGoal: The target amount of stablecoins to be raised during the fundraising campaign.

    • ticketSize: The size of each contribution ticket in stablecoins.

    • StablecoinToProjectTokenRatio: The conversion ratio of stablecoins to project tokens.

    • deadline: The deadline for the fundraising campaign.

    • totalContributed: Total amount of stablecoins contributed by all participants.

    • feeReceiver: Address where commission fees are sent.

    • totalStablecoinFees: Total commission to be paid in stablecoin.

    • totalProjectTokenFees: Total commission to be paid in Project Tokens.

    • projectWallet: Address of the wallet where project tokens are transferred after fundraising.

    • finalized: Flag indicating whether the fundraising campaign has been finalized.

    • fundraisingCanceled: Flag indicating whether the fundraising campaign has been canceled.

  3. Mappings and Arrays:

    • contributions: Mapping to track contributions made by each participant.

    • tokens: Mapping to track project tokens allocated to each participant.

    • contributors: Array to store addresses of contributors.

  4. Modifiers:

    • onlyOwner: Restricts access to functions to the contract owner.

  5. Constructor:

    • Initializes the contract with addresses of the stablecoin and project token contracts.

  6. Public Functions:

    • setFundraisingDetails: Sets the parameters of the fundraising campaign.

    • setProjectWallet: Sets the address of the wallet where project tokens are transferred.

    • contribute: Allows participants to contribute stablecoins to the fundraising campaign.

    • finalizeFundraising: Finalizes the fundraising campaign.

    • claimTokens: Allows contributors to claim their allocated project tokens.

    • cancelFundraising: Cancels the fundraising campaign and refunds contributions to participants.

Usage

Setting Fundraising Details

The setFundraisingDetails function is used by the contract owner to set the parameters of the fundraising campaign. These parameters include the fundraising goal, ticket size, stablecoin to project token ratio, fundraising deadline, and fee receiver address.

Contributing to the Fundraising Campaign

Participants can contribute to the fundraising campaign by calling the contribute function and providing the desired contribution amount in stablecoins. Contributions must be made before the fundraising deadline.

Finalizing the Fundraising Campaign

Once the fundraising campaign ends, the contract owner can finalize the campaign by calling the finalizeFundraising function. This function distributes project tokens to contributors based on their contributions and collects fundraising fees.

Claiming Allocated Tokens

Contributors can claim their allocated project tokens by calling the claimTokens function after the fundraising campaign has been finalized.

Canceling the Fundraising Campaign

If needed, the contract owner can cancel the fundraising campaign by calling the cancelFundraising function. This function refunds contributions to participants.

Last updated