Writing a "contract" with a demon/diety/spirit?

This was pretty informative: