menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Truffle Suite

Sweet tools for smart contracts

Channels
Team

Mappings won't show up

September 18, 2020 at 6:23am

Mappings won't show up

September 18, 2020 at 6:23am
Hey guys! I have a question relating to ganache. I'm testing out an NFT contract and ran into an issue. Mappings will not be recorded, however hard I try. I even made some simple test contracts to test it out which maps uint a = 3 to uint b = 4.
The contract compiles, shows up in my ganache GUI, but alas. No mapping still Is this a known issue?
Also, I would like to add that I'm a big fan of the platform. it's really great to have such an easy way of interacting with contracts! Other than the mappings, everything is working great. unfortunately, it's kind of a big part :')

September 18, 2020 at 6:26am
Yeah, sadly Ganache UI doesn't support decoding mappings right now. This is something we're aware of and have in mind to add, but there's a few technical limitations we'd have to overcome for that to be possible.
like-fill
1
Okay, great to hear that I'm not going crazy! :) The fact that it's there confused me a lot
Thanks for the answer!
Hopefully some of the work we've been doing lately will help pave the way for that. In the meantime, I can point you in a direction of a workaround to get this information, if you're comfortable with doing it JS instead of a GUI
happy to help!
Ah, I would love a workaround! What do you suggest?
Edited
so, Ganache UI uses /decoder under the hood, and /decoder let's you specify mapping keys you're interested in (it looks like: decoder.watchMappingKey("balances", "0x..."), if you're trying to see balances[0x...])
you can take a look at the documentation here https://www.trufflesuite.com/docs/truffle/codec/index.html
should warn you - it's currently designed for advanced use cases, since we needed to solve that first for internal improvements / to support Truffle enhancements
Edited
anyway, happy to answer questions :)
like-fill
1
I understand, it's very useful non the less. Happy with the great support! I love the product suite, I'll be sure to tell you how it goes when I get to it.
like-fill
1
sounds good, looking forward to hearing about your experience!