Does the stakedMaturityE8sEquivalent field in ic-js represent the maturity of the neuron?

I am using ic-js to query my neuron maturity at the code level via hotkey, and the neuron maturity in the NNS shows: 0.00026069.
but in the returned field it is showing:
stakedMaturityE8sEquivalent: undefined
image
This leads me to be not quite sure which field actually represents the neuronal maturity.
Does anyone know which field represents neuronal maturity?

Hi @e274426380,

There are two keys for maturity:

  • stakedMaturityE8sEquivalent
  • maturityE8sEquivalent

“stakedMaturityE8sEquivalent” maturity is used to increase voting power and future rewards of the neuron.

“maturityE8sEquivalent” is the maturity that can be staked or spawned.

More about maturity here: Staking and voting rewards on the NNS | Internet Computer

Don’t hesitate to ask any further questions.

1 Like

I seem to understand.
So maturityE8sEquivalent represents my neuronal interest.
And my maturityE8sEquivalent shows 0n, not 0.00026069 is it because the value is too small and just ignored?

If your maturity is so, it should have it.

How do you know that it’s “0.00026069”?

1 Like

in https://nns.ic0.app/.
:cold_face:But I have found a major error.
I thought that the neurons listed in neuron.listNeurons were my neurons, but now I realise that this doesn’t seem to be correct because the neurons don’t have the same id.
Through testing, I found
const neuron = GovernanceCanister.create()
The list of neurons derived from neuron.listNeurons belongs to the anonymous user 2vxsx-fae, and now my question is, how do I get neuron to learn information about my currently logged in II so that I can get a list of neurons that correspond to the logged in user?
Oddly enough, I remember when I was testing this API a few months ago, I came to the conclusion that calling this method when I was logged in would return the neuron list for the currently logged in II, but things are different now than they were then.
Am I misremembering this?

It depends on who is making the call to listNeurons.

Do you see your neurons in https://nns.ic0.app/ ?

The problem is that when you login from another domain, not https://nns.ic0.app/ the, Internet Identity give you another “identity”

Check the Internet Identity Spec.

For example, if you are in localhost, you login with II, even you are using the same Anchor in Internet Identity, you get another “identity”. That’s why when you make a call to get the neurons, you don’t get any.

From where are you making the call to listNeurons?

I get authorisation by entering my current site’s principalId as a hotkey into my nns neuron.
I tried setting the hotkey to “2vxsx-fae” and managed to get my nns neuron information.
Now I know that I should be entering the agent as a parameter into the create method.

const neuron = GovernanceCanister.create({
    agent: agent,
  })

I’m trying it out though and will continue to look for help in the forums when I have a new question, thanks for the answer.

The principal “2vxsx-fae” is the anonymous identity. I don’t recommend setting it as hotkey to your neuron. Anyone will be able to vote with your neuron.

When you create an agent, you need to specify the identity.

Inspect the project built by dfx new, it has some useful snippets.

2 Likes

I definitely agree that you should be using a proper identity for something like your hotkey, but congrats on taking the initiative for coding it yourself!

The HttpAgent from @dfinity/agent can be initialized with an identity, creating an “authenticated” agent instead of the “anonymous” agent. You should pass a valid identity from @dfinity/identity or @dfinity/identity-secp256k1 during the HttpAgent constructor - https://agent-js.icp.xyz/agent/interfaces/HttpAgentOptions.html

An EcdsaKeyIdentity, stored in IndexedDb is the most secure approach, but you can also use an Ed25519KeyIdentity generated from a secret, or a Secp256k1KeyIdentity from a seed phrase

3 Likes

Setting the hotkey to “2vxsx-fae” for emergency testing only, I have now removed it from the hotkey when I confirmed to my neuron message.
I have now confirmed that after passing in the agent, I can query to get the neuron corresponding to the principleId.

1 Like

Thanks for the reply, I passed the
const agent = new HttpAgent({ identity })
Created the agent and passed the agent in

const neuron = GovernanceCanister.create({
      agent: agent, {
    })

to get the canister with authentication, and now everything functions fine.

3 Likes