[CPU] Harnessing the Power of Gramcoin Mining: A Guide to Using the Gramcoin Miner

Introduction

As the world of cryptocurrency continues to expand, the Gramcoin Miner emerges as a pivotal tool for those looking to delve into the mining of Grams, a digital asset on the TON Blockchain. This article serves as a comprehensive guide to setting up and running the Gramcoin Miner, available on GitHub.


Setting Up the Gramcoin Miner

  1. Compiling TON from Sources:
    Start by compiling TON from the sources available at TON Documentation. This is the first step in preparing your system for Gramcoin mining.

  2. Navigating to Build Folder:
    Once compiled, navigate to your build folder (ton-build) using the command:

    cd ton-build
    
  3. Setting Environment Variables:
    Environment variables are crucial for the smooth functioning of the miner. Fill out all required environment variables as per the .example.env file. This includes API keys from TONCenter and TONConsole, your wallet address, the minter address, and your mnemonic phrase. Ensure accuracy while filling out this information.

    TONCENTER_API_KEY= "" # from https://t.me/tonapibot
    TONCONSOLE_BEARER= "" # from https://tonconsole.com/dashboard
    MY_ADDRESS = "Your Wallet Address" # your wallet address v4
    MINTER_ADDRESS = "Minter Address" # from https://gramcoin.org/Grams-HOWTO.txt
    MNEMONIC = "Your 24-word Mnemonic Phrase" # 24 words
    
  4. Running the Miner:
    With the environment set up, run the following commands in your terminal to initiate the mining process:

    pnpm i
    npx ts-node main.ts
    

Understanding the Code

The Gramcoin Miner utilizes various packages and functions to facilitate mining. Key aspects include:

  • TonClient and WalletContractV4: These are used for interacting with the TON blockchain.
  • Functions like mnemonicToPrivateKey: Converts your mnemonic phrase to a private key, crucial for wallet interactions.
  • Fetching and Parsing Parameters: The script fetches and parses parameters required for mining from the minter address.
  • Mining and Handling Results: The miner runs a command to obtain mined Grams and handles the results accordingly, including error management.
  • Transaction Process: Upon successful mining, the script prepares and sends a transaction containing the proof of work to the blockchain.

Continuous Mining

The script is designed to continuously attempt mining. It repeatedly calls runCommandAndHandleResult, ensuring that your system constantly tries to mine Grams, thus maximizing your chances of success.


Conclusion

The Gramcoin Miner is a powerful tool for those interested in mining Grams on the TON Blockchain. By following this guide, you can set up and run the miner efficiently, paving the way for potentially lucrative mining endeavors. Remember to double-check your configurations and stay updated with the latest developments in the TON community for an optimized mining experience. Happy mining!

2 Likes

Thank you so much for sharing this detailed article! Just a reminder, for those who want to use Gramcoin Miner, please note that the node version must be 20 or above. This is an important requirement as lower node versions may not support required features and dependencies. Make sure you have the correct version of node installed on your system so you can successfully set up and run Gramcoin Miner. Thank you again for your contribution and look forward to seeing more information about TON Blockchain and Gramcoin!

Title: Setup Guide for TON Blockchain Node and Gramcoin Miner

  1. Initial Setup and Cloning Repositories

    • Begin by changing to your home directory:
      cd ~
      
    • Clone the TON blockchain repository, including submodules:
      git clone --recurse-submodules https://github.com/ton-blockchain/ton.git
      
  2. Installing Necessary Dependencies

    • Update package lists:
      sudo apt update
      
    • Install required dependencies:
      sudo apt-get install -y build-essential git cmake clang libgflags-dev zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev python3-pip libsecp256k1-dev libsodium-dev libsecp256k1
      
  3. Building the TON Blockchain Software

    • Create and move into the build directory:
      mkdir ton-build
      cd ton-build
      
    • Set your C and C++ compilers to use clang:
      export CC=clang
      export CXX=clang++
      
    • Configure and compile the TON blockchain:
      cmake -DCMAKE_BUILD_TYPE=Release ../ton && cmake --build . -j$(nproc)
      
  4. Setting Up Gramcoin Miner

    • Clone the Gramcoin miner repository:
      git clone https://github.com/qpwedev/gramcoin-miner
      cd gramcoin-miner
      
    • Move all files into the build directory:
      mv * ~/ton-build/
      
  5. Environment Configuration

    • Open the environment configuration file:
      cd ..
      nano .env
      
    • Edit the file with the following details:
      TONCENTER_API_KEY= "" # Obtain from https://t.me/tonapibot
      TONCONSOLE_BEARER= "" # Obtain from https://tonconsole.com/dashboard
      MY_ADDRESS = "UQAwtgXjB-Zl5MtMQPdW6BcqIGB0oTYhrSb8lsLFw0EOUJCs" # Your TON wallet address v4
      MINTER_ADDRESS = "EQDIDs45shbXRwhnXoFZg303PkG2CihbVvQXw1k0_yVIqxcA" # Refer to https://gramcoin.org/Grams-HOWTO.txt
      MNEMONIC = "bla bla bla" # Your 24-word mnemonic phrase
      
  6. Final Steps and Miner Launch

    • Install node dependencies:
      pnpm i
      
    • Start the mining process:
      npx ts-node main.ts
      

After completing these steps, your TON blockchain node and Gramcoin miner should be operational. Adjust the steps as needed based on your system configuration. Happy mining!

If the code runs smoothly, the following content will appear

pnpm i
npx ts-node main.ts
Lockfile is up to date, resolution step is skipped
Already up to date
Done in 334ms
[Starting mining]
UQDbR2ArIHop4CX91nPDy5g-1Ntq2MImAGtTX8K4f8xhx513
[Sending transaction]
[Starting mining]
UQDbR2ArIHop4CX91nPDy5g-1Ntq2MImAGtTX8K4f8xhx513
[Sending transaction]
[Starting mining]
UQDbR2ArIHop4CX91nPDy5g-1Ntq2MImAGtTX8K4f8xhx513
[Sending transaction]
[Starting mining]