When were the first formal baseball rules created?

The first formal baseball rules created in 1845.

The New York Knickerbocker Base Ball Club was formally established at the instigation of Alexander Joy Cartwright. Cartwright and Daniel Lucius “Doc” Adams created a set of rules that would change the game of baseball forever. Adams and Cartwright are credited with the development of the game of baseball as we know it today.