Much has been said about the Electoral College the past month. This page at the National Archives lists all the relevant sections of the US Constitution.
There is nothing in the constitution that requires electors to vote as mandated by the state. Any such laws exist at the state level.
The image on the right is the Electoral College votes for the 1824 Presidential election which eventually say John Quincy Adams selected by the US House. This election lead Andrew Jackson to form the Democratic Party.