Suppose you're an organization contracting with a freelancer to create something (e.g. a software application, a report) that you expect to be funded by grants, but you don't yet have the budget for it. The freelancer wants to ensure that the client takes reasonable steps to apply for funding for the project and pays out all (or defined portions) of the grant money they receive. The client wants to ensure that they don't owe the freelancer any money other than the grant money they actually receive that is earmarked for the project, except for possibly a small deposit/advance at the beginning.
Suppose further that the client gets a grant for a general budget (e.g. a technology budget) that they can spend on projects at their discretion, and one of those projects is one for which they have already promised funding to the freelancer. The freelancer's project can't hog the entire grant budget, but the freelancer should be guaranteed a minimum portion of that budget regardless of how much money the organization receives (e.g. 20% of the grant money or $5,000, whichever is less).
Are there any templates/examples for how these contracts are structured, within or outside the EA community?
I don't really understand the question here: If an organisation contracts someone to do work for them, they usually agree on a specific amount, either a fixed price or an hourly/daily rate. What are the specifics of your scenario here? Should the amount be conditional on how much funding the organisation receives for that specific work? That seems a quite strange approach to me. Or are you expecting that the contractor commits to doing the work but might not get paid if a grant application is unsuccessful? I don't really think anyone would or should agree to that. The right approach should be to wait with actually hiring the contractor until the organisation has the money to pay for them.