Skip to main content

Derive neuron ID

Intermediate
Tutorial

Overview

Since version1.3.0
Idempotent?no
Minimal access levelcontroller

Staking requires transferring tokens to a sub-account of the governance canister. To complete the transfer, you need to know both your ICP ledger account identifier (source of the transfer) and the account identifier of the governance sub-account (destination of the transfer). Make sure you have enough ICP in your source account to make the transfer to the governance canister. To derive the account identifier of your public key you can look at how the derive endpoint works.

Deriving the governance canister account identifier

For neuron creation on the Internet Computer, the process begins with the transfer of ICP tokens to the address destined to become the neuron. This address, while earmarked for a future neuron, does not yet represent an active neuron until the governance canister acknowledges the deposit. It's crucial to understand that, at this juncture, the neuron has not been created; the address is simply a placeholder for the future neuron. By transferring the ICP tokens directly to this designated address, you effectively earmark them for neuron creation. However, the governance canister must be notified of this transfer to activate the neuron. This process is done in the next step of the guide. Once the governance canister is aware, it uses the transferred tokens at the specified address to formally establish the neuron.

You can derive the governance canister account identifier you need to send ICP similarly as to how you derive your own account identifier.

curl --location '0.0.0.0:8081/construction/derive'  --header 'Content-Type: application/json' --data '{
"network_identifier": {
"blockchain": "Internet Computer",
"network": "00000000000000020101"
},
"public_key": {
"hex_bytes": "047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c757367",
"curve_type": "secp256k1"
},
"metadata": {
"account_type": "neuron",
"neuron_index": 0
}
}'

The response is the account identifier we need to fund with ICP.

{"account_identifier":{"address":"26d877d2a04f0a9ae5e5a481102d5a865115263f2ed93a0804e3ed7b8d824921"}}

Since version 1.3.0, you can control many neurons using the same key. You can differentiate between neurons by specifying different values of the neuron_index metadata field. The rosetta node supports neuron_index in all neuron management operations. neuron_index is an arbitrary integer between 0 and 264 - 1 (18446744073709551615). It is equal to zero if not specified. If you use JavaScript to construct requests to the Rosetta node, consider using the BigInt type to represent the neuron_index. The Number type can precisely represent only values below 253 - 1 (9007199254740991).

We can then fund this account with the amount of ICP we would like to stake. In this example with want to stake 10 ICP or 1_000_000_000 e8s.