7

So inflation gets run once a week according to the docs.

My question is how can you tell when the last inflation was run, and subsequently when the next inflation is eligible to be generated.

Also, according to the docs:

The distribution of new lumens is limited to once a week. Inflation is run in response to an inflation operation that anyone can submit to the network.

My guess is that someone already has a script/service that submits the inflation operation to the network every week, so the day/time in the foreseeable future will basically stay consistent? What is the day/time that this occurs/has occurred?

Are lumens distributed immediately after this inflation operation is sent (like, within seconds)?

I've edited this comment to ask questions specifically about determining when the last inflation was generated/distributed, as the existing question What day of the week does the Stellar network pay out inflation? does not explicitly state a day.

  • Yes, although the accepted answer doesn't explicitly answer the question. I'd like to know much more about historical inflation dates and when the pool actually gets around to calculating as well as when it is actually distributed. – Zach Jan 19 '18 at 17:57
  • Please add that additional information and why the other answer doesn't help you into the question via edit. – Helmar Jan 19 '18 at 19:18
  • @Helmar I've re-worked the question which will help me provide a better answer to the related question (marked as duplicate). I'd be happy to better answer that one when I can find answers to this one. – Zach Jan 19 '18 at 23:37
6

Given the current set of tools in our ecosystem (and lack of analytical systems) the easiest way to programatically determine when the last inflation was distributed is using Horizon server. You can do it two ways:

  • If you want to be notified when inflation is executed you can stream all the operations and call a function when operation type is equal to inflation.
  • If you want to get the last time when inflation was run, you can iterate pages of operations from the newest operations and stop when you achieve operation with a type equal to inflation.

Below you can find code snippets in Node.js for each of the methods above.

Notify next inflation

let StellarSdk = require('stellar-sdk');
let horizon = new StellarSdk.Server("https://horizon.stellar.org");

let stopStreaming = horizon.operations().cursor("now").stream({
  onmessage: operation => {
    if (operation.type == "inflation") {
      console.log(`Last inflation distributed at ${operation.created_at} (${operation.id})`);
      stopStreaming();
    } else {
      console.log(`Not inflation ${operation.id}`);
    }
  }
});

Last time inflation distributed

let StellarSdk = require('stellar-sdk');
let horizon = new StellarSdk.Server("https://horizon.stellar.org");

function processResults(results) {
  for (let operation of results.records) {
    if (operation.type == "inflation") {
      console.log(`Last inflation distributed at ${operation.created_at} (${operation.id})`);
      return;
    } else {
      console.log(`Not inflation ${operation.id}`);
    }
  }

  setImmediate(() => results.next().then(processResults));
}

horizon.operations().order("desc").limit(200).call().then(processResults);

Hopefully we will see analytical tools (or block explorers will start displaying this data) in a near future that will give answers to similar questions without writing a code.

  • Regarding the 1st snippet. Anyone can submit the inflation operation, so will all requests trigger that callback or only the successful one? Meaning if I submitted it now (too early to submit) would it still trigger stopStreaming()? – Zach Jan 24 '18 at 22:38
  • 1
    Horizon ingests successful transactions only. So no, if you submit inflation operation when it's not time for inflation to be distributed it won't trigger stopStreaming(). – Bartek Nowotarski Jan 24 '18 at 23:56
  • 1
    This is great, for those curious, at time of posting the last inflation transaction was: stellar.expert/explorer/tx/… . And for those extra curious, all inflation operations in recent history have been submitted by that same wallet. – Zach Jan 25 '18 at 2:32

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.