I wrote "скільки ця сметана коштує?". It said that I was wrong
So the rule here is the verb "kostovat" + nom ?
Yup (you mean коштувати?) Just like in English, "to cost" is understood as a metaphorical "action" performed by something of value.