0

For example, I know the code below isn't valid syntax, but would doing something like it be possible to dynamically set metadata content based on the token id? If so, how would that work?

@sp.offchain_view(pure = True)
    def token_metadata(self, tok):
         sp.result(sp.pair(tok, sp.big_map({
            "": sp.utils.bytes_of_string("ipfs://QmTwyN85GfziB5BGhF2ELogeJRt6CwevZY729bahQqKHiD/" + str(tok) + ".json"),
            "name": sp.utils.bytes_of_string("TRR Token " + str(tok)),
            "symbol": sp.utils.bytes_of_string("TRR"),
            "decimals": sp.utils.bytes_of_string("0")
         })))

When running the code above without the string concatenation, I'm getting this error for the metadata view:

(ERROR "Cannot compile missing type: a132") × <contract-storage> → (pair (ERROR "Cannot compile missing type: a132") (pair (nat %token_id) (map %token_info string bytes)))

1 Answer 1

0

I tried this and it is possible. The only thing is, it only partially does what I want. Also, it introduces confusion because we can't do string concatenation for the name, thus it would have to be a generic name.

For what I want to do, which is support a 10,000 NFTs, a better solution would be to have them all in an IPFS file or do a URI based approach. Even though this would mean the token isn't TZIP-12 compliant (no token_metadata big map stored and no token_metadata off_chain view).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.