Cover photo

Run POP Miner Hemi

Update

มีคนทำ script ใช้ให้ติดตั้งได้ง่ายขึ้น ใช้แค่คำสั่งเดียว ง่ายขึ้นเยอะ

[ -f "hemixyz.sh" ] && rm hemixyz.sh; wget -q https://raw.githubusercontent.com/zunxbt/pop-mining/main/hemixyz.sh && chmod +x hemixyz.sh && ./hemixyz.sh

โดยพอรันจะมีให้กรอก2 อย่าง เลือก wallet กับ fee

post image

กรณีมี Wallet อยู่แล้วให้เลือก 2 ถ้าไม่มีให้เลือก 1 ถ้าเลือก 2 จะมีให้เรากรอก private key

หลังจากนั้นจะมีให้กรอก

Enter static fee (numerical only, recommended: 100-200):

ให้เลือกค่า fee ระหว่าง 100-200 ถ้าเอาตามที่ผมใช้ก็คือ 100

เป็นอันเสร็จ ถ้าเราจะดู log ให้ใช้คำสั่ง

sudo journalctl -u hemi.service -f -n 50

ข้างล่างลืมไปได้เลย



วันนี้มาสอนรัน POP Miner ของโปรเจค Hemi บน VPS

จริงเราไม่จำเป็นต้องรันบน VPS ก็ได้ เราสามารถรันผ่าน URL

https://pop-miner.hemi.xyz/

แต่มีเงื่อนไขว่าต้องเปิดหน้า URL ไว้ตลอดเวลาห้ามผิด ถ้าปิดตัว miner จะหยุดทำงาน เหมาะสำหรับคนไม่อยากเช่า VPS แต่วันนี้จะมีสอนวิธีรันบน VPS

1. ติดตั้ง Pop Miner CLI

  • login เข้า VPS ให้เรียบร้อย แล้วทำการ Download Pop Miner CLI ด้วยคำสั่ง

wget https://github.com/hemilabs/heminetwork/releases/download/v0.4.3/heminetwork_v0.4.3_linux_amd64.tar.gz
  • ทำการแตกไฟล์ที่ Download ด้วยคำสั่ง

tar xvf heminetwork_v0.4.3_linux_amd64.tar.gz
  • เข้าไปใน Folder ที่เราแตกไฟล์ด้วยคำสั่ง

cd heminetwork_v0.4.3_linux_amd64

2. สร้าง Wallet

(หากใครมี Wallet อยู่แล้วหรือเคยสร้างจาก เว็บ pop-miner.hemi.xyz สามารถข้ามขั้นตอนนี้ไปได้เลย)

  • สร้าง Wallet ด้วยคำสั่ง

./keygen -secp256k1 -json -net="testnet" > ~/popm-address.json
  • ดูข้อมูล Wallet ที่เราสร้างด้วยคำสั่ง

cat ~/popm-address.json

หน้าตาจะได้แบบนี้

{"ethereum_address": "0x51xxxxxxxxxxxxxxxxxxxxxxxxxxA62","network": "testnet","private_key": "0aecxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx38a","public_key": "034a65xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf88e","pubkey_hash": "mxqxxxxxxxxxxxxxxxxxxxxxxxxqoMj"}

  • บันทึกข้อมูล Private_key กับ pubkey_hash เก็บไว้

3. สร้าง Environment ไฟล์

  • สร้าง Environment file ด้วยคำสั่ง

    sudo nano /etc/popmd_env
    
  • Copy code นี้ไปใส่

    POPM_BTC_PRIVKEY=private_keyPOPM_STATIC_FEE=50POPM_BFG_URL=wss://testnet.rpc.hemi.network/v1/ws/public

  • ให้แก้ private_key เป็น private_key ของเรา ใครที่เคยรันผ่าน pop-miner.hemi.xyz แล้วจะย้ายมาบน VPS สามารถเอา private key ของ pop-miner.hemi.xyz มาใส่ได้

  • กด Ctrl + X แล้วกด Y เพื่อ Save และ Exit

4. ขอ Faucet

  • เข้าไปที่ Discord ของ Hemi ห้อง #Faucet

https://discord.com/invite/hemixyz

  • พืมพ์คำสั่ง /tbtc-faucet ตามด้วยเลข pubkey_hash ตอนสร้างกระเป๋า

post image

ถ้าขึ้นแบบในภาพคือขอสำเร็จ

post image

แต่ถ้าขึ้นแบบนี้คือขอไม่สำเร็จ เนื่องจากเหรียญหมดต้องรอ Dev เติมเหรียญก่อน

post image

5. สร้าง Service และ Run miner

  • สร้าง service file ด้วยคำสั่ง

    sudo tee /etc/systemd/system/popmd.service > /dev/null << EOF[Unit]Description=PoPM ServiceAfter=network.target[Service]EnvironmentFile=/etc/popmd_envWorkingDirectory=/home//heminetwork_v0.4.3_linux_amd64ExecStart=/home//heminetwork_v0.4.3_linux_amd64/popmdRestart=alwaysRestartSec=5[Install]WantedBy=multi-user.targetEOF Reload systemd new service ด้วยคำสั่ง sudo systemctl daemon-reload Enable the service ด้วยคำสั่ง sudo systemctl enable popmd.service Start the servicesudo systemctl ด้วยคำสั่ง sudo start popmd.service Check the status service ด้วยคำสั่ง sudo systemctl status popmd.service จะได้ประมาณในภาพ

    post image
    • เช็ค Log ไฟล์ ด้วยคำสั่ง

      sudo journalctl -u popmd.service -f
      

      ไฟล์ log จะมีหน้าตาประมาณนี้ จะมี error บ้าง

    post image
    • ถ้ารันไปสักพักให้สังเกตุถ้ามีข้อความนี้แสดงว่า OK

      popm popm.go:438 Successfully broadcast PoP transaction to Bitcoin testnet3 with TX hash

    • หากต้องการจะหยุด service ใช้คำสั่ง

      sudo stop popmd.service
      
    • เช็คว่า Pop Miner ของเราทำงานได้ถูกต้องไหมแบบ Onchain เข้าไปที่ mempool แล้วเอา address ของเราไปกรอก

    https://mempool.space/

    จะมีโชว์ยอด Balance เหรียญ tbtc ที่เหลืออยู่ ถ้าจำนวนเหรียญลดลงแล้วมี transection เกิดขึ้นแสดงว่า OK

    post image

    วิธีทั้งหมดอ้างอิงมาจาก

    https://medium.com/@huicomm/how-i-run-pop-miner-in-hemi-testnet-2327c45ff3ca

    และ Guide ของ Official ที่

    https://docs.hemi.xyz/how-to-tutorials/tutorials/setup-part-1