Watch the video walkthrough for this topic in the Video Tutorials section.
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 address0x0000000000000000000000000000000000001005 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, andValidatorEditedevents.
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
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:How this works in practice
delegate() function (uses 18 decimals):delegate(): Acceptsmsg.valuein wei (18 decimals)
undelegate(): Expects the amount parameter in 6 decimals (uSEI)redelegate(): Expects the amount parameter in 6 decimals (uSEI)
delegation(): Returnsbalance.amountin 6-decimaluSEIanddelegation.sharesin 18-decimal precision- The Distribution precompile handles rewards. Its
rewards()query returns 18-decimalDecCoins, but withdrawn amounts (events) are 6-decimaluSEI.
Why this mixed system exists
- delegate() EVM compatibility: Uses the standard 18-decimal wei format, for consistency with EVM
msg.value - Cosmos integration for other operations:
undelegate()andredelegate()use 6-decimal uSEI precision to match native Cosmos operations - Staking query consistency: Query balances in the staking precompile use 6-decimal
uSEI(butsharesis 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)
- Display: convert to
- Reconcile delegate amounts with undelegate, redelegate, and rewards amounts: Convert the delegate
msg.valuefrom wei to uSEI with integer division by1e12(floor). This matches the internal truncation in the precompile. - Enforce granularity at the source: Construct
msg.valueas a multiple of1e12wei. To do this, format user input to 6 decimals before you callparseUnits.
Decimal conversion helpers
Use these helper functions to avoid precision errors:Step-by-step guide: Using the staking precompile
Delegate tokens
- JavaScript
- Solidity
Undelegate tokens
- JavaScript
- Solidity
Redelegate tokens
- JavaScript
- Solidity
Query a delegation
- JavaScript
- Solidity
Create a validator
- JavaScript
- Solidity
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
- JavaScript
- Solidity
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
Gas-related issues
Error code reference
FAQ: precision and normalization
- What are the base units and precision standards for SEI across operations?
delegate(): Acceptsmsg.valuein wei (18 decimals), but the precompile truncates it internally to 6-decimaluSEI. The effective granularity is 1 uSEI =1e12wei.undelegate()andredelegate(): Amounts use 6-decimaluSEI.- Staking queries: Balances are 6-decimal
uSEI, and shares are 18-decimal. The Distributionrewards()query returns 18-decimalDecCoins, but withdrawn amounts are 6-decimaluSEI.
- Should applications normalize between 18 and 6 decimals?
- Yes. For reconciliation, convert delegate
weitouSEIwith integer division by1e12(floor). For display, convert to SEI (wei → /1e18,uSEI → /1e6).
- Yes. For reconciliation, convert delegate
- 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-decimaluSEI.
- Yes. This behavior is intentional, and there is no plan to change it. Delegation uses EVM-native
- 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 thandelegate()stay consistent at 6 decimals.
- The precompile bridges EVM conventions (18-decimal
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-decimalDecCoins. Withdrawn amounts (events) are 6-decimaluSEI. - Granularity: The
msg.valueofdelegate()must be a multiple of1e12wei (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.