Pooled Staking
Staking on the Ethereum network involves locking up tokens to support the network's security and operations. In return, stakers earn rewards.
The Chorus One SDK simplifies the staking process on the Ethereum network, providing developers with the tools needed to build, sign, and broadcast staking transactions.
To enhance efficiency, the SDK leverages Stakewise V3's audited and secure smart contracts. By utilizing a pooling solution, it allows multiple users to combine their stakes, making staking more accessible and beneficial for smaller stakeholders.
This guide will walk you through the fundamentals of staking on Ethereum using the Chorus One SDK.
Understanding Key Concepts
Setting Up the Staker
To get started with staking on the Ethereum network using the Chorus One SDK, you will first need to initialize the SDK.
Note: For testing purposes, we will use the Hoodi testnet.
First, create an instance of EthereumStaker with the necessary configuration:
Configuration Parameters:
network: The Ethereum network to connect to. It can be
mainnetorhoodi.rpcUrl: (Optional) The URL of the Ethereum network RPC endpoint. This is where the SDK will connect to interact with the network. If not provided, the SDK will use the public RPC endpoint for the specified network.
Initializing the Staker
After configuring the EthereumStaker, initialize it to prepare for staking operations.
This can be done via the following input:
The init method establishes a connection with the configured RPC endpoint and prepares the staker for operations such as building and broadcasting transactions.
Building Transactions
Once the staker is set up, you can start building transactions for staking operations.
The EthereumStaker class provides methods to build transactions for staking, unstaking, merging and splitting stakes, and creating stake accounts.
You can learn more about these methods in the Methods section.
Example of building a staking transaction:
Ensuring Correct Amount Format for Staking
The amount parameter must be a string representing the amount of ETH to deposit. For example, '1' represents 1 ETH.
If you have the amount as a bigint, convert it to a string using the formatEther function from viem. Example:
This ensures the amountToStake parameter is in the correct format for the staking transaction function.
Getting the Validator Address provided by Chorus One
The @chorus-one/ethereum module includes a list of Chorus One validators for the Ethereum-compatible chains, organized by network(ethereum or hoodi) and vault type. You can use these addresses when building transactions.
Vault Types
MEV Max Vault (mevMaxVault): This vault employs Chorus Oneβs proprietary MEV Research to maximize staking returns by optimizing transaction ordering.
Obol Distributed Validator Technology (obolDvVault): This vault uses Obol's DVT to enhance resilience and decentralization of Ethereum staking by distributing validator duties across multiple nodes.
Signing the Transaction
Once the transaction is built, you can sign that transaction using your own signing solution e.g.:
When using your own signer, you will need to calculate the transaction fees yourself before signing.
Additionally, you can use the Chorus One SDK to sign transactions using Fireblocks, mnemonic or other methods.
For detailed information on setting up and configuring these options, please refer to the What is a Signer? section.
By integrating wagmi, you can take advantage of its lightweight developer-friendly wallet client capabilities to sign transactions on the Ethereum network:
For more information please refer to the Viem Documentation
By integrating Ethers, you can use its widely adopted and feature-rich library for signing transactions on the Ethereum network:
For more information please refer to the Ethers Documentation
By integrating Fireblocks, you can leverage its robust security features to sign transactions on the Ethereum network. To set up Fireblocks, you will need to provide the necessary API key, secret key, and vault ID:
Configuring Transaction Fees
When signing transactions, you can optionally configure the fees to manage cost and priority. The fees parameter allows you to specify a baseFeeMultiplier and a defaultPriorityFee.
baseFeeMultiplier: (Optional) This multiplier helps manage fee fluctuations by adjusting the base fee per gas from the latest block. For example, if thebaseFeeMultiplieris set to 2, the finalmaxFeePerGaswill be 2 times the base fee. The default value is 1.2.defaultPriorityFee: (Optional) This value allows you to override themaxPriorityFeePerGasestimated by the RPC. You can specify a fixed value to ensure that your transaction has a certain priority. By default, themaxPriorityFeePerGasis calculated by the RPC.
For more information please refer to the Signing with Fireblocks
Broadcasting the Transaction
After signing the transaction, you will need to broadcast it to the network. You can do this using the broadcast method:
And now you can track the transaction status:
Next Steps
In this section you learned how to set up the Chorus One SDK for the Ethereum network using the Hoodi testnet, which included how to build staking transactions, sign, broadcast, and track them.
To learn more about the available methods on
EthereumStakercontinue to the Methods section.
Further Reading
Last updated
Was this helpful?