That would totally depend on the contract you signed.
If you were represented by an agent, your contract probably has a financing contingency in it. If the failure to sale your home causes you to be unable to obtain financing with in the stated criteria of your contract then that contingency would normally be a valid cause for the contract to be voided.
Have you read your contract??? I certainly hope you did prior to signing it... with or with out representation. In any case your answer is in that document, several different contingencies are normally place in purchase offers to protect the buyer, if you don't find it then the news is probably not good and you should seek the advise of an attorney and attempt to work out something with the other parties to the contract. Liquidation of Damages clauses should also have been in your offer to purchase and that would also limit your potential losses... check for those.
If you don't find any of those, well congradulations.... you have the potential to get a very good (and potentially costly) learning experience in contract law.