Difference between wallet medata and account metadata?

We use some meta data for each user to store various state. It’s stored into a map[string]interface{} and then saved with:

nk.AccountUpdateId(ctx, userID, username, metadata, displayName, timezone, location, langTag, avatarUrl)

The data is unmarshalled from the user when needed. This all works fine. However, when looking at the WalletUpdate() function it also has a metadata parameter that has the same map[string]interface{} type. What is this used for and how does it differ from the account metadata? The docs say:

Additional metadata to tag the wallet update with.

What are the use cases where I would want to store metadata in the wallet? Is it meant so that I can store a reason why the wallet was updated, like the id of a match or a reference to a purchase of some kind? How would I later access this metadata?

@chakie The user metadata is intended to store custom, game-specific information about the user that does not already have a user or account field available! Good examples may be user level, or skill rating, and so on.

Wallet update metadata is intended for custom information about the wallet operation itself, exactly as you say. For example why an amount was deducted (spending soft currency) or granted (in-app purchase, its transaction identifier) and so on. This metadata is only then accessible via wallet ledger listings, mostly as part of the Nakama devconsole, and is most useful for customer support or debugging.

Hope this helps! :sunglasses:

1 Like

Thank you, that was exactly the info that I was looking for. We now use the user metadata for storing various game specific user properties, but the wallet metadata has been untouched so far. I think I will start adding some helpful info about what a transaction was for, just as you say.