Townsend Harris (1804–78) served 1856-1861 as the first American diplomat after Perry left. He won the confidence of the Japanese leaders, who asked his advice on how to deal with Europeans. Harris in 1858 obtained the privilege of Americans to reside in Japan's four "open ports" and travel in designated areas. It banned the opium trade and set tariffs. He was the first foreigner to obtain an extended commercial agreement; it was more equitable than the unequal treaties soon obtained by Britain, France and Russia.