Skip to content

Build and tokenize your own smart contract factory using Fundi, Openzeppelin, and Chainlink contracts with Foundry framework on Etherum/Base Sepolia

Notifications You must be signed in to change notification settings

fundiprotocol/FundiFactoryFoundryStarterKit

Repository files navigation

IMPORTANT: _This repo is a work in progress, and contracts have not been audited and only accessible on Ethereum/Base Sepolia until completed audit and mainnet deployment. Use with your own risk

Fundi Factory Overview

Table of Contents

Fundi Overview


FundiMap


Fundi is an open verifiable network of digital keys that tokenize validators and protocols to mint smart contracts and assets. These customizable contract keys adhere to a new NFT standard designed to facilitate seamless ownership transfer, making them verifiable by Fundi users and incentivized for security.

This repository utilizes the Fundi Factory Protocol, a protocol that tokenizes smart contract factories and can be monetized with any ERC20 cryptocurrency for minting contracts and assets. 100% of the proceeds are claimable by the owner.

The keys that tokenizes factories and assets are represented by NFTs.

This Factory image represents a factory key for a Custom (white) Unverified (silver) Factory


UnverifiedCustomFactory


This Asset image represents a asset key for an asset that was minted by a Custom (white) Unverified (silver) Factory

UnverifiedCustomAsset


Check out Fundi Tokenized Factories at Opensea on Base Sepolia

Interact with protocol functions at : Etherscan

The example in this repo

In this repo, we will go over how to tokenize a smart contract factory.

  1. Example Fundi Asset, smart contract that factory should mint and tokenize: ExampleFundiAsset.sol
  2. Example Fundi Factory, factory that mints and tokenizes asset using Fundi ExampleFundiFactory.sol

The idea here, is that once you see the power of this example, you should be able to tokenize anything.

ExampleFundiAsset.sol

  1. This is the smart contract that is tokenized. It could be anything or use case that you can think of 😉
  2. This contract inherits the FundiAsset.sol implementation which allows it to be tokenized by a FundiFactory.sol on the Fundi Factory Protocol

For ExampleFundiAsset.sol we are tokenizing a contract that can accept native and ERC-20 cryptocurrencies and only the owner of the protocol minted key can ownerWithdraw

ExampleFundiFactory.sol

  1. This is the smart contract that is tokenized and also tokenizes a FundiAsset.sol. 😉
  2. This contract inherits the FundiFactory.sol implementation which allows it to tokenize FundiAsset.sol and be tokenized on the Fundi Factory Protocol

For ExampleFundiFactory.sol we are tokenizing a contract factory that mints ExampleFundiAsset.sol contracts on Fundi. The owner of this factory key can collect mint fees through Fundi Factory Protocol withdrawFundiProceeds and withdrawFundiProceeds functions.

Getting Started

Requirements

  • git
    • You'll know you did it right if you can run git --version and you see a response like git version x.x.x
  • foundry
    • You'll know you did it right if you can run forge --version and you see a response like forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
  • node
    • You'll know you did it right if you can run node --version and you see a response like v16.13.0
  • npm
    • You'll know you did it right if you can run npm --version and you see a response like 8.1.0
  • fundi faucet
    • Use this test faucet to get FUNDI for minting fee(1 FUNDI per factory mint/.5 FUNDI per asset mint) you will know if you have a balance for ERC-20 address: 0x7891Cd6E291A79302bF47958806a9801D22feeB5.
    • You can request FUNDI tokens once every 24 hours for 5 FUNDI by connecting wallet and calling the requestTokens function below.

    FundiFaucet


Installation

  1. Clone the repo, navigate to the directory, and begin building your smart contract factory with the same implementations as src/Factories/ExampleFundiFactory.sol and src/Assets/ExampleFundiAsset.sol
git clone https://github.com/fundiprotocol/FundiFactoryFoundryKit
cd FundiFactoryFoundryKit

Build

  1. Using ExampleFundiAsset.sol as a template create your own custom smart contract using Chainlink and Openzeppelin in lib
  2. Use function modifier onlyOwner to only give access to token holder
  3. Using ExampleFundiFactory.sol as a template
  4. There are 7 types of FundiAsset.sol you can specify: PAYROLL(blue), TRUST(red), ESCROW(yellow), CROWDFUND(green), PERSONAL_ACCOUNT(purple), CONTRACT(red), and CUSTOM(white)

Test

  1. Build test for your factory and the asset that it mints to ensure that your contracts work as expected
  2. You can upload audits to your contracts using addContractAudit(string memory auditReport) if you want to be verified by Fundi Governance

Deploy

  1. Write deployment script using script/DeployFundiFactory.s.sol as an example.
  2. This script deploys the Factory and then mints a key that tokenizes the factory on Fundi Factory Protocol.
  3. Update your Factory type, contractURI, and required fee in fundiProtocol.mintFactoryKey( address(exampleFactory), <-address of deployed factory IFundiProtocol.AssetType.CUSTOM, <-custom factory "FactoryContractURI", <-factory contract info address(fundiToken), <-fundi token 0 <-no fee )
  4. Make sure your wallet has at least 1 FUNDI for factory mint and .5 for asset mint
  5. Test deployment using forge script scripts/DeployFundiFactory.s.sol --rpc-url YOUR_RPC_URL
  6. View your Factory on NFT Marketplaces at the Fundi Factory Protocol address

Chainlink

This repository includes Chainlink contracts, which expand the capabilities of smart contracts by enabling access to real-world data and off-chain computation while maintaining the security and reliability guarantees inherent to blockchain technology

Products

  • CCIP - enables cross-chain functionality to contracts
  • Functions - enables off chain api calls through Chainlink nodes
  • Automation - automate functions based on set conditions
  • Price feeds - get price feeds from Chainlink oracles for defi
  • VRF - verifiable randomness

Go to Chainlink Dev Hub to learn more

Openzeppelin

This repo has Openzeppelin, a library for secure smart contract development. Build on a solid foundation of community-vetted code.

Implementations of standards like ERC20 and ERC721. Flexible role-based permissioning scheme. Reusable Solidity components to build custom contracts and complex decentralized systems.

Go to Openzeppelin to learn more

What does this unlock?

Being able to verify and tokenize ownership of contract factories, funds, protocols, business processes, or any smart contract! 🤯

Disclaimer

The repository has not been audited, use at your own risk.