# Run POP Miner Hemi

By [ic36006](https://paragraph.com/@ox97acc5) · 2024-09-21

---

**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

![](https://storage.googleapis.com/papyrus_images/080b2667c4bc46c5c63a2ad686d39f47e2018519ec23be99778e695f188b17fb.png)

กรณีมี 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/](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](https://discord.com/invite/hemixyz)

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

![](https://storage.googleapis.com/papyrus_images/72812fda7b10fddfd0b4ce8fc56c0820b21ba885ccd3c7d39c2e78d8ba8cc09a.png)

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

![](https://storage.googleapis.com/papyrus_images/4c39e505b6a11f77d4f9a7ec285cc55cbaceaa245782bba44bdd0611d7decb03.png)

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

![](https://storage.googleapis.com/papyrus_images/e6d2ea31956439ad7dbf9f7c5d86397d9e3a24c3cd68b5a1f494217fa31bac5f.png)

**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 จะได้ประมาณในภาพ
    
    ![](https://storage.googleapis.com/papyrus_images/27a3071a7a0421ba275ede3f5449ac451fab07eafc52dd537ea5bfc10948f5e9.webp)
    
    *   เช็ค Log ไฟล์ ด้วยคำสั่ง
        
            sudo journalctl -u popmd.service -f
            
        
        ไฟล์ log จะมีหน้าตาประมาณนี้ จะมี error บ้าง
        
    
    ![](https://storage.googleapis.com/papyrus_images/017530aebd55db6ffa68a33812e719e22a137ee12fab303cc5b37a5d5326abce.png)
    
    *   ถ้ารันไปสักพักให้สังเกตุถ้ามีข้อความนี้แสดงว่า 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/](https://mempool.space/)
    
    จะมีโชว์ยอด Balance เหรียญ tbtc ที่เหลืออยู่ ถ้าจำนวนเหรียญลดลงแล้วมี transection เกิดขึ้นแสดงว่า OK
    
    ![](https://storage.googleapis.com/papyrus_images/ab65b5a75d4596a8a0f21b328d9c22f76d0bccdbc0d6e92bfd366aacfe03f50d.png)
    
    วิธีทั้งหมดอ้างอิงมาจาก
    
    [https://medium.com/@huicomm/how-i-run-pop-miner-in-hemi-testnet-2327c45ff3ca](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](https://docs.hemi.xyz/how-to-tutorials/tutorials/setup-part-1)

---

*Originally published on [ic36006](https://paragraph.com/@ox97acc5/run-pop-miner-hemi)*
