The important thing there, even before you get to writing an actual contract, is to write out the agreement informally and sit down with your friend and go over everything to make sure you are talking about the same thing. Most of the problems I have seen have resulted from people assuming they understood each other's positions when they didn't. Then you can write a formal contract if you need one (the most dangerous potential risk is if one party dies and things have to go through probate, all the good will in the world won't help then).
This may work if you're starting out by yourself, but as soon as you involve another person you have to have contracts. Too many people I know have lost their best friends over relying on decency. When money is involved spell it out multiple times in a contract and have it reviewed. Removing any confusion early on will prevent huge headaches later.