I sold some rice on the condition that I will take the value of rice after a few months. The value that I will take will be the market price of rice at the time when I will take it.
All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
One of the agreed-upon conditions for the validity of the sale transaction is that the price be known to the contracting parties (while conducting the sale contract). Kashshaaf Al-Qinaa‘ reads, “One of the due conditions for the validity of the sale transaction is that the price of the commodity should be known to the contracting parties while conducting the sale contract because the price is given in return for the commodity; both elements, price and commodity, must be clearly identified and known to the contracting parties...”
Therefore, the sale that you described in the question is invalid because the price is unknown to the contracting parties at the time of the sale. Accordingly, the buyer must give you back the sold commodity (the rice).
Allaah knows best.
You can search for fatwa through many choices