Skip to main content

Stake ICP

Intermediate
Tutorial

Overview

Since version1.5.0
Idempotent?yes
Minimal access levelcontroller

This section of the staking tutorial will show you how to use the ICP that was previously sent to the governance account identifier corresponding to your public key. You can use this ICP to create and fund a neuron.

The full amount of ICP that was sent to the governance account identifier will be used for staking.

A call to the endpoint construction/payloads would resemble the following.

curl --location '0.0.0.0:8081/construction/payloads'  --header 'Content-Type: application/json' --data '{
"network_identifier": {
"blockchain": "Internet Computer",
"network": "00000000000000020101"
},
"public_keys": [
{
"hex_bytes": "047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c757367",
"curve_type": "secp256k1"
}
],
"operations": [
{
"operation_identifier": {
"index": 0
},
"type": "STAKE",
"account": {
"address": "8b84c3a3529d02a9decb5b1a27e7c8d886e17e07ea0a538269697ef09c2a27b4"
},
"metadata": {
"neuron_index": 0
}
}
],
"metadata": null
}'

The transaction's returned output will resemble the following:

{'transaction_identifier': {'hash': '0000000000000000000000000000000000000000000000000000000000000000'}, 'metadata': {'operations': [{'account': {'address': '8b84c3a3529d02a9decb5b1a27e7c8d886e17e07ea0a538269697ef09c2a27b4'}, 'metadata': {'neuron_id': 3094748712371737240, 'neuron_index': 0}, 'operation_identifier': {'index': 0}, 'status': 'COMPLETED', 'type': 'STAKE'}]}}

Neuron management operations don’t strictly adhere to the Rosetta specification. If the transaction only contains the neuron management operations (like the example above), the returned transaction hash won’t be on the ICP ledger chain. The returned transaction hash does not make any sense for governance operations and is thus left blank.

The governance canister will take your public key and the neuron index provided (in this case it was 0) and either create a new neuron_id or add the ICP to an already existing neuron with the same derived neuron_id. In this case the neuron with the neuron_id 3094748712371737240 was created.

The neuron_id is an internal representation of neurons on the governance canister. The neuron index corresponds to the index of neurons that a certain public key controls. Taking the public key 047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c757367, the index 0 and given how many existing neurons already exist, the governance canister arrives at the neuron_id 3094748712371737240