We present a cap-and-trade scheme for the regulation of ridesharing. As opposed to marginal-pricing schemes, cap-and-trade schemes limit the quantity of transportation. Recognizing that a central authority may not be able to adequately regulate quantity, we let the quantity be determined according to demand for ridesharing. We use demand to compute the social cost of selfish driving in a virtual world where ridesharing does not exist and set this cost as a limit on the amount of social cost that a transportation network company (TNC) can incur. We perform analysis in the static case to show that our scheme has the effect of incentivizing the positive effects of ridesharing, i.e., carpooling, while limiting its negative effects, e.g., deadheading. We also present and discuss a practical implementation of the scheme. In implementation, the virtual social costs would be issued as credits through a central service and the actual social costs would be issued as debits; a net-positive balance would be imposed by the central service and TNCs could trade credits and debits on the open market.