Skip to content
Nomad edited this page Mar 20, 2022 · 13 revisions

Loopring Python Minting on Layer 2

About this App

This is the unofficial Loopring Python Minter on Layer 2.

The system utilizes a few parts:

  1. Python to generate images and metadata according to the standards for the new Layer 2 marketplace.
  2. NodeJS to pre-calculate CIDs on images and metadata files.
  3. Python to run the batch minting process.

System Requirements

Setting up the generator

  1. Copy the generator/traits.example.py file and rename it to generator/traits.py.
  2. Edit the file according to the notes below
  3. Copy the .env.example file and rename it to .env.
  4. Add your information to the file according to the table below

See the next sections for details on traits.py and .env setup.

dotenv

First you need to export your account to get the necessary details to fill in the dotenv file.

Go to https://loopring.io/# -> Security -> Export Account and copy the JSON provided into a safe space.

⚠️ DO NOT SHARE THIS INFO WITH ANYONE ⚠️

The output should look something like this:

{
    "address": "0x000000000000000000000000000000000000000000000",
    "accountId": 12345,
    "level": "",
    "nonce": 1,
    "apiKey": "randomlettersandnumbersohmygod",
    "publicX": "0x000000000000000000000000000000000000000000000",
    "publicY": "0x000000000000000000000000000000000000000000000",
    "privateKey": "0x000000000000000000000000000000000000000000000"
}
Variable Description Accepted Values
ARTIST_NAME Some name so people know who you are String of words, spaces, or numbers
MINTER address See your account export
ROYALTY_PERCENTAGE Percentage for royalty payouts to the minter 0 - 10
COLLECTION_DESCRIPTION A description to put into metadata String of words, spaces, or numbers
SEED A custom generation seed, generated for you if you leave it blank String of words, spaces, or numbers
SOURCE_FILES Custom folder where your source layers are. If blank, defaults to lowercase, no space version of COLLECTION_NAME Path to a folder
LOOPRING_API_KEY apiKey See your account export
LOOPRING_PRIVATE_KEY privateKey See your account export
ACCT_ID accountId See your account export
NFT_TYPE EIP1155 or EIP721 0 (1155) or 1 (721)
FEE_TOKEN_ID ETH or LRC 0 (ETH) or 1 (LRC)

Traits Primer

Firstly, rename "Collection Name" to be what you want to name your collection.

COLLECTION_NAME="Collection Name"

Now, you have to understand the layer structure. This seems tedious, but will save a ton of work later.

    {   # layer08
        "layer_name": "Trait Display Name 01",
        "filenames": {
            "Item Display Name 01": "item_01.png",
            "Item Display Name 02": "item_02.png"
        },
        "weights": [
            50,
            50
        ]
    }

The above is one layer, and needs to match up to your layer folders.

So, remember that the "Display Name" is what will actually appear in the metadata. So, if your layer08 should be labeled "Head" when this is all done, you would change the first line like this

        "layer_name": "Head",

Then you need to match up your items "Display Names" to your filenames.

        "filenames": {
            "AFRO JAPAN BANDANA": "AFRO_JAPAN_BANDANA.png",
            "BUNNY EARS": "BUNNY_EARS.png",
            "CHEF HAT": "CHEF_HAT.png",
            "COWBOY HAT": "COWBOY_HAT.png"
        },

Last part, you need to give them rarities or "weights". You have to have the same amount of "weights" that you do "filenames" So if there are 10 files for "Head", then you have to have 10 "weights" for "Head".

The lower the number you set, the rarer it will be.

The lines correlate to each other, so whatever "weight" is at the top of the list is linked to the "filename" at the top of the list. They go in order from there.

So as an example from my quick set of filenames above, you would need to have weights like this:

        "weights": [
            50,
            10,
            10,
            30
        ]

So to put my whole example layer together, it would look like this:

    {   # layer08
        "layer_name": "Head",
        "filenames": {
            "AFRO JAPAN BANDANA": "AFRO_JAPAN_BANDANA.png",
            "BUNNY EARS": "BUNNY_EARS.png",
            "CHEF HAT": "CHEF_HAT.png",
            "COWBOY HAT": "COWBOY_HAT.png"
        },
        "weights": [
            50,
            10,
            10,
            30
        ]
    }

Now keep in mind, this is an example of one layer. You must do this for all layers and filenames. Remember that upper and lowercase matters a great deal

Clone this wiki locally