Skip to main content

Quickstart

Welcome to the Quickstart guide! Follow these step-by-step instructions to quickly get started with the Reference Implementation.

Prerequisites

  • Install dependencies with yarn install.
  • Make sure Hardhat is installed globally.
  • Clone or download the Reference Implementation
git clone https://github.com/Nexera-Foundation/Minimalistic-ERC-7208.git

Setup Environment

  1. Copy the environment file

    • Copy the .env.example file and create a .env file.
    • Fill in the mnemonic phrase for deployments and transactions.
  2. Local Deployment Setup (Optional)
    If you're deploying locally, use the following command to start a local Hardhat node:

    npx hardhat node --no-deploy

    This will create a local environment for testing, deployments, and contract interactions. The --no-deploy flag ensures that contracts are not automatically deployed when the node starts. This step is optional if you prefer to work directly on a testnet.

Deploy Core Contracts

Deploy the core contracts using:

yarn deploy:core --network <localhost>

This command will deploy the DataIndex and DataPointRegistry contracts. You can choose to deploy these contracts from scratch or use existing deployments.

Allocate a Data Point

Next, allocate a data point by running:

yarn allocateDataPoint --network <localhost>

This communicates with the DataPointRegistry contract, allocating a data point (DP) for the caller. This data point will be essential in linking the token metadata.

Configure Data Manager Parameters

Before deploying example contracts, set the parameters for the ERC1155DataManager in the constants.ts file.

  1. Copy the example constants file:

    cp ./utils/constants.example.ts ./utils/constants.ts
  2. Populate the ERC1155DataManagerParameters with the data point's bytes32 value from the output of the previous step. Set the desired name and symbol for your ERC1155 collection. For example:

    export const ERC1155DataManagerParameters = {
    datapoint: "0x445000000000000100007a69de48d4eccf06e9f445489b7776c6d4989ec43d3f0",
    name: "My1155Collection",
    symbol: "NFT",
    };

Deploy Example Contracts

Deploy the example contracts using:

yarn deploy:examples --network <localhost>

This will deploy:

  • FungibelFractionsDO
  • ERC20FractionDMFactory
  • ERC1155WithERC20FractionsDM

These contracts will enable the hybrid ERC1155/ERC20 functionality.

Set Up Permissions for Data Manager

To configure the Data Manager, use:

yarn setUpDataManager --network <localhost>

This step is crucial for linking the Data Manager to the DataPointRegistry. As the owner of the data point (DP), you must:

  • Whitelist the Data Manager in the DataIndex.
  • Assign the admin role of the DP to the Data Manager through the DataPointRegistry. This allows the manager to forward calls and modify the DP’s storage.

Mint Tokens

Mint the ERC1155 tokens by running:

yarn mintTokens --network <localhost>

This will mint the tokens for the collection. Ensure that you check the token balance before and after minting.

Use the ERC20 Data Manager

Once the ERC20DataManager is deployed, you can use the fractions as ERC20 tokens by calling the balanceOf method, allowing users to interact with them like any other fungible token:

yarn useERC20DataManager --network <localhost>