Cryptocurrencies such as bitcoin have raised both excitement and questions about what exactly digital currency is and how it works. If you have traded in cryptocurrency, you may be wondering how your transactions are taxed. Whether you went all in on bitcoin or another cryptocurrency or invested just a few hundred dollars, it’s important to understand how the IRS treats the exchange of digital currency so that you can file your return, and pay your taxes, correctly. Here’s what you need to know…

Cryptocurrency is taxed as a property. The IRS treats digital or virtual currency for tax purposes as a capital asset, similar to a stock or real estate. That means that every time you exchange cryptocurrency—whether you sell your position for cash or trade it for another digital currency—it’s considered a taxable event. If you make a profit on the exchange, you have a capital gain just as you would with the sale of an appreciated stock. What makes cryptocurrency unique—and potentially troublesome for tax filers— is that exchanging cryptocurrency directly for goods or services is not treated like spending money—it’s still considered a taxable event. From an IRS perspective, when you use digital currency to buy something from a merchant or service provider, you’re not “spending” it—you’re selling it as an investment and then using the resulting cash (even if you never take possession of any cash!) to make the purchase and, by doing so, triggering potential capital gains tax.

Caution: Some people are suggesting that swapping one cryptocurrency for another could qualify as a tax-free, “like-kind” exchange. A like-kind exchange allows investors to avoid capital gains tax on the sale of property if they purchase a similar asset to replace it and meet certain technical conditions. The fact is, Congress has already changed the rule for 2018 to explicitly restrict like-kind exchanges to real estate. However, it hasn’t offered clear guidance on how it will treat investors who use the rule to classify pre-2018 cryptocurrency exchanges as like-kind. While it might seem an attractive tax loophole, there’s no guarantee that someone trying it won’t be assessed not only taxes but also, potentially, interest and penalties.

You’re responsible for calculating your own cryptocurrency tax liability. When you trade mainstream investments through a traditional brokerage account, your gains and losses are typically calculated for you. With cryptocurrency, you must keep a record of your transactions throughout the year and use them to determine how much you owe in capital gains tax. If you trade through a cryptocurrency exchange like Coinbase or Bittrex, that platform will generate transaction reports that you can download to track your activity. If you use digital currency to buy goods and services, you’ll need to keep receipts of those purchases. Once you’ve gathered that documentation, there are a number of online resources, such as Bitcoin.tax and Cointracking.info, which can process the figures and calculate the gain you report to the IRS.

Managing your tax liability with cryptocurrency is a more involved process than you may be accustomed to. But by familiarizing yourself with the rules and dutifully tracking your trading activity, you can avoid additional stress come April.