This is certainly not an easy question to answer. I doubt there is someone who know this, actually. It's very technical and legal. If you're really interested about this, perhaps you could browse the internet and try to see whether other people had similar questions? Maybe some of them got the answers.
A wild guess: I bet taxes must be paid. If you're home is on solar panels, for example, in Germany, you can sell the energy, if you have extra, but you also must pay taxes, so... I don't think that the system varies much.