(echo) by the hour is the way to go (echo)
I generally do not work for a fixed price, especially if there are unknowns. Even for non-binding estimates, I like to work on a phase basis: I ask the client to approve X number of hours for analysis & design, specifically to address the unknowns. The only guaranteed deliverable for this initial work is the results of my research. I may need to ask for additional hours to make sure I 'have my arms around' the entire project. Sometimes during this phase I determine that the project is not viable.
When I have worked through the unknowns, or if there are no major unknowns, experience guides me to a fairly accurate estimate, and at this point I am willing to do fixed price. My formula is to take what I optimistically think it will take, then multiply by 2.2. (Double it and add ten percent.) I have used this formula for over 25 years and it has guided me well. Past reliability gets factored in subconsciously in coming up with the original optimistic number.
Additional note: When working on the project, I shoot for my original optimistic guess. Projects always take longer than we expect, and if I shoot for the number I gave the client, I will probably go over it. By shooting for my original optimistic number, I always go over, but generally come in at or just under the estimate I gave the client.
Keep Up with TechRepublic