I read this as a paperback around the 90s in English, part of a collection of the shelves of our house (so it might be older). The cover has the protagonist considering the box, which I remember as having geometric designs and a blue motif. Said protagonist starts the book as a rug merchant, selling "flying carpets" that move on their own. In the middle of a demonstration, his trained beetles (how he got the carpets to move on their own) suddenly start fleeing the carpet, scotching his scam. Another merchant, who'd earlier been annoying the protagonist by shilling a lawn roller, proceeds to use said roller on the carpet, killing a number of the beetles before the protagonist can stop him (with it being implied that the beetles sense the upcoming disaster and tried fleeing in advance, thereby causing the disaster they were trying to avoid. I think the protagonist had to flee the marketplace as people were after him for running a scam.
Somehow, he winds up up with this box which is said to be able to take anything he gives it, and always gives him what he needs. It had drawers on all four sides of it, and I think it had more sides/angles than a regular cubic box. At least the first few times the protagonist tries to get "what he needs" out of the box, he gets cryptic notes on slips of paper and he's convinced it's a scam.
At some point in the book, he is ushering a small child around. At first I wanted to say that was his quest, for which he was given the box, but now I feel like it was him waking up in the middle of the night to find the child standing above him. I think the child actually urinates on him, something I found kind of gross as an adolescent. And said child might have been gone by the time he was awake again, but the wet spot was still present. The only other thing I remember in the book was that eventually he learns that he can give the magic box non-physical things, like his fear and doubts, and they are actually removed.