Part 5: Preparing the Assets
If you have used CMv1 or Metaplex before, this process will be familiar. We need to create a 1-to-1 mapping of the .PNG and .JSON files. The files should be named by number, so 0.png
maps to 0.json
. The numbers should start at 0 and increase sequentially, never skipping a number.
Metaplex has this sample set that we can download and work with to be consistent. You can edit the JSON to include whichever values you would like, as long as it is compliant with the URI json schema.
Download the sample set and store it somewhere that can be easily referenced from the command line. We will be putting ours at ~/dev
. This will allow us to reference all the .PNG and .JSON files by using the path ~/dev/assets
.
Finally, we’ll need to update the address value in the json files. By default, the address used in the json files is 6j4nNrozTJkk1zatiXHezSLZArnRUq3WkGKHACThXGpZ
. We will update all of these to use the address that we’ve set up in the Solana CLI earlier.
To do so, run the following bash script:
for json_file in ~/dev/assets/*.json;
do
address=$(solana address)
sed -i '' "s/6j4nNrozTJkk1zatiXHezSLZArnRUq3WkGKHACThXGpZ/$address/g" $json_file
done
This code will loop through all of the files in your assets directory that end in .JSON
Then, it will store your Solana address in a variable with address=$(solana address)
. Finally, it uses the sed
command line tool to do a “find and replace” action. It searches through each file and replaces 6j4nNrozTJkk1zatiXHezSLZArnRUq3WkGKHACThXGpZ
with the address from the CLI.
Note:
The empty pair of quotes at the beginning of the
sed
command are necessary if you're on a Mac device. If you are running a linux machine, these quotes can be omitted.
Updated over 1 year ago