Praise be to Allah.
The piece of gold that you took is collateral or a security deposit, and there is nothing wrong with stipulating collateral when giving a loan, because Allah, may He be exalted, says (interpretation of the meaning): “then a security deposit [should be] taken” [al-Baqarah 2:283].
The collateral or security deposit is a trust (amaanah) given to the one who requests it, and he is not liable unless he willfully damages it or is negligent. Negligence includes failing to keep it in an appropriate place.
Ibn Qudaamah (may Allah have mercy on him) said: But if the one who is keeping the collateral willfully damages the collateral or is negligent about keeping it in a safe place, and that leads to it being damaged or destroyed, then he is liable. We do not know of any difference of scholarly opinion regarding his liability. Moreover, it is a trust (amaanah) in his care, so if it is damaged or destroyed as a result of his willful action or negligence, then he is liable, as in the case of an item that has been entrusted to him for safekeeping. But if it is damaged or destroyed without any willful action or negligence on his part, then he is not liable, and it is the property of the one who gave it to him as collateral. That was narrated from ‘Ali (may Allah be pleased with him). This was also the view of ‘Ataa’, az-Zuhri, al-Awzaa‘i, ash-Shaafa‘i, Abu Thawr, and Ibn al-Mundhir.
End quote from al-Mughni (4/257).
It was narrated from Ahmad (may Allah have mercy on him) that he said: If the collateral goes missing when in the care of the one who is keeping it, he is liable. See: al-Insaaf (5/159).
Based on that, there must be some negligence involved in the loss of the piece of gold that was given as collateral, so you are liable for it, unless its loss was due to some cause beyond your control, such as a fire or a break-in and theft.
You should have told the borrower about the loss of the gold when it happened. If the value of the gold at the time of its loss was equal to the debt, then the debt is regarded as having been discharged.
What appears to be the case is that you must pay the value of the gold on the day it was lost, because this value takes the place of the collateral, so it remains something that you owe.
It says in al-Mawsoo‘ah al-Fiqhiyyah (28/257): There is some difference of opinion with regard to working out the value of the collateral that is kept by the lender.
The Hanafis stated that the value of the collateral, if it is destroyed, is its value on the day it was taken, because on that day he became liable for it, and on that day the exchange took place, hand-to-hand and the lender became liable when it was destroyed.
But if the collateral was something that the lender, or someone else, consumed, then its value is its value on the day it was consumed, and that value becomes the collateral that is to be returned.
With regard to working out the value of collateral that has been destroyed, the Maalikis have three views, all of which were narrated from Ibn al-Qaasim:
The first view is that [what matters is its value] on the day it was destroyed, because the collateral still existed on that day, and as it was destroyed on that day, its value on that day is to be taken into consideration. End quote.
And Allah knows best.