Skip to main content
Watch the video walkthrough for this topic in the Video Tutorials section.
Address: 0x0000000000000000000000000000000000001005 The Sei staking precompile allows EVM applications to interact directly with Sei’s native staking module through standard smart contract calls. This enables delegation, undelegation, redelegation, validator management, and staking queries directly from your dApps without needing separate Cosmos SDK integration.
What is a precompile? A precompile is a special smart contract deployed at a fixed address by the Sei protocol itself, that exposes custom native chain logic to EVM-based applications. It acts like a regular contract from the EVM’s perspective, but executes privileged, low-level logic efficiently.

How Does the Staking Precompile Work?

The staking precompile at address 0x0000000000000000000000000000000000001005 exposes a comprehensive set of staking functions including delegate(), undelegate(), redelegate(), createValidator(), editValidator(), and various query functions like validators(), delegatorDelegations(), pool(), and params().
  • Direct Integration: EVM contracts and dApps can call staking functions like any other smart contract method.
  • Native Execution: Operations are executed at the Cosmos SDK level for maximum efficiency and security.
  • Seamless Bridge: No need for separate wallet integrations or complex cross-chain interactions.
  • Event Emission: All staking operations emit events (Delegate, Undelegate, Redelegate, ValidatorCreated, ValidatorEdited) for easy tracking and indexing.

Use Cases

  • DeFi Integration: Build liquid staking protocols and yield farming strategies.
  • Delegation Services: Create user-friendly interfaces for staking operations.
  • Portfolio Management: Automate staking strategies and delegation rebalancing.
  • Validator Management: Create and manage validators programmatically.

What You’ll Learn in This Guide

By the end of this guide, you’ll be able to:
  • Integrate Staking Operations - Call delegation, undelegation, and redelegation functions directly from your EVM contracts and dApps
  • Handle Decimal Precision - Master the critical precision patterns for different operations to avoid common formatting errors
  • Create and Manage Validators - Create new validators and edit their parameters programmatically
  • Query Staking State - Use the comprehensive query functions to fetch validators, delegations, unbonding info, pool statistics, and staking parameters
  • Listen for Staking Events - Track staking operations using emitted events for indexing and notifications
  • Build Portfolio Tools - Implement automated rebalancing and delegation tracking for staking management applications
  • Navigate Staking Risks - Understand unbonding periods, slashing mechanics, and validator selection for safe staking operations

Events

The staking precompile emits the following events:

Listening for Events

You can listen for these events in your dApp to track staking operations:

Functions

The staking precompile exposes the following functions:

Transaction Functions

Query Functions

Important Precision Note for delegation() Response:The response contains two different precision scales:
  • balance.amount: 6 decimals (usei) - the actual staked token amount
  • delegation.shares: 18 decimals - the validator pool share amount
  • delegation.decimals: Always returns 18 (refers to shares precision, NOT balance)
To convert to SEI for display:
  • Balance: balance.amount / 1e6
  • Shares: delegation.shares / 1e18

Using the Precompile

Setup

Prerequisites

Before getting started, ensure you have:
  • Node.js (v18 or higher)
  • npm or yarn package manager
  • EVM-compatible wallet
  • SEI tokens for gas and staking operations

Install Dependencies

Install the required packages for interacting with Sei precompiles:

Import Precompile Components

Precompile Address: The staking precompile is deployed at 0x0000000000000000000000000000000000001005

Contract Initialization

Set up your provider, signer, and contract instance:

Critical: Understanding Decimal Precision

One of the most important concepts to understand when working with the Sei staking precompile:

Mixed Decimal Precision System

The staking precompile operates with different decimal precision for different operations due to bridging EVM and Cosmos standards:
Granularity for delegate():msg.value is truncated to 6 decimals (uSEI). Always send amounts that are a multiple of 1e12 wei (last 12 digits zero) to avoid unintended truncation.
  • OK: 1_000_000_000_000 wei (0.000001000000 SEI)
  • NOT OK: 1_000_000_000_001 wei (0.000001000000000001 SEI)
  • NOT OK: 1_000_000_330_000 wei (0.000001000000330000 SEI)
Examples:
  • Delegate 10 SEI → 10000000000000000000 wei (18 decimals)
  • Undelegate 10 SEI → 10000000 uSEI (6 decimals)

How This Works in Practice

delegate() Function (Uses 18 decimals):
  • delegate() - accepts msg.value in wei (18 decimals)
undelegate() and redelegate() Functions (Use 6 decimals):
  • undelegate() - expects amount parameter in 6 decimals (uSEI)
  • redelegate() - expects amount parameter in 6 decimals (uSEI)
Reading/Query Operations (Return 6 decimals):
  • delegation() - returns balance.amount in 6-decimal uSEI and delegation.shares in 18-decimal precision
  • Rewards are handled by the Distribution precompile: rewards() query returns 18-decimal DecCoins, while withdrawn amounts (events) are 6-decimal uSEI

Why This Mixed System Exists

  1. delegate() EVM Compatibility: Uses standard 18-decimal wei format for EVM msg.value consistency
  2. Other Operations Cosmos Integration: undelegate() and redelegate() use 6-decimal uSEI precision to match native Cosmos operations
  3. Staking Query Consistency: Staking precompile query balances use 6-decimal uSEI (while shares is 18-decimal) for consistent reading

Best Practice: Different Conversion for Different Functions

When working with user inputs, use the appropriate conversion for each function:

Normalization Guidelines (Clients and Indexers)

  • Normalize to a single unit for analytics and reconciliation:
    • Display: convert to SEI (wei / 1e18, uSEI / 1e6)
    • Storage/aggregation: prefer uSEI (6 decimals)
  • Reconciling delegate vs. undelegate/redelegate/rewards: convert delegate msg.value from wei to uSEI using integer division by 1e12 (floor), which matches the precompile’s internal truncation.
  • Enforce granularity at source: construct msg.value as a multiple of 1e12 wei by formatting user input to 6 decimals prior to parseUnits.

Decimal Conversion Helpers

Use these helper functions to avoid precision errors:

Step-by-Step Guide: Using the Staking Precompile

Delegate Tokens

Undelegate Tokens

IMPORTANT: Undelegated tokens are subject to a 21-day unbonding period during which they cannot be transferred and do not earn rewards.

Redelegate Tokens

Redelegation restrictions:
  • Maximum 7 redelegations per validator pair per 21-day period
  • After redelegating from Validator A to Validator B, you cannot redelegate from Validator B to another validator for 21 days
  • Each redelegation has its own 21-day cooldown period

Query a Delegation

Create a Validator

Creating a validator requires significant SEI for self-delegation and proper validator infrastructure setup. Only proceed if you understand the responsibilities of running a validator node.

Edit a Validator

Edit Validator Constraints: - Commission can only be changed once every 24 hours - minSelfDelegation can only be increased, never decreased - Pass empty string "" for commissionRate to keep current rate - Pass 0 for minSelfDelegation to keep current value

Query Validators

Query a Specific Validator

Query All Delegations for an Address

Query Unbonding Delegations

Query Redelegations

Query Staking Pool and Parameters

Query Historical Validator Info

Advanced Usage Examples

Portfolio Rebalancing

Complete Integration Example

Security Considerations & Risks

Unbonding Period

  • 21-day lock: Undelegated tokens cannot be transferred or earn rewards for 21 days
  • No exceptions: This cannot be canceled once initiated
  • Planning: Consider this when managing liquidity needs

Validator Selection Criteria

  • Commission Rate: Lower commission means more rewards for you (typically 1-10%)
  • Uptime: Check for validators with high uptime (99%+)

Redelegation Complexity

  • 7-transaction limit: You can only redelegate from the same validator to the same destination validator 7 times in 21 days
  • Serial blocking: After redelegating A→B, you cannot redelegate B→C for 21 days
  • Each redelegation starts its own 21-day timer

Troubleshooting

Common Issues and Solutions

Error Code Reference

FAQ: Precision and Normalization

  • What are the base units and precision standards defined for SEI across operations?
    • delegate(): accepts msg.value in wei (18 decimals), but is internally truncated to 6-decimal uSEI. Effective granularity is 1 uSEI = 1e12 wei.
    • undelegate() / redelegate(): amounts use 6-decimal uSEI.
    • Staking queries: balances are 6-decimal uSEI (and shares are 18-decimal). Distribution rewards() query returns 18-decimal DecCoins, but withdrawn amounts are 6-decimal uSEI.
  • Should applications normalize between 18 and 6 decimals?
    • Yes. For reconciliation, convert delegate wei to uSEI via integer division by 1e12 (floor). For display, convert to SEI (wei → /1e18, uSEI → /1e6).
  • Is this behavior consistent and intentional?
    • Yes. This is intentional and not planned to change. Delegation uses EVM-native msg.value (18 decimals), while staking operations are executed in the Cosmos staking module, which uses 6-decimal uSEI.
  • Why multiple decimal precisions on one chain?
    • To bridge EVM conventions (18-decimal msg.value) with the Cosmos staking module’s native 6-decimal accounting while keeping queries and non-delegate() writes consistent at 6 decimals.

Important Notes

Remember the key rule: delegate() uses 18 decimals, undelegate()/redelegate() use 6 decimals, delegation() returns 6 decimals!

Decimal Precision

  • delegate() uses 18 decimals (wei) for msg.value
  • undelegate() and redelegate() use 6 decimals (uSEI) for amount parameters
  • Query results return amounts in 6 decimal precision
  • Best practice: Use appropriate conversion functions for each operation
  • Rewards/claims (Distribution precompile): rewards() query returns 18-decimal DecCoins; withdrawn amounts (events) are 6-decimal uSEI
  • Granularity: delegate() msg.value must be a multiple of 1e12 wei (last 12 digits zero) because the precompile truncates to 6 decimals internally

Validator Addresses

  • Use valid Sei validator addresses with seivaloper1... prefix
  • These are Cosmos-format addresses, not EVM addresses

Staking Risks

  • Unbonding: 21-day waiting period for undelegated tokens
  • Redelegation limits: Complex rules around frequency and serial operations

Commission and Rewards

  • Validators keep a commission percentage
  • Rewards are distributed proportionally to delegation amounts
  • Choose validators wisely based on commission, uptime, and governance participation