Last active
January 28, 2023 14:02
-
-
Save praskoson/ff28981b50c773b67e6a97b45eb1a3a2 to your computer and use it in GitHub Desktop.
Bash script for sequentially minting Solana NFTs. Uses metaboss, jq and Solana CLI config file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
USAGE="Usage: ./mint-blank-nfts {amount} [metadata URL]\n\nDependencies: \nmetaboss ^0.14.0 (https://crates.io/crates/metaboss)\nSolana CLI key file (~/.config/solana/id.json)\njq (https://stedolan.github.io/jq/)" | |
if [ $# == 0 ]; then | |
echo -e $USAGE | |
exit 1; | |
fi | |
if [ ! -f ~/.config/solana/id.json ]; then | |
echo "No keypair file found at ~/.config/solana/id.json" | |
exit 1 | |
fi | |
wallet=$(solana address) | |
amount=$1 | |
metadata_url=${2:-"https://arweave.net/FPGAv1XnyZidnqquOdEbSY6_ES735ckcDTdaAtI7GFw"} | |
metadata_template='{ | |
"name": "TestNFT1", | |
"symbol": "TNFT", | |
"uri": "", | |
"seller_fee_basis_points": 0, | |
"creators": [ | |
{ | |
"address": "", | |
"verified": true, | |
"share": 100 | |
} | |
] | |
}' | |
metadata_template=$(echo $metadata_template | jq \ | |
--arg uri "$metadata_url" \ | |
--arg address "$wallet" \ | |
'.uri = $uri | .creatos[0].address = $address') | |
temp_file=$(mktemp) | |
echo $metadata_template > $temp_file | |
for i in $(seq $amount) | |
do | |
output=$(metaboss mint one -d $temp_file --sign 2>&1 | head -n 2 | tail -n -1) | |
if [ $? -ne 0 ]; then | |
echo "mint failed" | |
echo $output | |
rm $temp_file | |
exit 1 | |
fi | |
id=$(echo $output | sed -rn 's/Mint account: ([a-zA-Z0-9]+)/\1/p') | |
echo $id | |
done | |
rm $temp_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment