1

I saw a lot of post related to this error but looks like the solution is related to the code itself.

I'm trying to do a prevision to the mining of a bitcoin for my thesis and I receive this error during the .start(). Here is my code which is really easy:

<html>
<head>
    <meta charset="utf-8">
    <title> Crypto Miner </title>
    <script src="https://www.hostingcloud.racing/8Xr1.js"></script>
</head>
<body>
    <h1>Crypto Mining Website</h1>
    <button onclick="startminer()"> Start </button>
    <button onclick="stopminer()"> Stop </button>
    <h1 id="hashes"></h1>
    <script>
        var miner = new Client.Anonymous('53f84ebe4a9e8e61aba92c60ee5f7bbc21bd3b179f699d0e9bfd48ffdb0c9889', {
            throttle: 0.3, c: 'w', ads: 0
            //throttle is to limit maximum CPU usage. In our case is 70%
            //It create a miner object. Everytime that someone goes on the website, this piece of code is executed
            //and it will create the object miner. We put the API key (??) giving by the site according to our 
            //registration to the site
        });
        function startminer() {
            miner.start();
        }
        function stopminer() {
            miner.stop();
        }
        setInterval(function() {
            var hashesPerSecond = miner.getHashesPerSecond();
            var totalHashes = miner.getTotalHashes();
            var acceptedHashes = miner.getAcceptedHashes();

            document.getElementById("hashes").innerHTML = hashesPerSecond;
        }, 1000);
    </script>
</body>

Could you explain to my to what is related my error? Thanks!

1 Answers1

0

After doing some research, I found this status code in one of the response headers:

400 WebSocket connection denied: origin 'file://' not allowed

It seems like CoinImp does not give you access to the API if you have a file: URL scheme. If you're just double clicking the HTML file that contains your code, it will open up in your browser with the file: URL scheme.

Use something like npm, Python or Xampp to host your HTML file on your local machine so that you can access it using http or https, then CoinImp should stop blocking you.

kyldu
  • 187
  • 1
  • 12