Generate assets to empower your in-game items

1. Set up developer tools you'll need

Set up for macOS users

Homebrew

Homebrew is a package manager allows you to easily install the packages needed for this tutorial. Go to the Homebrew website for instructions on how to install and use it.

Node.js

Node.js allows us to use JavaScript to build and run applications.

ENSURE YOU HAVE THE LATEST LTS VERSION

...or you may experience issues following this tutorial.

For Mac users, open up the terminal and run:

brew install node

Visual Studio Code

Visual Studio Code is a code editor we will be using for this tutorial. It is known for its user-friendly interface and extensive extension library.

Set up for Windows users

Node.js

Node.js allows us to use JavaScript to build and run applications.

ENSURE YOU HAVE THE LATEST LTS VERSION

...or you may experience issues following this tutorial.

For Windows users, you can verify that Node.js is properly installed and working by opening PowerShell or the Command Prompt and running:

npm -v

Visual Studio Code

Visual Studio Code is a code editor we will be using for this tutorial. It is known for its user-friendly interface and extensive extension library.

2. Set up Metamask as your developer wallet: Metamask

3. Fork and modify the GGG contract

Solidity repository provides a standard set of libraries. This is your starting point for deploying our recommended ERC721 preset contracts.

Follow GitHub's guides for cloning and forking a repo if you need help

At the end of this process you should have a copy of the repository installed locally on your machine with the path ../{YOUR_GITHUB_USERNAME}/GGG-boilerplate

Once downloaded, run the following command from the root directory:

npm install

Configure Hardhat

Update your project's hardhat.config.js/ts file with the following code. This file is located in your smart contract repository.

const config = {
  solidity: {
    version: '0.8.17',
    settings: {
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
};

4. Add metadata to your contract

Create metadata

There are 2 types of metadata to keep in mind:

  • For your collection: Contract metadata contains collection description and name. A collection can have many NFTs.

  • For each NFT: NFT metadata contains characteristics and properties of each specific NFT.

  1. Create folders and files by running these commands in your terminal:

💡METADATA URLSAll NFT metadata filenames should be in the format of [int]. The collection metadata file can contain any values as long as it is in JSON format.

  1. In the folder nft-metadata populate the 1 file with the metadata for the corresponding NFT, using the following example. Make sure to replace each image with the URLs that you created earlier to host your NFT images.

{
  "id": 1,
  "image": "<replace this with your own IPFS link from step #1>",
  "token_id": "1",
  "background_color": null,
  "animation_url": null,
  "youtube_url": null,
  "name": "Test GGG NFT",
  "description": "This NFT is my first GGG NFT created on GGG",
  "external_url": null,
  "attributes": [
    {
      "trait_type": "Hat",
      "value": "Top Hat"
    },
    {
      "trait_type": "Coat",
      "value": "Tails"
    },
    {
      "trait_type": "Neck",
      "value": "Bow Tie"
    }
  ]
}
  1. Copy the contents of the 1 file into the 42 and 987654321098765432109876543210987654321 files, changing the values of "id" to match.

  2. In the folder contract-metadata populate the contract.json file with the metadata for the collection, using the following example. Replace image with the URL for the specific NFT image you uploaded when you created your collection metadata.

{
  "name": "My collection",
  "description": "Some description",
  "image": "<replace this with your own IPFS link from step #1>",
  "external_link": "https://some-url"
}
  1. Ensure files are saved before uploading both folders into IPFS. Double check this by closing the file and re opening - make sure that the values have been saved.

5. Set up your wallet for minting

  • Obtain test $GGG tokens to pay for gas fees

  • Locate your wallet's private key

  • Configure the private key

6. Contract deployment

Deploy the contract

Fill in the values in scripts/deploy.ts as appropriate, and then run the following command from your project's root directory:

# Deploy to GenesisL2 Devnet
npx hardhat run --network GenesisL2Devnet scripts/deploy.ts

🎉CONGRATULATIONS You've now deployed your first contract on Genesis Devnet!

Make sure you copy the CONTRACT_ADDRESS which is returned after the successful deployment:

MyERC721 contract deployed to 0xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Verify the contract has been deployed

Last updated