This is a very nice request topic.
I sadly don't have time to fulfill your request, but I can give a few hints. The worth of items should always be a number between 1 and 5 to avoid things like "half a star" and the items that the other "player" can be internally displayed as an array of arrays, like [[ID, QUANITY], [ID, QUANITY]]. I also suggest that it should be saved what was traded to avoid the player being able trade the same item over and over from an NPC by reentering the trade screen.
Good luck with your request.