- Solidity (High-level language for implementing smart contracts)
- OpenZeppelin (A library for secure smart contract development)
- Brownie (Python development framework for Ethereum)
- Pinata (Cloud-based InterPlanetary File System service provider; no need to run IPFS node by yourself)
- Hashlips Art Engine (Javascript based library that generates artworks based on provided layers)
- Ganache (Local Blockchain environment)
- Infura (Blockchain API to connect to a Testnet or a Mainnet; no need to run own Blockchain node)
- Alchemy (Blockchain API to connect to a Testnet or a Mainnet; no need to run own Blockchain node)
Please install or have installed the following:
- Install Brownie, if you haven't already. Here is a simple way to install brownie.
python3 -m pip install --user pipx
python3 -m pipx ensurepath
# restart your terminal
pipx install eth-brownie
Or, if that doesn't work, via pip3
pip3 install eth-brownie
- Download the repository
If you are cloning the project then run this first, otherwise you can download the source code on the release page and skip this step.
git clone https://github.com/vsevdrob/nft-brownie-mix
cd nft-brownie-mix
- Install Hashlips Art Engine dependencies:
Go to the ./hashlips_art_engine
and run the following command if you have yarn
installed.
yarn install
Alternatively you can run this command if you have node
installed.
npm install
If you want to be able to deploy to testnets, do the following.
Set your WEB3_INFURA_PROJECT_ID
, and PRIVATE_KEY_TEST
environment variables.
You can get a WEB3_INFURA_PROJECT_ID
by getting a free trial of Infura. At the moment, it does need to be infura with brownie. If you get lost, you can follow this guide to getting a project key. You can find your PRIVATE_KEY
from your ethereum wallet like metamask.
If you want to auto-upload to pinata instead of IPFS automatically, you can do so by getting a Pinata API Key.
You can add your environment variables to a .env
file. You can use the .env.example as a template, just fill in the values and rename it to .env
.
Here is the example of how .env
should look like:
export WEB3_INFURA_PROJECT_ID='Ba41Bac12341'
export PRIVATE_KEY_TEST='Ab678bCbc126'
export PINATA_API_KEY_TEST='53hHlhjrw124h1h2'
export PINATA_API_SECRET_TEST='jJF234JEwqekq2'
You can also learn how to set environment variables easier
Then, make sure your brownie-config.yaml
has:
dotenv: .env
DO NOT SEND YOUR PRIVATE KEY WITH FUNDS IN IT ONTO GITHUB
Otherwise, you can build, test, and deploy on your local environment.
You'll also need testnet rinkeby ETH. You can get ETH into your wallet by using the rinkeby faucets located here. If you're new to this, watch this video.
For local testing install ganache-cli
npm install -g ganache-cli
or
yarn add global ganache-cli
All the scripts are designed to work locally or on a testnet. You can add a ganache-cli or ganache UI chain like so:
brownie networks add Ethereum ganache host=http://localhost:8545 chainid=1337
And update the brownie config accordingly.
- Setup
hashlips_art_engine
- Clone the official repo by running this command in the project root directory
./nft-brownie-mix
:
git clone https://github.com/HashLips/hashlips_art_engine.git
- With the help of the haslips documentation generate your first images. You know you fulfilled it right if the directory
./nft-brownie-mix/hashlips_art_engine/build/images
contains of satisfied images.
- Make sure that hashlips is enabled
HASHLIPS = {"enabled": True}
in./scripts/utils/config.py
.
- Add manually the image(s) into
./img
.
- Go to
./scripts/collectible/config.py
and provide some configurations applied to your wishful collection by replacing the values in this variables:
"""
Collectible.sol constructor arguments.
"""
COLLECTIBLE = {
"name": "Super Art Collection", # <-
"symbol": "SAC", # <-
"contract_URI": "", # <-
"royalty_receiver": "0x8626f6940e2eb28930efb4cef49b2d1f2c9c1199", # <-
"royalty_fraction": 250, # e.g. 100 (1%); 1000 (10%) # <-
}
"""
Is collection considered as a single edition collection?
- YES: SINGLE_EDITION_COLLECTION["enabled"] = True
- NO: SINGLE_EDITION_COLLECTION["enabled"] = False
"""
SINGLE_EDITION_COLLECTION = {
"enabled": True, # <-
"file_name": "image_name.png", # Provide the literal name of the image in ./img # <-
}
"""
If SINGLE_EDITION_COLLECTION is enabled:
AMOUNT_TO_MINT = 1
If SINGLE_EDITION_COLLECTION is disabled:
AMOUNT_TO_MINT = 10
"""
AMOUNT_TO_MINT = 1 if SINGLE_EDITION_COLLECTION["enabled"] else 10 # <-
SPREADSHEET = {
"enabled": False, # <-
"trait_types": [
"1st trait type (eg. Sport)", # <-
"2nd trait type (eg. Languages)", # <-
"3rd trait type (eg. Zodiac sign)", # <-
], # <- # first row columns after | ID | NAME | DESCRIPTION | CREATOR | ARTIST | 1st trait type | 2nd ...
}
"""
@dev If SPREADSHEET is disabled and SINGLE_EDITION_COLLECTION is disabled:
@dev name = "Name" + f"# {_token_id}"
@dev description = "Description"
@dev creator = "Creator"
@dev artist = "Artist"
@dev If SPREADSHEET is disabled and SINGLE_EDITION_COLLECTION is enabled:
@dev name = "Name"
@dev description = "Description"
@dev creator = "Creator"
@dev artist = "Artist"
@dev If SPREADSHEET is enabled and SINGLE_EDITION_COLLECTION is enabled:
@dev name = <NAME PROVIDED IN SPREADSHEET UNDER ID 1>
@dev description = <DESCRIPTION PROVIDED IN SPREADSHEET UNDER ID 1>
@dev creator = <CREATOR PROVIDED IN SPREADSHEET UNDER ID 1>
@dev artist = <ARTIST PROVIDED IN SPREADSHEET UNDER ID 1>
@dev If SPREADSHEET is enabled and SINGLE_EDITION_COLLECTION is disabled:
@dev name = <NAME PROVIDED IN SPREADSHEET UNDER ID #>
@dev description = <DESCRIPTION PROVIDED IN SPREADSHEET UNDER ID #>
@dev creator = <CREATOR PROVIDED IN SPREADSHEET UNDER ID #>
@dev artist = <ARTIST PROVIDED IN SPREADSHEET UNDER ID #>
"""
COLLECTION = {
"description": "This collection represents ...", # <-
"artwork": {
"name": "Name" if not SPREADSHEET["enabled"] else None, # <-
"description": "Description" if not SPREADSHEET["enabled"] else None, # <-
"creator": "Creator" if not SPREADSHEET["enabled"] else None, # <-
"artist": "Artist" if not SPREADSHEET["enabled"] else None, # <-
"additional_metadata": {
"enabled": False, # <-
"data": {
"extra key 1": "value", # any key | value
"extra key 2": "value", # any key | value
# ...
},
},
},
"external_link": {
"enabled": False, # <-
"base_url": "https://yourwebsite.io/", # <-
"url": "https://yourwebsite.io/super-art-collection/", # <-
"include_token_id": False, # e.g. https://yourwebsite.io/super-art-collection/123 # <-
},
}
- Deploy
Collectible.sol
smart contract and mint the first NFTs:
- On
development
network:
Start the brownie console:
brownie console
In that console execute the functions:
run("scripts/deploy/deploy_collectible.py")
run("scripts/main.py")
- On
rinkeby
test network:
Simply run this commands in your terminal window:
brownie run scripts/deploy/deploy_collectible.py --network rinkeby
brownie run scripts/main.py --network rinkeby
To get started with Brownie:
- Check out the Brownie mixes that can be used as a starting point for your own contracts. They also provide example code to help you get started.
- Check out the Chainlink documentation to get started from any level of smart contract engineering.
- "Getting Started with Brownie" is a good tutorial to help you familiarize yourself with Brownie.
- Cognitive Brownie tutorial by Curve Finance.
- For more in-depth information, read the Brownie documentation.
- Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
This project is licensed under the MIT license.