A Carat (Karat in USA & Germany) was originally a unit of mass (weight) based on the Carob seed or bean used by ancient merchants in the Middle East. The Carob seed is from the Carob or locust bean tree. The carat is still used as such for the weight of gem stones (1 carat is about 200 mg). For gold, it has come to be used for measuring the purity of gold where pure gold is defined as 24 carats.
How and when this change occurred is not clear. It does involve the Romans who also used the name Siliqua Graeca (Keration in Greek, Qirat in Arabic, now Carat in modern times) for the bean of the Carob tree. The Romans also used the name Siliqua for a small silver coin which was one-twentyfourth of the golden solidus of Constantine. This latter had a mass of about 4.54 grams, so the Siliqua was approximately equivalent in value to the mass of 1 Keration or Siliqua Graeca of gold, i.e the value of 1/24th of a Solidus is about 1 Keration of gold, i.e 1 carat.