This repository is a fork of iraykhel/defitaxes, which its owner iraykhel is no longer able to maintain due to work constraints.
DeFi Taxes is a web-based application designed to help you calculate your crypto taxes using blockchain transaction data.
Many EVM blockchains are supported (e.g., Ethereum, BNB Smart Chain, Base, Arbitrum, Polygon, etc.) as well as Solana. See the supported chains list for the full list.
If you would like to contribute to this project, follow the instructions below to set up a development server.
You will need Python installed. See the official Python website for installation instructions.
Redis is used for storing user sessions and managing the process queue.
To install Redis, follow the Redis installation instructions.
Details of your Redis server should be added to the REDIS_URL
configuration parameter. See the Config section for more details.
All keys stored in Redis are prefixed to make them easier to identify, especially if you are sharing a Redis server with other applications. The prefix is defined by the REDIS_PREFIX
configuration parameter.
-
Clone the repository:
git clone https://github.com/BittyTax/defitaxes.git
-
Create a virtual environment for Python. This is optional but recommended.
cd defitaxes python -m venv .venv source .venv/bin/activate
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env
file. See the Environment Variables section for details. -
To run the development server:
flask run
By default, Flask will assume all application data is held in a folder called instance
. If you prefer to use a different location, set this using the environment variable DEFITAXES_INSTANCE_PATH
.
To run the application without a web server, you can use the Flask command:
flask driver process <address> <chain>
For example:
flask driver process 0x032b7d93aeed91127baa55ad570d88fd2f15d589 ETH
Copy the sample.env file to .env
and populate it with your API keys.
API keys can mostly be obtained for free by subscribing to the websites listed below. See footnotes for exceptions.
Name | Description |
---|---|
DEFITAXES_ETHERSCAN_API_KEY |
Etherscan - Ethereum (ETH) Blockchain Explorer |
DEFITAXES_OPTIMISTIC_ETHERSCAN_API_KEY |
Optimistic - OP Mainnet (ETH) Blockchain Explorer |
DEFITAXES_BSCSCAN_API_KEY |
BscScan - BNB Smart Chain (BNB) Blockchain Explorer |
DEFITAXES_ARBISCAN_API_KEY |
Arbiscan - Arbitrum One (ETH) Blockchain Explorer |
DEFITAXES_NOVA_ARBISCAN_API_KEY |
Nova Arbiscan - Arbitrum Nova (ETH) Blockchain Explorer |
DEFITAXES_POLYGONSCAN_API_KEY |
Polygonscan - Polygon PoS Chain (POL) Blockchain Explorer |
DEFITAXES_ZKEVM_POLYGONSCAN_API_KEY |
zkEVM Polygonscan - Polygon zkEVM (ETH) Blockchain Explorer |
DEFITAXES_SNOWTRACE_API_KEY |
Snowtrace1 - Snowtrace Multichain Explorer |
DEFITAXES_FTMSCAN_API_KEY |
FTMScan - Fantom (FTM) Blockchain Explorer |
DEFITAXES_CRONOSCAN_API_KEY |
Cronoscan - Cronos Chain (CRO) Blockchain Explorer |
DEFITAXES_CELOSCAN_API_KEY |
Celoscan - Celo Chain (CELO) Blockchain Explorer |
DEFITAXES_MOONSCAN_API_KEY |
Moonbeam - Moonbeam Chain (GLMR) Blockchain Explorer |
DEFITAXES_MOONRIVER_MOONSCAN_API_KEY |
Moonriver - Moonriver Chain (MOVR) Blockchain Explorer |
DEFITAXES_GNOSISSCAN_API_KEY |
GnosisScan - Gnosis Chain (xDAI) Blockchain Explorer |
DEFITAXES_BASESCAN_API_KEY |
BaseScan - Base (ETH) Blockchain Explorer |
DEFITAXES_BLOCKDAEMON_API_KEY |
Blockdaemon - Blockdaemon Institutional Gateway to Web3 (Solana RPC) |
DEFITAXES_COINGECKO_API_KEY |
CoinGecko2 - Cryptocurrency prices |
DEFITAXES_TWELVEDATA_API_KEY |
Twelve Data - Fiat prices |
DEFITAXES_DEBANK_API_KEY |
DeBank3 - Current token balances, some protocol names |
DEFITAXES_RESERVOIR_API_KEY |
Reservoir - Currently held NFTs |
DEFITAXES_COVALENTHQ_API_KEY |
CovalentHQ4 - Fees on Arbitrum, errors on Fantom, some counterparty info on Ethereum |
1 - No API key is currently required.
2 - You can use either the CoinGecko "Demo" plan which is free, or the paid "Pro" plan.
3 - DeBank is prepaid only, minimum 200 USDC.
4 - GoldRush offer a 14-day fee trial, or paid plans start at $50/month.
The application configuration is loaded into Flask using a Config object.
Name | Default | Description |
---|---|---|
DEBUG_LEVEL |
0 |
Enable additional debug logging stored in the instance/logs folder |
REDIS_URL |
"redis://localhost:6379" |
URL of Redis server |
REDIS_PREFIX |
"defitaxes" |
Prefix added to all Redis keys |
SOLANA_MAX_TX |
10000 |
Maximum number of Solana transactions to be processed. Used to restrict API usage. Remove this parameter to remove the limit |
COINGECKO_PRO |
False |
Choose between the "Pro" paid plan, or the "Demo" free plan |
The application requires two pre-configured SQLite databases. These reside in the instance
folder unless otherwise configured.
They have been removed from the repository due to size, but can be created manually.
This database contains address labels for each blockchain. It is mainly created by scrapping content from the Label Cloud of each EVM Block Explorer.
For Solana, the program labels are parsed using this Solscan file.
The code which creates this database is currently a separate repository. See blockchain-address-database.
This database contains:
- Fiat prices from Twelve Data
- Crypto prices and data from CoinGecko
- EVM signature mappings from 4Byte
I will add Flask commands to initialise and create these tables.