Open runvnc opened 2 years ago
Also if I write some JavaScript for this encoding/decoding I can make it open source. I guess the challenge for re-encoding this data is it requires one to know the schema, i.e. all of the different trait variants and their order.
My suggestion would be to place this in a special ASA in the account (possibly the first config transaction?) identified with a property like is_schema
or something, that just describes/lists all of the possible trait variants:
{ color: ['bronze','silver','gold'],
power: 'byte' }
I am planning to start putting the trait data in the Reserve Address field (in addition to the config notes). I don't see another option that will allow smart contracts to access it.
Example: item has color, and power traits. 3 different colors (0 - bronze 1 - silver, 2 - gold), and power from 0 to 100. So say the item is
color: silver
andpower: 50
the reserve address (as a byte array) would be something like[1,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
This will allow for the development of games that run on chain. For example (forgive me if I am getting some details wrong, just a hypothetical I haven't tried), a battle between two characters (represented as ASAs) can use the Txn.ForeignAssets to pass in two fighting characters, then access the asset params, generate a random number and weight it with the second (or 31st?) byte (the
power
level) and compare the two to see which character wins the fight round. Etc.