Tom meets the Devil (who is known within the story as Old Scratch) and negotiates a bargain with him; the story says that the basic terms of the bargain were "easily surmised" - meaning that most people should be able to guess what they were, but neither Tom nor the narrator ever explicitly say what they are. We are meant to know from prior experience, or deduce from insight, that Tom is trading his soul for the treasure, and that the Devil will "collect" him when he dies.
However, it is implied that there are several conditions beyond this most obvious one that the two bargain over (although it's not clear how much bargaining power Tom might have had if he had already agreed to give over his soul). The Devil demands that the treasure be used "in his service", meaning for sinful purposes. He suggests that Tom buy and operate a slave ship, but Tom refuses to do this. The text says that he was bad in many ways, but that not even the Devil could convince him to do this (a statement which is perhaps influenced by the politics of the time in which it was written). Instead, they agree that Tom will lend money, which is a job that is "just to Tom's taste".