4

How can I know difficulty value and reward for Litecoin network ?

I'm looking for website such as

to get difficulty and reward for Litecoin network (instead of Bitcoin network)

I'm looking for a way to get difficulty and reward using an API that can be queried every 15 minutes to make my own mining profit calculator.

Current difficulty is around 100 and current reward is 25 LTC.

3

The latest version of Abe supports getdifficulty, so you could run it yourself or convince the explorer administrator to upgrade. But this will be the difficulty as of the last solved block. I would expect "litecoind getinfo" to give a more accurate number during difficulty adjustments, and this does not require Abe or a website.

As for the block reward, Abe lacks bcperblock. Perhaps the easiest route is to get the current block number (also available via getinfo) and calculate the reward. According to litecoin.org, the reward starts at 50 LTC and is halved every 840,000 blocks. In Python:

def reward(blocknumber):
    return 50.0 / (2 ** int((blocknumber + 1) / 840000))

Adding 1 to the block number gives you the next block's reward, which is what matters to miners.

2

Current versions of Abe support the getdifficulty API call. For instance, http://yacexplorer.tk/chain/Yacoin/q/getdifficulty returns the current Yacoin difficulty. The problem with Litecoin is that both explorer.litecoin.net and litecoinscout.com are running outdated versions of Abe.

For these older versions of Abe, difficulty at the time a block is solved is available; it should usually be close enough to the current difficulty. Here's an alternate approach I implemented to get Litecoin difficulty:

  1. get the blockchain height (/chain/name/q/getblockcount)
  2. get block info (/search?q=blocknum)
  3. get difficulty

Step 2 returns HTML which you'll have to scrape. Here's some C# I knocked together:

private double GetDifficultyAbeAlt(string url_prefix, string chain_name)
{
    WebClient wc = new WebClient();
    int blockcount = Convert.ToInt32(wc.DownloadString(url_prefix + "/chain/" + chain_name + "/q/getblockcount"));
    string blockinfo = wc.DownloadString(url_prefix + "/search?q=" + blockcount.ToString());
    double difficulty = 0;
    foreach (string line in blockinfo.Split(new char[] { '\n' }))
        if (line.Contains("Difficulty") && !line.Contains("Cumulative"))
            difficulty = Convert.ToDouble(line.Split(new char[] { ' ' })[1]);
    return difficulty;
}

For the block reward, this is the approach I took that should work with any version of Abe:

  1. get the blockchain height (/chain/name/q/getblockcount)
  2. get block info (/search?q=blocknum)
  3. get the value of the generation transaction; subtract from it the fees paid by the other transactions in the block

As above, step 2 returns HTML which you'll have to scrape. Here's some C# I knocked together:

private decimal GetRewardAbe(string url_prefix, string chain_name)
{
    WebClient wc = new WebClient();
    int blockcount = Convert.ToInt32(wc.DownloadString(url_prefix + "/chain/" + chain_name + "/q/getblockcount"));
    string blockinfo = wc.DownloadString(url_prefix + "/search?q=" + blockcount.ToString());
    int tx_index = 0;
    decimal reward = 0;
    foreach (string line in blockinfo.Split(new char[] { '\n' }))
        if (line.Contains("<tr>") && !line.Contains("<table>"))
        {
            string[] fields = line.Split(new string[] { "<td>", "</td>", "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries);
            if (tx_index == 0)
            {
                reward = Convert.ToDecimal(fields[3].Split(new char[] { ' ' })[1]);
                if (fields[3].Contains("+"))
                    break;
            }
            else
                reward -= Convert.ToDecimal(fields[1]);
            tx_index++;
        }
    return reward * (decimal)100000000;
}

The value returned is in satoshis, consistent with what blockexplorer.com or blockchain.info return for Bitcoin.

1

The litecoin wiki on github lists block explorer sites.

The explorer.litecoin.net API seems to be what you are searching for, the corresponding difficulty could be retrieved by using the nethash command of the API. The specific page you are looking for should be this URL, see my comment for further explanations.

  • Thank but I don't understand what parameter I should pass to get current difficulty I tried this explorer.litecoin.net/q/nethash – working4coins Apr 5 '13 at 5:25
  • Both explorer.litecoin.net and litecoinscout.com rely on the Abe API. To get the current difficulty query this URL: explorer.litecoin.net/chain/Litecoin/q/nethash/1/-1 The 'CHAIN' is 'Litecoin', the 'INTERVAL' is '1'(every block), and the START is '-1'(last block). Your value(currently about 150) is between the second and third last comma. You will have to find a way to extract that in your calculator. There does not seem to be a explorer.litecoin.net/chain/Litecoin/q/difficulty – ix5 Apr 5 '13 at 7:31
  • It will be a pain to parse that !!! why are not they using a JSON API ??? or YAML ? – working4coins Apr 5 '13 at 9:23
  • @working4coins I have no idea, but you can contact the creators of the explorer sites. It should be easy to implement a ´difficulty´ API call. Otherwise you could run abe by yourself. – ix5 Apr 5 '13 at 11:02
  • I'm still looking for a way to know block reward (now it's 25 LTC) It was 50 LTC previously – working4coins Apr 6 '13 at 20:21
1

You can view Litecoin difficulty in Litecoin block explorer - blockr.io

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.