i want to create uri in my nft collection contract
every nft item need uri, for example 0.json or 1.json
i have int variable and string variable like bellow
int _item = 10
slice _file = ".json"
and i want to merge it like this "10.json"
how can i do it in func ?
Dec 21, 2022, 7:49 AM
This might help in just converting the number part to string:
slice to_string(int n) {
builder b = begin_cell();
tuple chars = null();
do {
int r = n~divmod(10);
chars = cons(r + "0"u, chars);
} until (n == 0);
do {
int char = chars~list_next();
b~store_uint(char, 8);
} until (null?(chars));
return b.end_cell().begin_parse();
}
slice to_string(int n) {
builder b = begin_cell();
tuple chars = null();
do {
int r = n~divmod(10);
chars = cons(r + "0"u, chars);
} until (n == 0);
do {
int char = chars~list_next();
b~store_uint(char, 8);
} until (null?(chars));
return b.end_cell().begin_parse();
}
Dec 21, 2022, 8:41 AM