Staking Basics¶
Staking allows you to become a validator in the ComputeChain network and participate in consensus.
Requirements¶
Minimum Stake¶
By Network:
| Network | Minimum Initial Stake |
|---|---|
| Devnet | 1,000 CPC |
| Testnet | 100,000 CPC |
| Mainnet | 100,000 CPC |
Maximum Validators¶
| Network | Maximum Validators |
|---|---|
| Devnet | 5 |
| Testnet | 21 |
| Mainnet | 100 |
STAKE Transaction¶
Transaction Structure¶
Type: TxType.STAKE
Fields:
Transaction(
tx_type=TxType.STAKE,
from_address="cpc1...", # Sender address
to_address=None, # Not used for staking
amount=1500 * 10**18, # Stake amount (in wei)
fee=gas_limit * gas_price,
nonce=...,
gas_price=1000,
gas_limit=40000, # GAS_PER_TYPE[STAKE]
payload={
"pub_key": "02a1b2c3..." # Validator public key (required!)
}
)
Required Fields¶
pub_key in payload:
- Validator public key (hex string)
- Used to generate consensus address (
cpcvalcons...) - Transaction will be rejected without
pub_key
Automatic Filling:
CLI automatically takes public key from keystore:
Staking Process¶
Step 1: Create Key¶
Step 2: Fund Account¶
ALICE_ADDR=$(./cpc-cli keys show alice | grep address | awk '{print $2}' | tr -d '",')
./cpc-cli tx send $ALICE_ADDR 2000 --from faucet --node http://localhost:8000
Important: Balance must cover: - Stake amount (minimum 1,000 CPC for devnet when creating a new validator) - Transaction fee (~40,000 gas * gas_price)
Step 3: Send STAKE Transaction¶
What happens:
- CLI creates
STAKEtransaction - Automatically adds
pub_keyfrom keystore - Calculates
gas_limit(40,000) andfee - Signs transaction
- Sends to mempool via RPC
/tx/send
Step 4: Wait for Block Inclusion¶
Wait Time:
- Devnet: ~10 seconds (1 block)
- After inclusion, validator is created but not yet active
Step 5: Validator Activation¶
Epoch:
- Devnet: every 10 blocks (~100 seconds)
- Testnet: every 100 blocks (~50 minutes)
- Mainnet: every 72 blocks (~72 minutes)
What happens in epoch:
- Validator set recalculation
- Sort by stake (descending)
- Select top-N validators (N = max_validators)
- Activate validators (
is_active = True) - Deactivate validators outside top-N
Check Status:
Increasing Stake¶
Adding to Existing Stake¶
Simply send another STAKE transaction:
What happens:
- If validator with such
pub_keyalready exists, stake is added val.power += tx.amount- Validator remains in set (if was active)
Note: min_validator_stake applies only to the first STAKE (validator creation). Subsequent STAKE transactions can use any positive amount to increase existing stake.
Reward Address¶
Setting Reward Address¶
By Default:
reward_addressis set totx.from_address(sender address)- Block rewards go to this address
Change (Future):
Planned ability to change reward_address via separate transaction.
Gas Costs¶
STAKE Fee¶
Gas Cost: 40,000 gas
Calculation Example:
Minimum Balance for Staking:
Examples¶
Full Scenario (Node B)¶
# 1. Import faucet key from Node A
./cpc-cli keys import faucet --private-key $(cat .node_a/faucet_key.hex)
# 2. Create Alice
./cpc-cli keys add alice
# 3. Get Alice address
ALICE_ADDR=$(./cpc-cli keys show alice | grep address | awk '{print $2}' | tr -d '",')
# 4. Fund account
./cpc-cli tx send $ALICE_ADDR 2000 --from faucet --node http://localhost:8000
# 5. Stake
./cpc-cli tx stake 1500 --from alice --node http://localhost:8000
# 6. Wait for epoch (10 blocks)
sleep 120
# 7. Check status
./cpc-cli query validators --node http://localhost:8000
Next Steps¶
- Validator Lifecycle — Validator lifecycle
- Rewards — Validation rewards
- Node Setup — Running validator node