This person needs a good criminal defense attorney immediately. Depending on the amount of drugs he was trying to sell to the undercover police officer, he could be facing a mandatory minimum state prison sentence of 2 to 4 years, or more.
It is possible for the local district attorney's office to "de-mandatorize" his charges, but that probably would only be part of a deal after substantial co-operation. And simply offering to co-operate is usually not enough- law enforcement expects defendant to be pro-active in their co-operation, since it is the defendant who will benefit from reducing an otherwise long prison sentence.
But again, these are extremely serious charges requiring expert legal help immediately.
Depends on the weight, the judge, whether cooperation panned out and the DA's opinion. You should consult with an experienced local defense attorney. As it is a felony, jail time is a possibility.