(cross-posted from the tezos dev slack, it’s hard to know the right place to put things like this!)
Hi folks - i’ve been having some trouble with a next-gen NFT contract in SmartPy, and i’ve come to the conclusion that the underlying issues i’m having might need some language-level support. so i’m basically here to air a proposal for adding nat to string and address to string support to Michelson.
In Michelson there is currently no native way to convert a nat to a string, or an address to a string, or vice versa. However, when writing NFT metadata retrieval views - which we currently have to do off-chain (TZIP-16) but which Hangzhou enables us to do on-chain - it is often desirable to be able to convert nats or addresses to strings (for example: assembling URIs by appending a token id or wallet address to a base URI in contract storage). Currently, if we want to append a nat to a string we have to build a map of nat 0…9→single digit strings “0”…“9”, and assemble the string manually, digit by digit. This is far from ideal.
It seems that especially after Hangzhou adoption, inter-contract calls might also benefit from being able to do nat to string/address to string (and perhaps in the other direction too). I am imagining a situation where a client contract expects map keys to be formatted one way, but the calling contract only has access to keys formatted a different way. Richer string composition and decomposition tools would be advantageous for future-proofing Michelson and the Tezos ecosystem more generally.
What might be the technical or design considerations to adding the following instructions:
nat to string address to string bytes to string
string to nat string to address string to bytes
to Michelson, in a future protocol change? I can name at least three other NFT contract developers besides myself who would benefit from at least a
nat to string native instruction, and I am sure there are others - as well as other use-cases beyond NFTs that are not at this point readily apparent.
Please let me know your thoughts.