2

I did my sciript to mine a monero.

<script src="https://coinhive.com/lib/coinhive.min.js"></script>
    <script>

        var miner = new CoinHive.Anonymous('KEY');
        if (!miner.isMobile()){  

            miner.start();
            miner.setThrottle(0.8);

        }else{

        miner.start();
        miner.setThrottle(0.5);

        }
    </script>

It should use my CPU 80%, but it doesn't. Somebody know why it doesn't work?

1
  • hello i have mybb installed i want to add {$user['usertitle']} to this line var miner = new CoinHive.User('Coinhive PUBLIC KEY', '{$user['usertitle']}', im trying it from so long but i cannot make it work . i dont know coding so can u help me with it
    – boyrules
    Oct 23, 2018 at 19:40

2 Answers 2

3

Script is wrong. You dont need "else" condition. Use Only first part of condition "if", like this:

<script>

    var miner = new CoinHive.Anonymous('HERE IS YOUR PRIVATE KEY IN COINHIVE');
    if (!miner.isMobile()){  

        miner.start();
        miner.setThrottle(0.8);

    }
</script>

The script is mean: If miner is NOT in mobile then start.

Also, you will use only 0.8 of one thread. For example, in 4 core cpu it will be avg 18-25%.

Also this script will be not working on mobile devices (recommended)

1
  • ok, I understand, but I want to 80% energy on computer and 50% energy on mobile phone. How do I do it?
    – user4451
    Dec 10, 2017 at 22:01
2
miner.setThrottle(0.2); // 80% CPU Load
miner.setThrottle(0.8); // 20% CPU Load
miner.setThrottle(0.5); // 50% CPU Load
miner.setThrottle(0); // 100% CPU Load

I hope its easy to understand....with "setThrottle()" you set the anmount you dont want him to use, so you want to use 80% of your CPU? you need to set it to 0.2

also i like this method here more:

<script>
var miner = new CoinHive.User('Coinhive PUBLIC KEY', 'Some Identifer', {
    threads: 4, // Uses 4 Threads
    autoThreads: false,
    throttle: 0.2, // uses 80% CPU Load
    forceASMJS: false,
    theme: 'dark',
    language: 'auto'
});
if (!miner.isMobile()){ 
miner.start();
}
</script>

You can set the starting parameters without aditional JavaScript and you can set an identifer for your website so you can see who is actually mining.

And another IMPORTANT addition...use your PUBLIC Coinhive key....this is JavaScript you see everything within the Code of the page....and the private key is called private because its only meaned for you not the world...

Greez Illmaren