I'm trying to store records in a contract that are supposed to have an arbitrary number of fields. For example, one record would have "bitrate", another "ISBN" etc., in addition to a number of fixed fields. It is natural to store these fields as a string => string mapping.
Now, the question is, how do I pass these fields to the contract, and how do I get them back? Even the latest version of Solidity, v0.8, doesn't permit using mappings in public contract functions. I'm thinking of sending strings and parsing them inside the contract, but surely there is a more "native" Solidity way using low-level functions?
setField(itemId, fieldName, value)
andgetField(itemId, fieldName) public string
. However blockchain is not designed to be a storage of string data and it is quite inefficient, so unless this is a theoretical exercise it does not make much sense. – Mikko Ohtamaa Jan 12 at 11:04