Skip to content

Commit

Permalink
script to generate metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
FredCoen committed May 20, 2022
1 parent fdb91bb commit 0546914
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ cache/
node_modules
.env
assets
out
out

# Added by cargo

/target
39 changes: 39 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "cryptotesters-merkle-whitelist-nft"
version = "0.1.0"
edition = "2021"

[[bin]]
name="Generate-metadata-files"
path="./generateMetadata.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde_json = "1.0.81"
25 changes: 25 additions & 0 deletions generateMetadata.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::fs::File;
use std::io::prelude::*;
#[macro_use]
extern crate serde_json;

fn main() {
let mut id = 0;
loop {
id += 1;
if id < 2001 {
let file_path = format!("./assets/metadata/{}", id);
let mut file = File::create(file_path).expect("Error encountered while creating file!");
let dynamic_image = format!("https://cryptotesters.mypinata.cloud/ipfs/QmdwSvMaprFBQ7EjdiJ67GYVFgr6q18W4u2pK6f65BqnCh/{}.png", id);
let dynamic_name = format!("Tester{}", id);
let content =
json!({"description":"Cryptotesters","image": dynamic_image,"name": dynamic_name});

file.write_all(serde_json::to_string_pretty(&content).unwrap().as_bytes())
.expect("Error while writing to file");

continue;
}
break;
}
}

0 comments on commit 0546914

Please sign in to comment.