Skip to main content
Watch the video walkthrough for this topic in the Video Tutorials section.
Address: 0x0000000000000000000000000000000000001005 The Sei staking precompile lets EVM applications interact directly with the Sei native staking module through standard smart contract calls. Your dApps can use it for delegation, undelegation, redelegation, validator management, and staking queries. They do not need a separate Cosmos SDK integration.
What is a precompile? A precompile is a special smart contract that the Sei protocol itself deploys at a fixed address. It exposes custom native chain logic to EVM-based applications. To the EVM, it behaves like a regular contract, but it executes privileged, low-level logic efficiently.

How does the staking precompile work?

The staking precompile at address 0x0000000000000000000000000000000000001005 exposes transaction functions such as delegate(), undelegate(), redelegate(), createValidator(), and editValidator(). It also exposes query functions such as validators(), delegatorDelegations(), pool(), and params().
  • EVM contracts and dApps can call staking functions like any other smart contract method.
  • Operations run at the Cosmos SDK level, which makes them efficient and secure.
  • You do not need separate wallet integrations or complex cross-chain interactions.
  • Staking operations emit Delegate, Undelegate, Redelegate, DelegationRewardsWithdrawn, ValidatorCreated, and ValidatorEdited events.

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

This guide shows how to:
  • Call delegation, undelegation, and redelegation functions directly from your EVM contracts and dApps
  • Use the correct decimal precision for each operation, to avoid common formatting errors
  • Create validators and edit their parameters programmatically
  • Use the query functions to fetch validators, delegations, unbonding information, pool statistics, and staking parameters
  • Listen for staking events, to track staking operations for indexing and notifications
  • Build portfolio tools for staking management applications, with automated rebalancing and delegation tracking
  • Understand unbonding periods, slashing mechanics, and validator selection, so that you can stake safely

Events

The staking precompile emits these events:

Listening for events

Your dApp can listen for these events to track staking operations:

Functions

The staking precompile exposes these functions:

Transaction functions

Query functions

Precision in the delegation() response:The response uses two different precision scales:
  • balance.amount: The staked token amount, in 6 decimals (usei)
  • delegation.shares: The amount of shares in the validator pool, in 18 decimals
  • delegation.decimals: Always returns 18 (the precision of the shares, NOT of the balance)
To convert to SEI for display:
  • Balance: balance.amount / 1e6
  • Shares: delegation.shares / 1e18

Using the precompile

Setup

Prerequisites

Before you start, make sure that you have:
  • Node.js (v18 or higher)
  • The npm or yarn package manager
  • An EVM-compatible wallet
  • SEI tokens for gas and staking operations

Install dependencies

Install the required packages to interact 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

Decimal precision is one of the most important concepts to understand when you work with the Sei staking precompile.

Mixed decimal precision system

The staking precompile uses different decimal precision for different operations, because it bridges EVM and Cosmos standards:
Granularity for delegate():To avoid unintended truncation, always send amounts that are a multiple of 1e12 wei (the last 12 digits are zero). The precompile truncates msg.value to 6 decimals (uSEI).
  • 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 the amount parameter in 6 decimals (uSEI)
  • redelegate(): Expects the amount parameter in 6 decimals (uSEI)
Read and query operations (return 6 decimals):
  • delegation(): Returns balance.amount in 6-decimal uSEI and delegation.shares in 18-decimal precision
  • The Distribution precompile handles rewards. Its rewards() query returns 18-decimal DecCoins, but withdrawn amounts (events) are 6-decimal uSEI.

Why this mixed system exists

  1. delegate() EVM compatibility: Uses the standard 18-decimal wei format, for consistency with EVM msg.value
  2. Cosmos integration for other operations: undelegate() and redelegate() use 6-decimal uSEI precision to match native Cosmos operations
  3. Staking query consistency: Query balances in the staking precompile use 6-decimal uSEI (but shares is 18-decimal), for consistent reading

Best practice: different conversion for different functions

When you work with user input, 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 and aggregation: prefer uSEI (6 decimals)
  • Reconcile delegate amounts with undelegate, redelegate, and rewards amounts: Convert the delegate msg.value from wei to uSEI with integer division by 1e12 (floor). This matches the internal truncation in the precompile.
  • Enforce granularity at the source: Construct msg.value as a multiple of 1e12 wei. To do this, format user input to 6 decimals before you call parseUnits.

Decimal conversion helpers

Use these helper functions to avoid precision errors:

Step-by-step guide: Using the staking precompile

Delegate tokens

Undelegate tokens

Undelegated tokens have a 21-day unbonding period. During this period, you cannot transfer them, and they do not earn rewards.

Redelegate tokens

Redelegation restrictions:
  • A maximum of 7 redelegations per validator pair in each 21-day period
  • After you redelegate 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

Proceed only if you understand the responsibilities of running a validator node. To create a validator, you need significant SEI for self-delegation and a correctly configured validator infrastructure.

Edit a validator

Edit validator constraints: You can change the commission only once every 24 hours. You can only increase minSelfDelegation, never decrease it. To keep the current rate, pass an empty string "" for commissionRate. To keep the current value, pass 0 for minSelfDelegation.

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: For 21 days, undelegated tokens cannot be transferred and do not earn rewards.
  • No exceptions: After the unbonding starts, you cannot cancel it.
  • Planning: Consider the unbonding period when you manage liquidity needs.

Validator selection criteria

  • Commission rate: Commission is typically 1% to 10%. A lower commission means more rewards for you.
  • Uptime: Look for validators with high uptime (99% or more).

Redelegation complexity

  • 7-transaction limit: You can redelegate from the same validator to the same destination validator only 7 times in 21 days.
  • Serial blocking: After you redelegate from A to B, you cannot redelegate from B to 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 for SEI across operations?
    • delegate(): Accepts msg.value in wei (18 decimals), but the precompile truncates it internally to 6-decimal uSEI. The effective granularity is 1 uSEI = 1e12 wei.
    • undelegate() and redelegate(): Amounts use 6-decimal uSEI.
    • Staking queries: Balances are 6-decimal uSEI, and shares are 18-decimal. The 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 with integer division by 1e12 (floor). For display, convert to SEI (wei → /1e18, uSEI → /1e6).
  • Is this behavior consistent and intentional?
    • Yes. This behavior is intentional, and there is no plan to change it. Delegation uses EVM-native msg.value (18 decimals). Staking operations run in the Cosmos staking module, which uses 6-decimal uSEI.
  • Why does one chain use multiple decimal precisions?
    • The precompile bridges EVM conventions (18-decimal msg.value) and the native 6-decimal accounting of the Cosmos staking module. At the same time, queries and writes other than delegate() stay consistent at 6 decimals.

Important notes

Remember this rule: delegate() uses 18 decimals, undelegate() and redelegate() use 6 decimals, and 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 the appropriate conversion function for each operation
  • Rewards and claims (Distribution precompile): The rewards() query returns 18-decimal DecCoins. Withdrawn amounts (events) are 6-decimal uSEI.
  • Granularity: The msg.value of delegate() must be a multiple of 1e12 wei (the last 12 digits are zero). The precompile truncates it to 6 decimals internally.

Validator addresses

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

Staking risks

  • Unbonding: A 21-day waiting period applies to undelegated tokens.
  • Redelegation limits: Complex rules apply to redelegation frequency and serial redelegations.

Commission and rewards

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