Contracts are very easy to write. They're modeled after the .desktop format, with a couple of additions. Below is an example of a real contract for changing the wallpaper in a gnome environment:
[Contractor Entry] Name=Wallpaper Icon=wallpaper Description=Set as wallpaper MimeType=image Exec=gsettings set org.gnome.desktop.background picture-uri %u
It follows the Desktop Entry Specification:
|%f||A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax.|
|%F||A list of files. Use for apps that can open several local files at once. Each file is passed as a separate argument to the executable program.|
|%u||A single URL. Local files may either be passed as file: URLs or as file path.|
|%U||A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.|
This file, named wallpaper.contract, is stored in /usr/share/contractor/ along with all of the other contracts.