There’s no law against bartering, so technically you could trade a piece of gold for something else. The point is legal tender laws force you to accept dollars as payment, regardless of what your contract says. So if you contract to be paid in gold and the other party reneges and pays you in dollars instead, you have no recourse to enforce the contract. The court will say “You got paid in dollars? And you’re not happy with that? Look at what it says on the Federal Reserve Notes he gave you. ‘This note is legal tender for all debts, public and private’. You got paid. Case dismissed.”