Ability to stake a neuron via dfx?

I searched deeply within the dfinity/ic code and it appears the only place “CreateNeuron” is used is via the method call to “RewardNodeProvider” - but how do you stake a neuron locally via dfx utility and call the governance canister directly? Does not appear to be an open method for us to stake a neuron other than using NNS app…

Please advise and thanks!


See: IC: Creating a new neuron (python) · GitHub

1 Like

@toysrtommy nice, thanks! Did you forget to include “CMD_CALL” and “CA_NNS”? Getting a slight error.

Traceback (most recent call last):
  File "neuron.py", line 11, in <module>
    CMD_REFRESH_NEURON="%s %s claim_or_refresh_neuron_from_account \"(record {{controller=principal \\\"{}\\\"; memo={}:nat64}})\"" % (CMD_CALL, CA_NNS)
NameError: name 'CMD_CALL' is not defined

Ah updated! thanks for reminding. it was extracted from a larger codebase.

1 Like

@toysrtommy great, thank you!

One last question, why can’t I find claim_or_refresh_neuron_from_account anywhere I look? It’s not in any interface specification I can seem to find: Home | ic.rocks

yeah i didn’t know either, until found it mentioned in another post here. I believe it’s a fairly recent addition.

1 Like

I’m working on a tool to support this. It won’t be in dfx though

icx-nns --endpoint $xsmall_a ledger stake-neuron 2x3kc-3n2jw-v3q5h-ngy4b-w2rsb-2ef5e-xxwan-qvhuq-lesp5-zmkjb-bae 1234 --amount 10
Transfer sent at BlockHeight: 9
Neuron id: NeuronId { id: 9634531799399624543 }

icx-nns --endpoint $xsmall_a governance get-neuron-ids

icx-nns --endpoint $xsmall_a governance get-neuron-info 9634531799399624543
NeuronInfo { retrieved_at_timestamp_seconds: 1622604166, state: Dissolved, age_seconds: 96, dissolve_delay_seconds: 0, recent_ballots: [], voting_power: 1000000190, created_timestamp_seconds: 1622604070 }

Hope to have it out with docs soon. It allows you to submit proposals, etc too.


This is great, let us know when it’s ready!

Agree, this would be very handy!

how did you know how to create the NNS subaccount? from the interface spec?

just inspected the nns.ic0.app’s js code (dfinity_agent.js)

1 Like