Create a simulacrum chain, generating an unbounded sequence of copies of you.
These simulacrums then create magic jars (500 gp ornate scroll cases), and transfer to true-polymorph created mimics. (note: if you have a separate collection of mimics, that can also work)
These mimics transform into scrolls of paper. You scribe the spell on these scrolls.
If the spell is used in any way you don't want it to, the simulacrum-mimics simply transform to a different form (say, a blank scroll), then abandon their mimic back into the scroll case. As they are The mimic is no longer scrollsthe spell, they cannot be scribed or even cast fromand it attacks the violator of the contract.
(The The simulacrum survives in the scroll case can be the magic jar, from which would makeit can continue on the mimic-attack less of a suicide missionusual way one does (possessing creatures for the simulacrums. If there is a riskrest of separation, the simulacrum can transform to a blank scroll and then flee to the scroll case.eternity).
Using this technique you can enforce any contract you want, so long as a simulacrum of it can detect violation while soul jared into a mimic shape-changed into a scroll that is.
Of course, this is similar to using a nuclear bomb to kill an ant in that we broke D&D 3 times before breakfast when creating this MRM, costs 2000 gp and multiple castings of a 9th level spell (unless you find a herd of mimics you can abuse).