During the crusade, Reval (Tallinn) was founded, as the capital of Danish Estonia, on the site of Lindanise. In 1248 Reval received full town rights and adopted the Lübeck law. The Hanseatic League controlled trade on the Baltic Sea, and overall the four largest towns in Estonia became members: Reval, Dorpat (Tartu), Pernau (Pärnu), and Fellin (Viljandi). Reval acted as a trade intermediary between Novgorod and Western Hanseatic cities, while Dorpat filled the same role with Pskov. Many guilds were formed during that period, but only a very few allowed the participation of native Estonians. Protected by their stone walls and alliance with the Hansa, prosperous cities like Reval and Dorpat repeatedly defied other rulers of Livonia. After the decline of the Teutonic Order after its defeat in the Battle of Grunwald in 1410, and the defeat of the Livonian Order in the Battle of Swienta on 1 September 1435, the Livonian Confederation Agreement was signed on 4 December 1435.