How did James Madison contribute to the Constitutional Convention?

He argued that the Convention should revise the Articles of Confederation.

He wrote the first draft of what became the Constitution.

He wrote the Statute on Religious Freedom, which became part of the Constitution.

He presented the idea of a two-house legislature.