Creating new neuron through canister interaction

Hi! I’m trying to code sth. that could programmatically create new neurons through either dfx or endpoints. From playing with the NNS webapp, it seems that creating new neuron somehow involves sending ICP to Governance canister (send_pb call and notify_pb call)?

Could someone explain in details? thanks!

Hey there, welcome to the community :slight_smile:

Create neuron
When the principal is a public key holder, they may lock a portion of their balance inside a new neuron. Technically, creating the neuron is done in two stages. First transfer the ICP to be staked to an account of the governance canister (which corresponds to a new neuron — the details of the association are omitted here). Then notify the governance canister of the incoming transfer which updates its internal neuron bookkeeping. If the entire balance is locked inside a new neuron, the account ceases to exist (i.e., is deleted from the ledger). To move these ICP to a different account, such as back to the original account, where they can once again be controlled like a normal balance, the associated neuron must be fully dissolved and disbursed (destroyed). The new neuron that has been created is controlled by the private key of the principal that created it.


Does this help?

Yes I’ve read this part. Thank you.

It seems like I need to send from a subaccount to a subaccount of governance canister.

How do you do that through dfx or protobuf exactly? What would be the command / params to do that? How do you find out the receiving accounts of the governance canister for staking purpose?

cc @prithvi @paulyoung @PaulLiu

I also wanted to do this, but I’ve not figured this out myself yet. @wang has collected the set of Candid interface files in his IC Tools repository, which can be helpful. But setting up those did file to use with dfx is still a bit awkward.

There is now a icx command that is simpler than dfx, and can communicate with the IC directly. But still, you’ll need go through some Candid encoding/decoding in order to talk to the governance and other canisters.

thanks Paul. I’ll try ic-tools

I’ve found how to create neurons, with some clue from Norton’s ic tools.
here’s the python code:

Also summarized here for the command line: