The exchange that Dorian makes comes directly from the old legend of Faust, who gave his soul to the Devil in exchange for unlimited power whilst on earth. Dorian trades his soul for eternal youth and beauty. The supernatural bargain he makes ensures that the marks of age, sin and vice appear only on the portrait that Basil Hallward painted and that Dorian is so jealous of, because it captures his youthful beauty and innocence so perfectly. With the bargain having been made, Dorian is free to follow Lord Henry's hedonistic advice, and engage in every crime and pleasure known to man. However, what is clear is that at varioius points he is reminded of what he has done. Note the following quote from Chapter 16:
Dorian walked to the door with a look of pain in his face. As he drew the curtain aside, a hideous laugh broke from the painted lips of the woman who had taken his money. "There goes the devil's bargain!" she hiccoughed, in a hoarse voice.
When challenged, this woman then calls Dorian "Prince Charming," and this is a reference of course to what was at stake and what Dorian has sacrificed everything for. The reference to Dorian as "the devil's bargain" is of course a direct link to the Faust legend: Dorian has made a bargain with the Devil and is now realising just what trouble he is in. Like Faust, he tries to do everything to avoid his fate, but finds that it is too late, and dies without being able to redeem himself.