Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

How to Implement a Non-Custodial Staking Solution

This guide provides a technical framework for institutions to build a staking service where they retain full control of validator keys, covering secure key generation, delegation contracts, and operational interfaces.
Chainscore © 2026
introduction
ARCHITECTURE GUIDE

How to Implement a Non-Custodial Staking Solution

This guide explains the core components and security patterns for building a non-custodial staking system, where users retain full control of their assets.

A non-custodial staking solution is defined by a single principle: the user's private keys and funds are never held by the service provider. Unlike centralized exchanges, where you deposit tokens into a custodial wallet, a non-custodial system uses smart contracts to delegate staking rights while the staked assets remain in the user's self-custodied wallet. This architecture eliminates counterparty risk and aligns with Web3's core ethos of user sovereignty. The primary technical challenge is designing a system that can securely manage delegation, rewards, and slashing without ever taking custody of the underlying tokens.

The core architecture typically involves three key smart contracts. First, a staking pool contract acts as the main entry point. Users interact with this contract to deposit (stake) and withdraw their tokens. Critically, this contract does not hold tokens permanently; it uses a delegation contract to assign voting or validation power to node operators. Second, a reward distribution contract calculates and allocates staking yields based on each user's share of the pool. These rewards are often claimable on-demand by the user. Third, an oracle or keeper network is required to monitor the underlying protocol (e.g., Ethereum's Beacon Chain, Cosmos validators) for slashing events and update the staking contracts accordingly.

Implementing the deposit function requires careful attention to asset handling. For Ethereum and EVM-compatible chains, the standard is to use the ERC-20 approve and transferFrom pattern. The user first approves the staking pool contract to spend a specific amount of their staking token. Then, they call a function like stake(uint256 amount), which safely pulls the tokens into the contract and mints a corresponding amount of liquid staking tokens (LSTs) to the user's address. These LSTs, such as stETH or rETH, represent the user's share and are freely transferable. The actual staking delegation to a validator set is then performed by the contract logic, not the user.

Reward mechanics must be transparent and trust-minimized. A common pattern is rebasing, where the value of each LST increases over time to reflect accrued rewards, as used by Lido's stETH. An alternative is the reward debt model, used by many yield farming contracts, which tracks a global reward accumulator and each user's share at the time of deposit. Rewards are calculated upon withdrawal or claim. All reward logic must be executed on-chain with data verified by oracles to prevent manipulation. Failed validator performance, or slashing, must also be reflected by reducing the value of the pool's LSTs proportionally.

Security is paramount. Key considerations include: - Using battle-tested libraries like OpenZeppelin for access control and math. - Implementing timelocks and multi-signature governance for critical parameter updates. - Conducting thorough audits from firms like Trail of Bits or Quantstamp. - Designing pause mechanisms for emergency stops in case of a discovered vulnerability. - Ensuring the system has no centralized admin keys that can unilaterally withdraw user funds. The contract should be verified on block explorers like Etherscan to guarantee transparency.

To start building, use established frameworks. For Ethereum, study the source code of Lido or Rocket Pool. For Cosmos SDK chains, examine the x/staking module. A basic proof-of-concept involves writing a Solidity contract that accepts an ERC-20, mints a receipt token, and uses a mock oracle to simulate rewards. The ultimate goal is a system where users can verify for themselves, via the immutable contract code, that their assets are secure and the protocol rules are enforced without the need for trust in a central entity.

prerequisites
IMPLEMENTATION GUIDE

Prerequisites and Core Requirements

Before building a non-custodial staking solution, you must establish the foundational technical and conceptual requirements. This section outlines the essential knowledge, tools, and architectural decisions needed for a secure and functional implementation.

A non-custodial staking solution allows users to delegate their tokens to a validator or pool while retaining full ownership of their private keys. This is a fundamental security model in decentralized finance, contrasting with custodial services where a third party controls the assets. The core requirement is to build a system of smart contracts that can securely accept user deposits, manage delegation logic, distribute rewards, and process withdrawals, all without ever taking custody of the user's private key. Popular frameworks for this include building directly on a blockchain's native staking module (like Ethereum's Beacon Chain deposit contract) or creating a liquid staking derivative protocol.

You will need proficiency in a smart contract language, typically Solidity for Ethereum Virtual Machine (EVM) chains or Rust for Solana or CosmWasm-based chains. A deep understanding of the target blockchain's consensus mechanism (Proof-of-Stake, Delegated Proof-of-Stake, etc.) and its staking APIs is non-negotiable. For example, on Ethereum, you must interact with the Beacon Chain deposit contract at 0x00000000219ab540356cBB839Cbe05303d7705Fa and understand validator lifecycle management. Essential developer tools include a framework like Hardhat or Foundry, a testnet faucet for test tokens, and blockchain explorers like Etherscan for contract verification.

Security is the paramount concern. Your architecture must account for key risks: slashing conditions, reward calculation errors, and upgrade mechanisms. Use established libraries like OpenZeppelin for secure contract patterns and plan for a timelock-controlled multi-signature wallet to manage administrative functions. All economic logic, including reward distribution formulas and fee structures, must be transparent and immutable post-deployment. Thorough testing on a testnet is mandatory; this includes unit tests for contract functions and simulated mainnet fork tests using tools like Ganache or Anvil to validate interactions with live staking contracts.

Finally, consider the user experience and integration layer. Your solution will need a web3 front-end (using a library like ethers.js or web3.js) for users to interact with the staking contracts. You may also need to build or integrate an oracle or indexer to track validator performance and calculate real-time rewards off-chain. Deciding whether to create a liquid staking token (LST) adds another layer of complexity, requiring additional contracts for minting/burning the derivative and ensuring its peg to the native staked asset.

key-concepts-text
CORE TECHNICAL CONCEPTS

How to Implement a Non-Custodial Staking Solution

A technical guide to building a staking protocol where users retain full control of their assets.

A non-custodial staking solution is a protocol that allows users to stake their cryptocurrency to secure a blockchain network without ever surrendering custody of their private keys. This is a fundamental security and trust model shift from centralized exchanges or custodial services. The core technical challenge is designing a system where the staking logic is executed via smart contracts on-chain, while the user's signing authority remains off-chain in their personal wallet. This guide outlines the key architectural components and implementation steps for building such a system, typically for a Proof-of-Stake (PoS) network like Ethereum, Cosmos, or a custom Substrate-based chain.

The architecture revolves around two primary smart contracts: a Staking Vault and a Rewards Distributor. The Vault is responsible for accepting user deposits, tracking stakes, and delegating to validators. Crucially, it should never hold a user's private key. Instead, users interact with it by signing messages with their wallet. The contract must implement secure functions for deposit(), withdraw(), and claimRewards(), each requiring a valid signature. For Ethereum staking, this involves interfacing with the official Deposit Contract (0x00000000219ab540356cBB839Cbe05303d7705Fa) and potentially using liquid staking tokens (LSTs) like stETH as a representation of the stake.

Implementing secure delegation is critical. Your staking contract must manage a whitelist of trusted validator public keys. When a user stakes, the contract logic should bundle deposits to meet the chain's minimum stake requirement (e.g., 32 ETH for Ethereum) and then execute a delegation to a validator. This often requires crafting and submitting specific transaction messages to the PoS chain's beacon node or staking module. For cross-chain solutions, you'll need a relayer or oracle service to bridge this communication. All delegation actions must be permissionless for the user but programmatically enforced by the contract's rules to prevent centralization risks.

Rewards distribution must be transparent and trust-minimized. The Rewards Distributor contract periodically receives staking rewards from the network. It calculates each user's share based on their stake amount and duration, minus a protocol fee. A common pattern is to accrue rewards on a per-second basis using a reward index that increases as rewards flow in. Users can then claim rewards by calling a function that calculates their entitled amount based on the difference between the current index and the index at their last interaction. This design gas-efficiently handles reward accounting for a large number of stakers.

Security considerations are paramount. Your contracts must be protected against common vulnerabilities like reentrancy, integer overflows, and logic errors in reward math. Use established libraries like OpenZeppelin and conduct thorough audits. Furthermore, implement a timelock or multi-signature mechanism for administrative functions such as updating the validator whitelist or fee parameters. To enhance user experience, consider integrating with EIP-712 for typed structured data signing, which provides clearer transaction prompts in wallets like MetaMask, and EIP-2612 for gasless permit approvals.

Finally, a complete solution requires a front-end dApp and backend indexer. The dApp, built with frameworks like React and ethers.js, allows users to connect their wallet, view their stake, and sign transactions. A backend service is needed to index on-chain events from your staking contracts to display historical data and calculate real-time APY. For production readiness, you must plan for upgrades using proxy patterns, integrate monitoring with tools like Tenderly, and ensure compliance with the specific staking rules of your target blockchain. The end result is a self-sovereign financial primitive that aligns with Web3's core ethos.

key-management-options
NON-CUSTODIAL STAKING

Secure Key Generation and Storage Options

For a non-custodial staking solution, the security of validator keys is paramount. This guide covers the tools and best practices for generating, encrypting, and storing keys without relying on a third party.

03

Distributed Key Generation (DKG)

Distributed Key Generation (DKG) protocols like Shamir's Secret Sharing or Multi-Party Computation (MPC) eliminate single points of failure. No single party ever has access to the complete private key. Libraries such as tss-lib or services like Fireblocks and Qredo implement MPC for threshold signing.

  • Threshold Schemes: Define a quorum (e.g., 3-of-5) required to sign a transaction.
  • Application: Useful for staking pools or DAO-controlled validators where key control is distributed among members.
  • Network Overhead: DKG introduces communication complexity but provides superior security for collective ownership.
04

Secure Keystore Management

After generation, encrypted keystores (.json files) must be stored securely. Never store the unencrypted mnemonic or private key digitally.

  • Air-Gapped Generation: Perform key generation on a machine permanently disconnected from the internet.
  • Encrypted Backups: Store keystores on encrypted, offline media (e.g., encrypted USB drives) in geographically separate physical locations.
  • Password Management: Use a strong, unique password for each keystore, managed by a tool like Bitwarden or 1Password. Never reuse passwords.
06

Monitoring and Key Rotation

Proactive monitoring and key rotation are critical for long-term security. Use tools like Ethereum 2.0 Client Diversity monitors and set up alerts for missed attestations.

  • Health Checks: Monitor disk space, memory, and sync status of your validator client and remote signer.
  • Key Rotation Plan: Have a documented process for rotating validator keys if a compromise is suspected. This involves generating new keys with a new mnemonic and exiting the old validator.
  • Exit Scenarios: Understand the voluntary exit process and keep your mnemonic secure for the ~27-hour withdrawal period after exiting.
ARCHITECTURE SELECTION

Comparison of Delegation and Restaking Protocols

Key differences between building on a delegation protocol like Lido or Rocket Pool versus an EigenLayer AVS.

Feature / MetricLiquid Staking (Lido)Solo Staking Pool (Rocket Pool)Restaking (EigenLayer AVS)

Custodial Model

Non-custodial for staker

Non-custodial for staker

Non-custodial for staker

Node Operator Control

Permissioned, DAO-curated

Permissionless, bonded

Permissioned, AVS-curated

Smart Contract Complexity

High (oracle, DAO, staking)

Very High (bonded minipools, slashing)

Extreme (dual-slashing, AVS integration)

Time to Mainnet

6-12 months

9-18 months

12-24 months

Native Token Required

Slashing Risk

Operator-specific

Operator + Protocol-wide

Operator + AVS + Ethereum

Revenue Streams

Staking rewards, MEV

Staking rewards, MEV, RPL rewards

Staking rewards, AVS service fees

Avg. Protocol Fee

10% of rewards

14-20% of rewards

5-15% of AVS rewards

step-1-key-generation
FOUNDATION

Step 1: Generating and Securing Validator Keys

The security of a non-custodial staking solution begins with the secure generation and management of validator keys. This step is critical, as losing these keys means permanently losing control of your staked assets.

Validator keys are cryptographic key pairs that grant the right to operate a node on a Proof-of-Stake (PoS) network. The two primary keys are the withdrawal key and the signing key. The withdrawal key, often derived from your mnemonic seed phrase, controls the staked funds and is used for exiting the validator. The signing key, generated from the withdrawal key, is used for day-to-day block proposal and attestation duties. For Ethereum validators, these are BLS12-381 keys generated using the official Ethereum staking-deposit-cli tool.

The generation process must occur in a secure, air-gapped environment to prevent key exposure. Using the deposit CLI, you specify the network (e.g., --chain mainnet), the number of validators, and your withdrawal address. The tool outputs two files: the deposit_data.json for the initial 32 ETH deposit and the keystore-m files (encrypted signing keys). Crucially, the mnemonic seed phrase is displayed only once—this phrase is the ultimate backup for all your validator keys and must be written down and stored offline in multiple secure locations.

Key security follows a principle of least privilege. The encrypted keystore files, protected by a strong password, are what your validator client (like Lighthouse or Prysm) needs to run. The password should be unique and managed separately. The mnemonic and withdrawal keys should never touch an internet-connected machine. For operational security, consider using a distributed key generation (DKG) ceremony or a tool like ethdo to create "offline" withdrawal credentials, further separating the keys that control funds from those used for signing.

step-2-smart-contract-delegation
CORE ARCHITECTURE

Step 2: Designing the Delegation Smart Contract

This section details the core logic and security considerations for building a non-custodial staking contract that allows users to delegate assets to a trusted operator.

A non-custodial delegation contract acts as a trust-minimized intermediary between a user's funds and a staking operator. Its primary functions are to securely accept user deposits, track individual stakes, and facilitate the delegation of the pooled stake to a designated validator or node operator. Unlike custodial solutions, the contract never transfers ownership of the underlying assets; it only grants staking rights. This design is critical for protocols like Ethereum's liquid staking (e.g., Lido's early architecture) or Cosmos SDK-based chains where delegation is a native function.

The contract state must meticulously track each user's contribution. This typically involves a mapping, such as mapping(address => uint256) public userShares;, which records a user's share of the total pooled assets. When rewards are generated by the external validator, they are added to the pool, and each user's share becomes redeemable for a larger portion of the total. This share-based system, similar to ERC-4626 vaults, avoids the need to manage individual reward streams and ensures fair, proportional distribution.

The most sensitive function is the delegation call itself. The contract must have a secure, permissioned method (e.g., function delegateToOperator(address operatorAddress) external onlyOwner) that calls the underlying chain's staking interface. For example, on Ethereum, this would interact with the DepositContract for Beacon Chain ETH, while on Cosmos, it would call the MsgDelegate message. A major security consideration is preventing re-delegation or slashable actions without a governance mechanism, as this could risk user funds.

Withdrawal requests in a non-custodial system must account for the unbonding period of the underlying chain. The contract cannot immediately return assets if they are locked in a validator. A common pattern is to implement a withdrawal queue or a cooldown period. When a user requests to withdraw, their shares are marked for redemption, and after the chain's native unbonding period (e.g., 7 days for Cosmos, variable for Ethereum withdrawals), the user can claim their underlying assets plus accrued rewards.

To enhance security and composability, the contract should emit clear events for all key actions: Deposited, Delegated, WithdrawalRequested, Claimed. Using a standardized interface allows front-ends and indexers to easily track contract state. Furthermore, integrating with a slashing insurance module or a multi-signature guardian for the delegateToOperator function can provide additional safety rails, making the system resilient against operator key compromise or protocol-level slashing events.

step-3-operator-interface
IMPLEMENTATION

Step 3: Building the Operator Signing Interface

This step details the core off-chain component that securely signs validator duties on behalf of the user's staked funds, enabling non-custodial participation.

The Operator Signing Interface is the off-chain service that acts as the user's delegate for validator operations. Its primary function is to securely generate the signatures required for Ethereum consensus duties—attestations, block proposals, and sync committee participation—without ever having direct custody of the user's staking keys. This is achieved by implementing the standard Beacon Node API endpoints defined in the Ethereum Beacon APIs specification. The operator must respond to requests from a consensus client (like Lighthouse or Teku) for signatures, using the private keys it is authorized to manage.

Security is paramount. The signing keys, derived from the user's withdrawal credentials, must be stored and used in a highly secure environment, typically a Hardware Security Module (HSM) or a secure, air-gapped signing service. The interface itself should run in a trusted execution environment with strict access controls. It must only sign messages for the specific validator duties it is authorized for, and should implement robust slashing protection by checking a local or shared database to prevent signing conflicting messages that could lead to the validator's stake being penalized.

Here is a simplified conceptual example of how the operator might handle a request to sign an attestation, using a pseudo-API structure:

code
POST /eth/v1/validator/attestation/{validator_pubkey}
{
  "data": {
    "slot": "123456",
    "index": "3",
    "beacon_block_root": "0xabc...",
    "source": {...},
    "target": {...}
  }
}

The operator would:

  1. Validate the request structure and the validator's active status.
  2. Query its slashing protection database to ensure signing this (slot, index) is safe.
  3. Retrieve the corresponding private signing key from its secure store.
  4. Construct the signing root from the provided data and sign it with the key.
  5. Return the signature in the expected API response format.

Integrating with a consensus client requires the operator to be specified in the client's configuration. For Prysm, you would set the --validators-external-signer-url flag to point to your operator's API endpoint. The client will then route all signing requests for the managed validators to your service. The operator must also expose a health check endpoint and a GET /eth/v1/keystores endpoint to list the public keys it manages, allowing the beacon node to verify which validators it should request signatures for.

Beyond basic signing, a production-grade operator should include monitoring for missed duties, detailed logging of all signing events, and alerting systems. It must be designed for high availability to ensure validators perform their duties consistently, avoiding inactivity leaks. The final architecture decouples the staked ETH (safely in the beacon chain deposit contract) from the operational risk, allowing users to change or withdraw their operator without moving their underlying stake.

step-4-integration-eigenlayer
IMPLEMENTATION

Step 4: Integrating with EigenLayer for Restaking

This guide details the technical process of integrating a non-custodial staking solution with EigenLayer's restaking primitives.

Integrating with EigenLayer involves interacting with its core smart contracts to enable users to restake their ETH or LSTs. The primary contract is the StrategyManager, which manages deposits into individual strategies (like stETH or cbETH), and the DelegationManager, which handles the delegation of that stake to operators or services like yours. Your first step is to decide on the restaking asset—native ETH via the EigenPod, or a liquid staking token (LST). For LSTs, you'll interact with the specific strategy contract deployed by EigenLayer.

For a non-custodial design, your protocol must never hold user staking keys. Instead, users interact directly with EigenLayer contracts after approving your service as an operator via the DelegationManager. The typical flow is: 1) User approves token spend for the relevant EigenLayer strategy, 2) User deposits into the strategy via StrategyManager.depositIntoStrategy, 3) User delegates their shares to your operator address using DelegationManager.delegateTo. Your backend then monitors these on-chain events to track user stakes within your system.

Your smart contract or off-chain service must implement slashing response logic. When EigenLayer's slashing conditions are met and a slash is proposed, your designated slasher address must call DelegationManager.freezeOperator and later slashShares. As an Actively Validated Service (AVS), you define the fault conditions. For example, a proof-of-custody AVS might slash an operator for failing to submit a required attestation. Your contract must verify these conditions on-chain before initiating the slash.

Here is a simplified code snippet for a contract that allows a user to delegate to your operator, assuming the user has already deposited into a strategy:

solidity
// SPDX-License-Identifier: MIT
import "@eigenlayer/contracts/interfaces/IDelegationManager.sol";

contract RestakingIntegrator {
    IDelegationManager public immutable delegationManager;
    address public myOperatorAddress;

    constructor(address _delegationManager, address _myOperatorAddress) {
        delegationManager = IDelegationManager(_delegationManager);
        myOperatorAddress = _myOperatorAddress;
    }

    function delegateToMyOperator() external {
        delegationManager.delegateTo(myOperatorAddress);
    }
}

This contract lets a user call delegateToMyOperator(), which delegates their entire stake balance to your service.

After integration, you must manage withdrawals. EigenLayer enforces a 7-day withdrawal delay for security. Users initiate a withdrawal request through the DelegationManager.queueWithdrawal function. Your service must monitor the completion period and, if operating an AVS, ensure the user's stake is not slashed during this window. Failed AVS tasks can lead to slashing, which would reduce the user's withdrawable amount. Always reference the latest contract addresses on the EigenLayer Docs.

Key considerations for production include gas optimization for batch operations, implementing off-chain indexers to track user shares and delegation status, and setting up a robust slashing alert system. Test thoroughly on the Holesky testnet, where EigenLayer maintains a full deployment. This integration transforms your staked ETH from a passive asset into cryptoeconomic security actively backing your protocol's operations.

DEVELOPER FAQ

Frequently Asked Questions

Common technical questions and solutions for building non-custodial staking protocols, covering smart contract architecture, security, and integration.

A non-custodial staking contract's architecture centers on a validator registry and a delegation manager. The core contract never takes custody of user funds. Instead, it holds a record of stakes mapped to user addresses. When a user stakes, tokens are transferred to the contract but remain under the user's cryptographic control via a shares-based accounting system.

Key components include:

  • Staking Token Interface: ERC-20 for the asset being staked (e.g., stETH, AAVE).
  • Rewards Distributor: Calculates and allocates yields, often using a "reward per token" cumulative counter.
  • Slashing Condition Manager: Contains logic for penalizing malicious validators without requiring admin key custody.
  • Withdrawal Queue/Validator Exit: Handles the unbonding period, ensuring users can withdraw their principal after a delay (e.g., 7 days on Ethereum).

This design ensures users maintain ownership, with the contract acting as a transparent ledger and rule enforcer.

conclusion
IMPLEMENTATION GUIDE

Conclusion and Next Steps

You have built the core components of a non-custodial staking solution. This section summarizes the key security and operational considerations for launching and maintaining your protocol.

Implementing a non-custodial staking solution requires a security-first mindset. The primary technical takeaways are the separation of concerns between your StakingPool and RewardDistributor contracts, the use of battle-tested libraries like OpenZeppelin for access control and math, and rigorous validation of all user inputs. Your smart contracts should undergo multiple audits from reputable firms like Trail of Bits or ConsenSys Diligence before any mainnet deployment. A comprehensive test suite covering edge cases—such as zero-value stakes, reward calculation rounding, and malicious withdrawal attempts—is non-negotiable.

Beyond the smart contracts, your frontend and backend infrastructure must be equally robust. The dApp interface should clearly communicate staking terms, APY calculations, and the risks involved. Use wallet connection libraries like WalletConnect or Web3Modal for a seamless user experience. Your backend needs reliable node providers (e.g., Alchemy, Infura) to broadcast transactions and index on-chain events for displaying user history. Implement a failover system to handle RPC endpoint outages.

For ongoing operations, you must establish clear processes for managing the protocol treasury and updating parameters. Consider implementing a timelock controller for any administrative functions, such as adjusting reward rates or pausing deposits, to give users transparency and reaction time. Monitor key metrics like total value locked (TVL), average stake duration, and contract gas usage. Engage with your community through governance forums to propose and vote on upgrades, ensuring the protocol evolves in a decentralized manner.

Your next steps should be methodical. 1) Deploy to a testnet (Goerli, Sepolia) and conduct a bug bounty program. 2) Finalize and publish a detailed technical documentation site using tools like Docusaurus or Mintlify. 3) Plan a phased mainnet launch, potentially starting with a whitelist of users. 4) Explore integrations with DeFi aggregators (like DefiLlama) and wallet dashboards to increase visibility. Remember, trust is earned through transparency and consistent, secure operation over time.