How can I use Archival node to access historical data for Livepeer

Hello,

I have subscription to Archival node data. I want to use that to access data for Livepeer say 6 months ago. How can I go about doing that? (Very new to all this stuff, please explain like I’m five!) . Thank you!!

Hi thanks for signing up! Could you provide more information as to what Livepeer data you are trying to access? We are happy to help you understand how to best access that!

Hi Mike!

So there is a delegator who is delegating to a transcoder. I need to query how much reward that delegator has made up until a specific date (better is total balance of reward+delegated amount). I was told I could do that by querying an archival node that is “frozen” at the relevant block height.

I’m looking at the SDK documentation here https://github.com/livepeer/livepeerjs/tree/master/packages/sdk#gettokenbalance and seeing maybe “getDelegator” or “getTokenBalance” could be useful.

Thanks for the help!!

For that you will want to use the eth_call method, documented here, https://infura.io/docs/ethereum/json-rpc/eth_call

to: this would be the Livepeer contract
data: this is where you would define the method signature for the Livepeer contract methods you listed and the block height

Let us know if this help!

Definitely helps!

But I’m not sure how to create the data hash… do you think you might be able to give some more guidance? I found the contract and the method (getDelegator) https://etherscan.io/address/0xcbaa6ea4886b535fc7abace3f3985ed03b3b80a0#readContract

Also, how do I make sure that I am using an archival node stopped at that block height, instead of using say a current node to query that block, if that makes sense? Or is that kind of implied when you pass in the block height?

Thanks so much!!

For interacting with this specific smart contract I’m not familiar with Livepeer’s interface, the best source of information on that is their forum: https://forum.livepeer.org

how do I make sure that I am using an archival node stopped at that block height, instead of using say a current node to query that block, if that makes sense? Or is that kind of implied when you pass in the block height?

It’s implied when you pass in a block height instead of using the ‘latest’ block tag.

Hope that helps

@2mh you are also able to look up the 4byte function signatures via https://www.4byte.directory

My understanding is its best to use a tool like ethers.js https://docs.ethers.io/ethers.js/html/api-contract.html#connecting-to-existing-contracts

and get the ABI of the contract from Etherscan https://etherscan.io/address/0xcbaa6ea4886b535fc7abace3f3985ed03b3b80a0#code

and then interact with it via the ethers.js library