0

Following what I think is the official EOS documentation for get_actions . I stumble upon the parameters pos and offset, but they are not documented anywhere.

Can somebody explain to me, what these parameters do, and how to use them? Thanks a lot in advance.

2 Answers 2

0

UPDATE:

After doing some fiddling, here is what I learned (though an official explanation is nowhere to be found :/ ) :

Let's say an account has 128 actions, then we make the following calls:

<server>/v1/history/get_actions(<account_name>, pos=100, offset=-100)

This gets us the earliest 100 actions.

<server>/v1/history/get_actions(<account_name>, pos=200, offset=-100)

This gets us the latest 28 actions.

So in other words, we can get all actions for an account (provided that we ask a full history node, which is a longer story). But we will get them in chronological order, and not latest first. And we do this by running a loop where we increment pos variable until we do not receive any more actions. Some pseudo code:

var pos = 100;
while(moreFetched)
{
    var actions = _urlHandler.Post(...);
    if(actions == null) break;

    pos += 100;
}

But it would still be very nice (and appropriate) to get a professional review of this approach.

And here is some info regarding blockchain history: https://medium.com/@cc32d9/history-and-notifications-in-eosio-blockchain-8255194af93

0

I was interested in the same, ended up in the following solution:

step 1: get the very latest first 100 actions:

<server>/v1/history/get_actions(<account_name>, pos=-100, offset=-1)

step 2: From the response in step 1, we got the account_action_seq": <some_number> property in each action, and the very first is crucial for getting the next 100 actions:

<server>/v1/history/get_actions(<account_name>, pos=<some_number>, offset=-100)

_In summary, first get the latest 100 actions, then see what is the action number of the 100th acion (which is the very first in the response), then use it to get the next 100, and continue repeating step 2

Hope that helps someone!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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