Virtual currencies, such as bitcoin, are still in the relatively early stages of adoption, and many legal aspects of them aren't well understood. One big example is taxation -- that is, if you buy bitcoin or any other virtual currency and sell it for more than you paid, do you have to pay taxes on your profits?

The short answer is "yes," but how much tax you'll have to pay depends on a few factors. Here's a rundown of how the IRS classifies bitcoin and what it means for your taxes.

Tax forms, calculator, pencils, and stack of money on a table.

Image Source: Getty Images.

How are bitcoin profits taxed?

In 2014, the IRS labeled cryptocurrencies "intangible property." That means that all cryptocurrencies, including bitcoin, are subject to capital gains tax rules, just like when you sell a stock or other type of capital asset.

Capital gains tax is calculated based on the difference in dollar value between when the asset was purchased (your cost basis) and when the asset was disposed of (the sales price). The capital gains tax rate depends on your marginal tax bracket, and how much time passes between the purchase date and the sales date.

Specifically, any capital asset that is sold at a profit within one year of the purchase date is considered a short-term capital gain and is taxed at your marginal tax rate, or tax bracket. In other words, if you're in the 25% tax bracket for 2017, any profitable sales of bitcoin that you held for a year or less in 2017 will be subject to tax at that rate.

On the other hand, long-term capital gains are taxed at more favorable rates. Taxpayers in the 10% and 15% tax brackets pay no long-term capital gains tax, while taxpayers in the 25% through 35% tax brackets pay a 15% capital gains tax rate. Finally, taxpayers in the top 39.6% tax bracket pay a 20% long-term capital gains tax rate, as well as an additional 3.8% tax on net investment income in excess of certain thresholds.

For example, if you purchased 10 bitcoin in 2015 for $300 each (cost basis of $3,000) and sold them in 2017 for $3,000 each (sale price of $30,000), you have a $27,000 profit. Because you held these bitcoin for more than one year, the gain will be taxed at your long-term capital gains rate.

On the other hand, if you buy a bitcoin for $3,000 today and sell it for $4,000 next week, you'll have a $1,000 profit that is a short-term capital gain, and therefore is taxable at your ordinary income tax rate.

It's also important to note that only your overall long-term and short-term capital gains are subject to tax, meaning that losses can be used to offset gains. I'll discuss this more in the last section, but if you have two short-term bitcoin transactions during 2017, one that results in a $1,000 profit and another that results in a $800 loss, your short-term taxable gains for the year will be just $200.

Keeping track

It's important to mention that because bitcoin is considered to be property, every bitcoin transaction is potentially a taxable event. Of course, if you buy a bitcoin for $3,000 and sell it for $4,000 a few weeks later, the tax implications are pretty clear.

On the other hand, if you regularly use bitcoin to purchase goods and services, it can be much more complicated. For example, if you buy a $10 lunch with bitcoin, and that bitcoin originally cost you $9, the dollar in profit is technically a capital gain.

Therefore, to ensure that you're fully tax-compliant, it's important to keep accurate records. Whenever you acquire bitcoins, record how much bitcoin you purchased and the exchange rate you paid (in U.S. dollars). Then, when you dispose of bitcoin, either through a sale or by making a purchase, be sure to record how much bitcoin you spend, as well as the exchange rate at the time the disposition took place.

A record-keeping system like this can make your life much easier at tax time. And,since not every bitcoin transaction is likely to be profitable, good records can make it easy to calculate your net, or overall, bitcoin profit for a particular time period.

Can you avoid paying tax on bitcoin profits?

Before we go any further, it's important to mention that simply choosing not to report any profits you made with bitcoin transactions to the IRS isn't a good idea. The IRS is fully aware that a large percentage of bitcoin users don't report their profits and losses, and there's a major tax-evasion investigation under way targeting frequent bitcoin users. Simply put, if you make a profit from bitcoin, failing to report it could potentially get you into major trouble.

The good news is that there are a few ways you might (legally) be able to avoid paying taxes on bitcoin profits.

As I briefly mentioned earlier, the IRS allows taxpayers to use their capital losses to offset capital gains. In other words, if you own a stock and sell your shares at a loss, you could use those capital losses to offset your bitcoin profits. The rules on capital losses are a bit more complicated than I can explain in one paragraph, so be sure you understand the rules before you use this to your advantage.

Another possible way to avoid, or at least defer, paying taxes on bitcoin profits is by buying bitcoin through an IRA. This is a relatively new concept, but there are a few companies that will help you set up an IRA with the intention of buying bitcoin or other cryptocurrencies. To be clear, I don't think bitcoin is a good retirement investment, so I wouldn't suggest making it a part of your actual retirement saving strategy. However, if you are saving enough for retirement elsewhere, such as an employer's 401(k), a bitcoin IRA could be a good way to avoid or defer taxes on bitcoin profits.

The Motley Fool has a disclosure policy.