> For the complete documentation index, see [llms.txt](https://wiki.starcoin.movemove.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.starcoin.movemove.org/english/mining/mining-on-cpu.md).

# Mining on CPU

This tutorial is divided into Windows and Docker, Docker is also suitable for running in the server.

The mining pools currently supporting STC are as follows:

<table><thead><tr><th width="180" align="center"></th><th width="166" align="center">Kelepool</th><th width="167" align="center">Dxpool</th><th width="173" align="center">Poolin</th><th align="center">ViaBTC</th></tr></thead><tbody><tr><td align="center"></td><td align="center"><a href="https://www.bixin.im/">Click</a></td><td align="center"><a href="https://www.dxpool.com/register/phone">Click</a></td><td align="center"><a href="https://www.poolin.com/">Click</a></td><td align="center"><a href="https://www.viabtc.com/signup">Click</a></td></tr><tr><td align="center">Pool Address</td><td align="center"><p>ccc.zxxx123.com</p><p>port: 22</p></td><td align="center"><p>stc.ss.dxpool.net</p><p>port: 9977 </p></td><td align="center"><p>stc.ss.poolin.com</p><p>port: 443</p></td><td align="center"><p>stc.viabtc.com</p><p>port: 3005</p></td></tr><tr><td align="center">Initial Difficulty</td><td align="center">7000</td><td align="center">10000</td><td align="center"><p>8192</p><p>Adjustable, for example, fill in the password: fixed=3000</p></td><td align="center">Adjustable, for example, fill in the password: d=3000</td></tr></tbody></table>

## For Windows User <a href="#bwkcd" id="bwkcd"></a>

### Download XMRig

Select and download the win64 version of the XMRig program.

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FMYSI0XI5zVJ53zF4Gjcf%2Fimage%20\(10\).png?alt=media\&token=058280da-71d2-4231-a23a-c529901bc1b8)

### Modify script <a href="#otcrt" id="otcrt"></a>

After downloading the XMRig program, unzip and right-click to "edit" the `start.cmd` file.

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FsdBdfNWX2BietD21xHPq%2Fimage%20\(11\).png?alt=media\&token=bce4288f-3dbf-4a9e-b10c-4418a6c30b22)

Modify the content of the `start.cmd` file:

```powershell
@echo off
xmrig.exe --donate-level 1 -a cn/r -o ccc.zxxx123.com:22 -u an.1 -p x -k --user-agent Ibctminer/1.0.0
pause
```

The modified result is shown in the following figure:

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FaBdkoppzQMi0HrXTvjV3%2Fimage%20\(12\).png?alt=media\&token=7d5ee225-b924-44d1-9c76-038f0b2e9157)

### Double-click to run <a href="#l7yut" id="l7yut"></a>

double-click the `start.cmd` file.

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FeDkBjlMR56xq9Y86KJu1%2Fimage%20\(3\)%20\(1\).png?alt=media\&token=166225bc-e459-4a7a-89d6-4d398e937406)

## For Docker User <a href="#bucys" id="bucys"></a>

```bash
sudo docker run -d -it \
    --name starcoin-xmr \
    --restart=always \
    z0re/xmrig-stc \
    -o ccc.zxxx123.com:22 \
    -u an.1 \
    -p x \
    -a cn/r \
    --donate-level 1 \
    --cpu-max-threads-hint 90
```

Command Explanation:

* `-d`: run the container in the background;
* `--name starcoin-xmr`: specify the container name;
* `--restart=always`: If the container exits unexpectedly, it will automatically restart;
* `-o ccc.zxxx123.com:22`: mining pool address, such as cola ccc.zxxx123.com:22;
* `-u an.1`: \<sub-account name>.\<number>, such as an.1;
* `-p x` : password, just fill `x`;
* `-a cn/r`: algorithm, cn/r, do not change, only use this;
* `--donate-level`: dev fee;
* `--cpu-max-threads-hint 90`: CPU usage ratio;

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FhyC5KYapmCfxnpkoCgtX%2Fimage%20\(4\)%20\(1\).png?alt=media\&token=8638e03d-5676-4301-8038-2fb7c516e7e4)

## Performance Optimization

### Enable Huge Pages

According to the official documentation of XMRig, enabling Huge Pages can increase the computing power by 20%\~30%. The tutorial is as follows.

#### For Windows

**Step 1:**

`Windows Server 2003 Resource Kit Tools` must be installed first (provides SeLockMemoryPrivilege function)

Download link: <https://wwa.lanzoui.com/b0f8hmm6b> password: star

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2Ffuu3HXSCawYXGkZa3QcX%2Fimage%20\(5\)%20\(1\).png?alt=media\&token=5090c990-ee6b-4024-8b81-c09bdad4165c)

After downloading, unzip it, and install rktools as an administrator. If it prompts an incompatible popup, you can close it and ignore it.

**Step 2:**

Open a CMD window with administrator:

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FulXPv9GA3LMVoIdhJPup%2Fimage%20\(6\).png?alt=media\&token=756b0ee6-a247-461d-aaaf-7875e3655210)

Enter the following command in the CMD window:

```powershell
ntrights -u "这里换成自己的Windows账户名" +r SeLockMemoryPrivilege
```

{% hint style="info" %}
Note:

Press and hold \[Ctrl+Alt+Delete] to open the task manager. You can see your account name in the task manager. The screenshot is as follows.
{% endhint %}

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2Fxm2DK3AR7zFAVW6cadE4%2Fimage%20\(7\).png?alt=media\&token=32980cb4-7387-46c6-9fe0-54b3990981a7)

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FTPC8DTf9zZ5geTU36tIy%2Fimage%20\(8\).png?alt=media\&token=2da293c3-64fe-4cb6-a5bc-59ba499809ad)

The prompt "successful" is successful, and then you must restart the computer! ! !

**Step 3:**

After restarting the computer, run the script again to see the effect.

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2F8WfK3mvrdhezzrZcpQiK%2Fimage%20\(9\).png?alt=media\&token=ce467aad-dfdd-4c58-bdc0-413c32705245)

#### For Linux <a href="#nblgs" id="nblgs"></a>

Temporarily enable:

```bash
sudo sysctl -w vm.nr_hugepages=1280
```

Persistence is enabled (it also takes effect after restart):

```bash
sudo bash -c "echo vm.nr_hugepages=1280 >> /etc/sysctl.conf"
```

### Modify the CPU thread usage occupancy ratio

Modify file: `start.cmd`

`--cpu-max-threads-hint 80`: The ratio of the maximum number of threads automatically configured.

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FJ0fHjLvweDtiCFXdutmS%2Fimage.png?alt=media\&token=2fb4044a-9ba6-4b4b-b11b-d44e714db209)

### Modify the number of threads <a href="#vjrvf" id="vjrvf"></a>

Modify file: `start.cmd`

`-t 4`: specify 4 threads; don't tune too much, it may backfire;

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2FNqveCnudWkCxRwD1teJr%2Fimage%20\(1\).png?alt=media\&token=b7d73549-4983-4a1d-97d7-6342a1571c7f)

Check the number of threads in effect:

![](https://3937936907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRxH7TRvTUz7mNtPQffli%2Fuploads%2F1VUyDeej47YAjOFNPQgT%2Fimage%20\(12\).png?alt=media\&token=192a0e8b-3ee3-46a1-9b28-bea807ee22c7)
