Zero-to-Solana First Metaplex
Going from Zero to Solana; running your first metaplex upload with no pre-requisites
A. Introduction
No pre-requisites required. You do not have to have read the first post in the series to run this, because we’ll put the setup steps in this document.
Goal for this is to be copy-paste in-order from a fresh system mint an NFT using metaplex on Solana devnet, all on a single page with numbered steps (so you can get help debugging)
B. Set up a VM using Multipass
The only way to get away with the OS-agnostic approach is to run everything on a a Ubuntu 20.04 and access via SSH command-line and tunneling.
We’ll use multipass, as this is cross-platform. Feel free to use VirtualBox, Parallels, or a cloud VM from AWS to load up the Ubuntu system.
On your host system open up a terminal (or Powershell):
- Windows: Install VirtualBox or use Windows 10 Pro w/ Hypervisor, and install https://multipass.run/download/windows
- Mac: Install Virtualbox and set the local driver to virtualbox and install https://multipass.run/download/macos
- Linux:
sudo snap install multipass
After installation, in your terminal, run:
multipass launch -n zerotosolana -m 8G -d 100G
- This will create an Ubuntu 20.04 VM named
zerotosolana
with 8GB of ram and 100GB of (virtual) disk space. Feel free to change these
Get into your shell like so:
multipass shell zerotosolana
- Note: This uses the autogenerated SSH keys in your multipass setup. You may override these and simply use ssh with a
cloud-init.yaml
file, which is out of scope for this doc
Install npm and yarn
We will upgrade the system node to install yarn, and then we will install nvm which lets us switch node versions for different projects
C1. Install system npm and yarn in Ubuntu VM
- Update apt database
sudo apt update
- Add apt source list
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
- Install nodejs and npm
sudo apt -y install nodejs npm
- Install yarn
sudo npm install --global yarn
C2. Install nvm to manage node versions
- Install nvm
sudo apt install -y curl curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
- Source profile
source ~/.profile
- install specific version of node with nvm
nvm install 14.17.6
- use specific version of node with nvm
nvm use 14.17.6
- Confirm you are using:
node -v
- It should say something like
v14.17.6
- It should say something like
D. Install metaplex
- Clone metaplex
git clone https://github.com/metaplex-foundation/metaplex.git gh_metaplex-foundation_metaplex
- Get into the cli directory
cd gh_metaplex-foundation_metaplex/js/packages/cli
- (optional) if you want to use the same version as this guide:
git checkout fda50663d76c93295e05962926c4c17f400397d8 # 2021 Sep 15 has the --no-bytecode fix
- metaplex is going through massive daily updates, so recommend you use the same version
- Build and install using the linux bytecode fix:
yarn install yarn build yarn run package:linuxb
- Add path to profile
echo export PATH=\"$(pwd)/bin/linux/:\$PATH\" >> ~/.profile
- Source to get metaplex
source ~/.profile
- Check metaplex to see if it works:
metaplex --version
- It should look something like this:
> metaplex --version 0.0.1
E. Solana
Note: we will use devnet and keygen switches explicitly. You may create a config file later to override mainnet defaults.
- Install solana, around 240MB
sh -c "$(curl -sSfL https://release.solana.com/v1.7.11/install)"
- It will update the PATH in your .profile file to this:
export PATH="/home/ubuntu/.local/share/solana/install/active_release/bin:$PATH"
- It will update the PATH in your .profile file to this:
- Get access to solana
source ~/.profile
- Confirm access to solana binary:
solana --version
- You will see
solana-cli 1.7.11 (src:bdb77b0c; feat:1140394761)
- You will see
- Generate keypair
solana-keygen new --outfile ~/.config/solana/devnet-lightcycle.json
- It will look something like:
Generating a new keypair For added security, enter a BIP39 passphrase NOTE! This passphrase improves security of the recovery seed phrase NOT the keypair file itself, which is stored as insecure plain text BIP39 Passphrase (empty for none): Wrote new keypair to /home/ubuntu/.config/solana/devnet-lightcycle.json ========================================================================== pubkey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ========================================================================== Save this seed phrase and your BIP39 passphrase to recover your new keypair: fake seed lightcycle research is the best fake seed fake seed fake seed ==========================================================================
- Request 10 SOL airdrop on devnet
solana --url devnet --keypair ~/.config/solana/devnet-lightcycle.json airdrop 10
- Confirm balance
solana --url devnet --keypair ~/.config/solana/devnet-lightcycle.json balance
F. Generate Assets
We will make two example NFTs for uploading
- Install python3
sudo apt install -y python3
- Clone the lightcycle nft generator project:
git clone https://github.com/lightcycleresearch/lightcycle-nft-generator.git gh_lightcycleresearch_lightcycle-nft-generator
- Change into directory
cd gh_lightcycleresearch_lightcycle-nft-generator
- Create config.ini
cp config.ini.example config.ini
- Get your solana pubkey and copy it to your clipboard for the next step:
solana-keygen pubkey ~/.config/solana/devnet-lightcycle.json
- Edit config.ini and change REPLACEME to your pubkey, save and close the file
vim config.ini
- Initialize project
python3 nftgen.py --project example --config config.ini --initialize
- Generate metadata
python3 nftgen.py --project example --config config.ini --generate-metadata
- Generate assets, which moves the images and metadata into one folder
python3 nftgen.py --project example --config config.ini --generate-assets
- Confirm you have the correct assets:
ls projects/example/assets/
- It will look like:
0.json 0.png 1.json 1.png
- It will look like:
- Get into the project directory to prepare for the next step
cd projects/example
G. Metaplex
We will upload, verify, create a candy machine, and mint a token with metaplex. We must create the candy machine before minting
- Ensure you are in the correct directory with the
assets
folder:pwd
- It should look something like:
/home/ubuntu/gh_lightcycleresearch_lightcycle-nft-generator/projects/example
- It should look something like:
- Check you have the assets folder available:
ls
- It should look like:
assets/ images/ metadata/
- It should look like:
- Confirm you have the correct assets:
ls projects/example/assets/
- It will look like:
0.json 0.png 1.json 1.png
- It will look like:
- Run metaplex upload:
metaplex upload ./assets --env devnet --keypair ~/.config/solana/devnet-lightcycle.json
- If it fails, run it again. Sometimes it takes a few tries
- It will look something like:
Processing file: 0 ... ... Processing file: 1 Started awaiting confirmation for xxx REST null result for xxx null Resolved via websocket { err: null } Returning status { err: null, slot: 81091320, confirmations: 0 } Latency xxx 1.9210000038146973 transaction for arweave payment: { txid: 'xxx', slot: 81091320 } File uploaded: https://arweave.net/xxx Writing indices 0 - 1 Done
- Verify the upload:
metaplex verify --env devnet --keypair ~/.config/solana/devnet-lightcycle.json
- It will look something like:
Looking at key 0 Name lightcycle #0 with https://arweave.net/xxx checked out Looking at key 1 Name lightcycle #1 with https://arweave.net/xxx checked out
- It will look something like:
- Create candy machine, so we can mint later:
metaplex create_candy_machine --env devnet --keypair ~/.config/solana/devnet-lightcycle.json
- It will look something like:
wallet public key: xxx create_candy_machine finished. candy machine pubkey: xxx
- It will look something like:
- Mint a token for testing
metaplex mint_one_token --env devnet --keypair ~/.config/solana/devnet-lightcycle.json
- It will look something like:
wallet public key: xxx Done xxx
Resources and References
You may read more for details:
- NFT generator to match Metaplex standard: https://github.com/lightcycleresearch/lightcycle-nft-generator
- @levicook Metaplex guide https://hackmd.io/@levicook/HJcDneEWF
- arweave docs: https://github.com/ArweaveTeam/arweave-js (the README has better docs than the official site)