Schaffhausen was a city state in the Middle Ages, documented to have struck its own coins starting in 1045. For a time it was under Habsburg domination, but regained its independence in 1415. It allied itself with Zürich in 1457, and became a full member of the Swiss Confederation in 1501. The first railroad came to Schaffhausen in 1857.