In this case, the court should enforce the contract on the USD with reasonable exchange rate or enforce the contract as it is (pay and only pay by bitcoin)?
There is no "should" about it. The court can ONLY award damages in legal tender. The court isn't going to try an enforce a contract. If one parties breaks the contract then the other party sues for
DAMAGES (in legal tender). That is the whole definition of legal tender. When the contract is broken and you sue in court the court can award you damages as compensation for your loss. The requirement that creditors must accept payment for debts in legal tender comes from this basis. If a debtor doesn't pay a creditor what can the creditor do? Take the debtor to court right? If the court agrees with the creditor what are they going to do? Award damages right? What form will those damages be in ... legal tender. The requirement for a creditor to accept payment in legal tender simply shortcuts you right to the forgone conclusion (and hopefully avoid a lot of court cases).
For example, lets say I loan you 100 bitcoins and in exchange you sign an agreement to pay me 105 bitcoins one year from now. Next year rolls around, and you won't give me any bitcoins but you do offer me USD, which I refuse.
You have no legal right to refuse legal tender for a debt owed. Your doing so would be looked upon dimly by the court. Even if the court awarded damages expect an ass chewing by the court (potentially even a reduction in the damages awarded). The only thing the court will do is award you damages in legal tender. So for you to refuse legal tender and seek recourse in the court is a colossal waste of time for both parties and the court.
You prove to the court that you are owed x BTC (i.e. contract is valid), and you prove to the court that the value of a "BTC" is y USD and the court would award you damages in the amount x * y USD.
Now just because the court awards damages in US dollars (legal tender) doesn't mean that you and the counterparty can't reach an agreement out of court. If the other party has the BTC and now having lost in court decides to pay up it in BTC that is fine. It may be more economical for him to just give you the BTC directly (rather than sell it for USD, pay you the USD and then you use the USD to buy back the BTC). There is nothing which prevents settling a judgement by other than legal tender if both parties agree to it. You would just draw up an agreement stating the transfer of X BTC satifies the judgement owed, conduct the transfer (possibly with escrow), sign the agreement and the counterparty could present it to the court to have the judgement satisfied. So legal tender doesn't prevent conducting business using another asset. However if one party doesn't agree then repayment will be in legal tender.
You can't write a contract which guarantees repayment in anything but legal tender.
If you lend me 100 oz of gold and I go into default, your only recourse is to sue for damages in legal tender.
If you give me 100 BTC for secure storage and I report it has been stolen, your only recourse is to sue for damages in legal tender.
If you lend me your priceless one of a kind antique vehicle and I destroy it, your only recourse is to sue for damages in legal tender.
The court can't force me to return the gold I spent on hookers and blow, the stolen BTC, or the one of kind antique which no longer exists. The court can however find me liable and award you damages to compensate you for your loss.
TL/DR
You can write a contract involving any asset. You could write a contract which contracts for difference on the value of oil measured in silver, with settlement in metric tons of potatoes.
The courts can ONLY award damages in legal tender. A creditor MUST accept payment for a debt in legal tender.