neo-project / proposals

NEO Enhancement Proposals
Creative Commons Attribution 4.0 International
136 stars 113 forks source link

NEP-11 properties method inconsistency #141

Open vincentgeneste opened 3 years ago

vincentgeneste commented 3 years ago

I believe the NEP-11 standard could use some clarification when it comes to the properties method.

The official standard (here: https://github.com/neo-project/proposals/blob/master/nep-11.mediawiki) states that for the properties method:

Returns a serialized NVM object containing the properties for the given NFT. The NVM object must conform to the "NEO NFT Metadata JSON Schema"

It also shows a signature like this

{
  "name": "properties",
  "safe": true,
  "parameters": [
    {
      "name": "tokenId",
      "type": "ByteString"
    }
  ],
  "returntype": "Map"
}

So this is the first issue, it's inconsistent, in one case it says a serialized NVM object, in the other it says a Map.

Also, I think for ease of use by wallets and dapps, one way to make it easier would be to allow the properties method to return a serialized json object, as it is way easier to deal with that, than to deal with a map / nvm objects directly (to avoid having to convert all base64 etc). A serialized json object also technically conforms to the standard since it is technically an NVM object, that also conforms with the json standard.

Thoughts?

hal0x2328 commented 3 years ago

I agree. I think that for the sake of adoption, a serialized JSON string should be the return type for properties.

There are likely to be numerous casual third-party NFT tools created, and if every developer of those tools has to learn how to deserialize NVM objects, many will be discouraged if they don't already have a background in low-level smart contract VM interaction.

The Map object return is only slightly better since they still have to base64-decode every field individually before they can utilize the data.

NFTs can bring a lot of new interest in Neo. We should make it easy for anyone who has mostly only experience working with fetching JSON objects in a front-end application to interact with Neo NFTs.

mfbz commented 3 years ago

I totally agree with this. A serialized JSON string would be so much accessible. No base64 parsing, no low-level interaction, just data ready to be used.

The easier it is for devs to interact with NFTs, the more we'll see NFTs based DApp on NEO, and I think that this proposal goes perfectly in that direction.

ediopia commented 3 years ago

I agree. I've tested both ways and JSON string is much simpler. I couldn't even find a way to deserialize NVM at frontend.

I was lost because some NGD sample nft contracts don't follow the standard description.

steven1227 commented 2 years ago

Try to solve in the https://github.com/neo-project/neo-modules/pull/651

devhawk commented 2 years ago

If we are going to consider changes to NEP11, can we also consider solving https://github.com/neo-project/neo-devpack-dotnet/issues/647 and https://github.com/neo-project/neo-modules/issues/629?