Staking Interfaces
Welcome to the 0G Chain Staking Interfaces documentation. This guide provides comprehensive information about interacting with the 0G Chain staking system through smart contracts, enabling you to build applications that leverage validator operations and delegations.
If you want to set up and initialize a validator, see the Validator Initialization Guide below.
Quick Navigation
- Validator Initialization Guide - Complete step-by-step setup for becoming a validator
- Contract Interfaces - Smart contract reference documentation
- Examples - Smart contract code examples
Overview
The 0G Chain staking system enables 0G token holders to participate in network consensus and earn rewards through two primary mechanisms:
- Becoming a Validator: Run infrastructure to validate transactions and produce blocks
- Delegating to Validators: Stake tokens with existing validators to earn rewards without running infrastructure
The staking system is built on two core smart contract interfaces:
IStakingContract: Central registry managing validators and global staking parametersIValidatorContract: Individual validator operations including delegations and reward distribution
Prerequisites
Before working with the staking interfaces:
- Familiarity with Solidity and smart contract development
- Basic knowledge of consensus mechanisms and staking concepts
Quick Start
// Create a validator
IStakingContract staking = IStakingContract(0xea224dBB52F57752044c0C86aD50930091F561B9);
address validator = staking.createAndInitializeValidatorIfNecessary{value: msg.value}(
description, commissionRate, withdrawalFee, pubkey, signature
);
// Delegate to validator
IValidatorContract(validator).delegate{value: msg.value}(msg.sender);
Core Concepts
Validators
Validators process transactions and produce blocks:
- Unique Identity: Identified by 48-byte consensus public key
- Operator Control: Managed by an Ethereum address
- Commission: Set their own reward commission rates
- Self-Delegation: Required minimum stake from operator
Delegations
Token holders earn rewards by delegating to validators:
- Share-Based: Delegations represented as shares in validator pool
- Proportional Rewards: Earnings based on share percentage
- Withdrawal Delay: Undelegation subject to network delay period
Reward Distribution
Rewards flow through multiple layers:
- Community Tax: Applied to all rewards first
- Validator Commission: Taken from remaining rewards
- Delegator Distribution: Proportional to shares held
Contract Interfaces
IStakingContract
0xea224dBB52F57752044c0C86aD50930091F561B9 (Mainnet)
Central registry for validators and global parameters.
Validator Management
// Create validator contract
function createValidator(bytes calldata pubkey) external returns (address);
// Initialize validator with self-delegation
function initializeValidator(
Description calldata description,
uint32 commissionRate,
uint96 withdrawalFeeInGwei,
bytes calldata pubkey,
bytes calldata signature
) external payable;
// Create and initialize in one call
function createAndInitializeValidatorIfNecessary(
Description calldata description,
uint32 commissionRate,
uint96 withdrawalFeeInGwei,
bytes calldata pubkey,
bytes calldata signature
) external payable;
Query Functions
function getValidator(bytes memory pubkey) external view returns (address);
function computeValidatorAddress(bytes calldata pubkey) external view returns (address);
function validatorCount() external view returns (uint32);
function maxValidatorCount() external view returns (uint32);