How to check the stake interest records of ICP using rust or js code?

Hello everyone, Recently I am developing a dapp. Here is my question in the process of developing .
Assume a user have staked some ICP in the NNS wallet for 8 years.
I am not sure how to interact with the NNS wallet API or the IC ledger. Can anyone give me some guidance or examples on how to query the historical transaction data of the NNS wallet and get the stake interest of ICP using rust or JS code?
Thank you very much!

1 Like

Hi @q2333gh

When a user stakes ICP, it means that the user staked a “neuron”.

You can get the list of neurons of a user using nns-js, and a method in the class GovernanceCanister called listNeurons.

Check this URL:

The method says: “returns the list of neurons controlled by the caller.”

The caller needs to be the same identity that was used to stake the neuron.

For example, in the NNS Dapp, the users log in with Internet Identity and then they are able to stake a neuron with that user. Therefore, when we then call “listNeurons” with that same user, we get the neuron they staked.

Remember that with Internet Identity, each client application gets a different identity.

I hope this helped but don’t hesitate to reply if you have any further questions.