By 1855, most of California's surface gold had already been panned out, leaving only the richer but deeper veins of ore, which individual miners couldn't retrieve without massive capital investments. Despite that, San Francisco had evolved into a vast commercial magnet, sucking into its warehouses and banks the staggering riches that overworked newcomers had dragged, ripped, and distilled from the rocks, fields, and forests of western North America.
Investment funds poured into more than mining, however. Speculation on the newly established San Francisco stock exchange could make or destroy an investor in a single day, and several noteworthy writers (including Mark Twain) were among the young men forever influenced by the boomtown spirit. The American Civil War left California firmly in the Union camp, ready, willing, and able to receive hordes of disillusioned soldiers fed up with the internecine warmongering of the Eastern seaboard. In 1869, the transcontinental railway linked the Eastern and Western seaboards of the United States, ensuring the fortunes of the barons who controlled it. The railways shifted economic power bases, however, as cheap manufactured goods from the East undercut the costly articles brought on ships that sailed or steamed around the tip of South America. The "Big Four" -- iron-willed capitalists Leland Stanford, Mark Hopkins, Collis P. Huntington, and Charles Crocker -- almost completely controlled ownership of the newly formed Central Pacific and Southern Pacific railroads, and their ruthlessness was legendary. (Much of the bone-crushing railway labor was done by low-paid Chinese newcomers, most of whom arrived in overcrowded ships at San Francisco ports.) As the 19th century came to a close, civil unrest became more frequent as the monopolistic grip of the railways and robber barons became more obvious. Adding to the discontent were the uncounted thousands of Chinese immigrants who fled starvation and unrest in Asia at rates rivaling those of the Italians, Poles, Irish, and British.
During the 1870s, the flood of profits from the Comstock Lode in western Nevada diminished to a trickle, a cycle of droughts wiped out part of California's agricultural bounty, and local industry struggled to survive the flood of manufactured goods coming by rail from well-established East Coast and Midwestern factories. Often, discontented workers blamed their woes on the now-unwanted hordes of Chinese workers who, by preference and for mutual protection, had congregated in teeming all-Asian communities.
Despite these downward cycles, the city enjoyed bouts of prosperity around the turn of the 20th century, thanks to the Klondike gold rush in Alaska and the Spanish-American War. Accustomed to making a buck off gold fever, San Francisco managed to position itself as a point of embarkation for supplies bound for Alaska. Also during this time, the Bank of America emerged; it eventually grew into the largest bank in the world. Founded in North Beach in 1904, the bank was the brainchild of Italian-born A. P. Giannini, who later funded part of the construction for a bridge many critics said was preposterous: the Golden Gate.