Sometimes written, too. For example, in Japanese doujins, we have the Touhou Project/ZUN issuing an explicit license where Touhou creators are given permission to do their thing, but if they want to sell their works outside a convention like Reitaisai or a doujin-focused reseller like Toranoana, they have to contact him and work out a licensing agreement.
A big part of the cease-fire between IP holders and fanfic authors is probably the unwritten rule that the fanfic shall not be directly monetized.
Sometimes written, too. For example, in Japanese doujins, we have the Touhou Project/ZUN issuing an explicit license where Touhou creators are given permission to do their thing, but if they want to sell their works outside a convention like Reitaisai or a doujin-focused reseller like Toranoana, they have to contact him and work out a licensing agreement.