RanchiMall's Token and Smart Contract system
Go to file
2024-12-01 10:40:46 +05:30
.github/workflows Update test_parsing.yml 2023-05-18 14:58:13 +05:30
tests Refactoring + cleanup 2023-05-18 09:26:13 +00:00
.gitignore Converting calculations to Decimal calculations 2023-11-11 05:00:22 +00:00
config-example.ini Update config-example.ini 2024-11-27 10:00:17 +05:30
config.ini Update config.ini 2024-12-01 10:40:46 +05:30
convert_db.py Changes to updateLatestTransaction so it can take unique transactionType as argument 2022-02-24 13:07:20 +00:00
models.py Update models.py 2024-11-27 08:46:39 +05:30
parser_function_definitions.py Update latest code 2022-01-06 08:35:44 +00:00
parsing.py Update parsing.py 2024-11-27 08:47:57 +05:30
planning.txt Cleanup 2022-11-17 12:00:50 +00:00
pyflosetup.sh Update pyflosetup.sh 2024-11-27 09:15:05 +05:30
README.md Update README.md 2024-11-28 06:37:05 +05:30
requirements.txt Merged requirements.txt for Scanner and API 2024-12-01 10:33:40 +05:30
setup.sh Update setup.sh 2024-11-28 06:29:52 +05:30
smart-contract-system-redesign.txt Refactoring processBlock & adding smart contract plan 2022-01-10 20:54:02 +05:30
sqlite_to_mysql.sh Create sqlite_to_mysql.sh 2024-10-29 10:59:39 +05:30
statef_processing.py Cleanup and updating of flosight link 2023-03-01 11:56:36 +00:00
tracktokens_smartcontracts.py Update tracktokens_smartcontracts.py 2024-12-01 10:34:38 +05:30
util_db_connect.py Refactoring + cleanup 2023-05-18 09:26:13 +00:00
util_rebuild_withAPI.py Added new helper scripts 2023-09-11 11:33:37 +00:00
util_rebuild.py Added rebuild code 2023-08-22 10:49:34 +00:00
util_reset_latest_block.py Added new helper scripts 2023-09-11 11:33:37 +00:00
util_rollback.py Converting calculations to Decimal calculations 2023-11-11 05:00:22 +00:00

Howto start the MYSQL version

Setup setps

  1. Just download one file from this setup.sh and run it. It will download the rest of repository
  2. Give setup.sh execute permissions first chmod +x setup.sh, and then ./setup.sh
  3. Run setup.sh to install python3.7 virtual environment, install and configure MySQL if it does not exist, install all dependencies and then start the application.

How to run

  1. python3.7 tracktokens-smartcontracts.py

  2. python3.7 tracktokens-smartcontracts.py --reset

  3. python3.7 tracktokens-smartcontracts.py --rebuild

  4. python3.7 tracktokens-smartcontracts.py --rebuild usd# tokenroom#

  5. python3.7 tracktokens-smartcontracts.py => To run normally

  6. python3.7 tracktokens-smartcontracts.py --reset => To remove all data and start from scratch

  7. python3.7 tracktokens-smartcontracts.py --rebuild => To reprocess existing blockchain data for ALL TOKENS as stored in latestBlocks table of rm_latestCache_db database

  8. python3.7 tracktokens-smartcontracts.py --rebuild usd# tokenroom# => To reprocess existing blockchain data for USD# TOKENROOM# as stored in latestBlocks table of rm_latestCache_db database

FLO Token & Smart Contract System

Test flodata parsing

Important versions and their hashes

The python script scans the FLO Blockchain for Token and Smart Contract activity and creates/updates local SQLite databases accordingly.

339dac6a50bcd973dda4caf43998fc61dd79ea68 The legacy token and smart contract system running currently on the server

41c4078db98e878ecef3452007893136c531ba05 ==> WORKING VERSION | Token swap branch The latest version with token swap smart contract and token transfer with the following problems:

  1. Parsing module is not able to detect token creation and transfer floData
  2. The smart contract system is not moving forward because it is not able to detect token databases as they are created when run form scratch, however it is working with old created token databases

89d96501b9fcdd3c91c8900e1fb3dd5a8d8684c1 Docker-compatibility branch is needed right now because Docker image made for flo-token-tracking required some changes which have been made in that branch.

How to start the system

  1. Create a virtual environment with python3.7 and activate it

    python3.7 -m venv py3.7 
    source py3.7/bin/activate
    
  2. Install python packages required for the virtual environment from pip3 install -r requirements.txt

  3. Setup config files with the following information
    For testnet

    # config.ini
    [DEFAULT]
       NET = testnet
       FLO_CLI_PATH = /usr/local/bin/flo-cli
       START_BLOCK = 740400
       FLOSIGHT_NETURL = https://0.0.0.0:19166/
       TESTNET_FLOSIGHT_SERVER_LIST = https://0.0.0.0:19166/
       MAINNET_FLOSIGHT_SERVER_LIST = https://blockbook.ranchimall.net/
       TOKENAPI_SSE_URL = https://ranchimallflo-testnet-blockbook.ranchimall.net
       IGNORE_BLOCK_LIST = 902446
       IGNORE_TRANSACTION_LIST = b4ac4ddb51188b28b39bcb3aa31357d5bfe562c21e8aaf8dde0ec560fc893174
       DATA_PATH = /home/production/deployed/ftt-blockbook-migration-testnet-rescan
       APP_ADMIN = oWooGLbBELNnwq8Z5YmjoVjw8GhBGH3qSP
    

    For mainnet

    # config.ini
    [DEFAULT]
       NET = mainnet
       FLO_CLI_PATH = /usr/local/bin/flo-cli
       START_BLOCK = 3387900
       FLOSIGHT_NETURL = https://blockbook.ranchimall.net/
       TESTNET_FLOSIGHT_SERVER_LIST = https://0.0.0.0:19166/
       MAINNET_FLOSIGHT_SERVER_LIST = https://blockbook.ranchimall.net/
       TOKENAPI_SSE_URL = https://ranchimallflo-blockbook.ranchimall.net
       IGNORE_BLOCK_LIST = 2
       IGNORE_TRANSACTION_LIST = b4
       DATA_PATH = /home/production/deployed/ftt-blockbook-migration-rescan
       APP_ADMIN = FNcvkz9PZNZM3HcxM1XTrVL4tgivmCkHp9
       API_VERIFY = False
    
    
  4. Install pyflosetup.sh if dependency errors of any kind come. Give it execute permissions first chmod +x pyflosetup.sh, and then ./pyflosetup.sh

  5. If running for the first time, run python3.7 tracktokens-smartcontracts.py --reset otherwise run python3.7 tracktokens-smartcontracts.py

How to setup a virtual environment

To set up a virtual environment that uses Python 3.7 while keeping Python 3.10 as the default system version, follow these steps: Step 1: Make Sure Python 3.7 is Installed

Ensure Python 3.7 is installed on your system:

Add the deadsnakes PPA (if not already done):

bash

sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update

Install Python 3.7 and the venv module for Python 3.7:

bash

sudo apt install python3.7 python3.7-venv

Step 2: Create a Virtual Environment with Python 3.7

Since you want your virtual environment to specifically use Python 3.7, you need to use Python 3.7 explicitly to create the venv, while keeping Python 3.10 as the system's default Python:

Create the virtual environment using Python 3.7:

bash

/usr/bin/python3.7 -m venv myenv

This command creates a virtual environment named myenv using Python 3.7 located at /usr/bin/python3.7. Replace myenv with your desired environment name.

Step 3: Activate the Virtual Environment

Activate the virtual environment to switch to Python 3.7 within the environment:

On Linux or macOS:

bash

source myenv/bin/activate

On Windows:

bash

.\myenv\Scripts\activate

After activation, your shell prompt should indicate that the virtual environment is active. Step 4: Verify the Python Version in the Virtual Environment

To confirm that the virtual environment is using Python 3.7, run:

bash

python --version

You should see output indicating that Python 3.7 is being used:

Python 3.7.x

Step 5: Deactivate the Virtual Environment When Done

When you are finished, deactivate the virtual environment to return to the base Python 3.10:

bash

deactivate

MySQL commands to create a user

  1. CREATE USER 'FUfB6cwSsGDbQpmA7Qs8zQJxU3HpwCdnjT'@'localhost' IDENTIFIED BY 'RAcifrTM2V75ipy5MeLYaDU3UNcUXtrit933TGM5o7Yj2fs8XdP5';
  2. GRANT ALL PRIVILEGES ON rm_%_db.* TO 'FUfB6cwSsGDbQpmA7Qs8zQJxU3HpwCdnjT'@'localhost' WITH GRANT OPTION;

Modify config.ini

[MYSQL]
USERNAME = FUfB6cwSsGDbQpmA7Qs8zQJxU3HpwCdnjT
PASSWORD = RAcifrTM2V75ipy5MeLYaDU3UNcUXtrit933TGM5o7Yj2fs8XdP5
HOST = localhost
DATABASE_PREFIX = rm