Integrate Native ETH Staking to Your Web3 Product: A Step-by-Step Guide

In the dynamic realm of Web3 technologies, RockX is spearheading a revolution with its innovative Native ETH Staking API integration, designed to democratize ETH staking for a broader audience while empowering institutions to tailor the staking experience to their unique needs. This pioneering approach not only simplifies the integration process for institutional clients like Amber Group and Cactus Custody but also opens up avenues for them to customize and enhance their offerings, bringing the benefits of ETH staking to more customers with unparalleled ease and security. Through this guide, we will navigate the intricacies of incorporating RockX’s Native ETH Staking Solutions into your Web3 product, ensuring a seamless, secure, and personalized staking journey for your end-users.

Get Started With API Integration

Step 1: Register a RockX account via https://sso.rockx.com for Mainnet;  or https://beta-sso.rockx.com for Testnet environment

Step 2: Create an API token (RockX will assign a test token for Testnet environment)

Step 3: Prepare an ETH wallet with at least 32.5 ETH to support at least one validator and gas fees

Step 4: Prepare 1 – 2 ETH wallets to receive fee recipient/ MEV rewards and staking rewards

Environment Information

Different API token applies per ENV

MainnetTestnet (Goerli)Testnet (Holesky)
SSOhttps://sso.rockx.comhttps://beta-sso.rockx.com
Staking Portal URLhttps://stake.rockx.com/https://beta-stake.rockx.com/
Staking API URL “STAKE_API”https://stake-api.rockx.com/api/v2/eth2https://beta-stake.rockx.com/api/v2/eth2
Query Validatorhttps://stake-api.rockx.com/api/v1/eth2/validator/listhttps://beta-stake-api.rockx.com/api/v1/eth2/validator/list
Stake Contract https://etherscan.io/address/0xe8239B17034c372CDF8A5F8d3cCb7Cf1795c4572https://goerli.etherscan.io/address/0x2176FF25DBcd2FA1E61184cdb1Be2644EA90862A
Reward Pool Contracthttps://etherscan.io/address/0xb7019c9184580b2E1f66fCDc3EB6c62621732064https://goerli.etherscan.io/address/0xaD13252977ec93F8Ce36c918F5882B81c427A23B

ETH Native Staking Flow

User Guide To Stake via API

Prepare an API call payload

First, prepare an API call payload in multiples of 32 ETH as each validator key will require 32 ETH to stake. In this example, we will assume a single validator key (count = 1), hence, you are required to prepare a 32 ETH call payload.

Step 1: Prepare the API payload

curl -X POST -d '{
  "claim": "$TX_FEE_REWARDS_RECIPIENT_ADDRESS",
  "count": 1,
  "withdraw": "$WITHDRAWAL_ADDRESS"
}' -H "Authorization:Bearer $TOKEN" 
https://stake-api.rockx.com/api/v1/eth2/order/add

Step 2: Replace the variables accordingly and make the HTTPS API call 

Field nameTypeMandatory?DescriptionNotes
TOKENstringYesThe access token of API user
dataclaimstringYesThe claimAddress used to claim transaction fee rewards and MEV rewards, user must ensure the ownership of this addressUser must ensure the ownership of this address
countintYesThe number of validator keys user intends to stakeRange: 1-100
withdrawstringYesThe withdrawal address that exit the ETH validatorUser must ensure the ownership of this address

Step 3: Upon successful API call, a standard JSON format response will be returned with the following data structure:

Field nameTypeDescriptionNotes
codestringHTTP status code

message
stringMessage returned from server
datapubkeysarrayList of pubkeys created for stakingMust keep the sequence as it is 
signaturesarrayList of signatures used for each pubkeyMust keep the sequence as it is 
paramsSigstringThe verification signature
extradataintReserved data

Step 4: Take the return values and prepare the contract call. To illustrate it in a natural way, the demonstration is made via etherscan contract call as below:

Stake and Connect Process

Once the API call payload and necessary setup are established, you may commence the staking and wallet connecting process. 

Step 1: Go to Stake Contract 


Via Mainnet: https://etherscan.io/address/0xe8239B17034c372CDF8A5F8d3cCb7Cf1795c4572#writeProxyContract
Via Testnet:
https://goerli.etherscan.io/address/0x2176FF25DBcd2FA1E61184cdb1Be2644EA90862A#writeProxyContract

Connect your Metamask wallet by filling up the parameters accordingly in function “13.stake” for Mainnet; “11.stake” for Testnet

ParameterDescriptionExample value
stakeThe amount of ETH user to stake, it must be identical with the count in the API call in step #1, else the contract call will fail32, 64… the 32 times the count in the API call in step #1
claimaddrThe address to claim tx recipient / MEV rewards, can be the same as deposit addresss0x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93
withdrawaddrThe withdrawal address and staking rewards address, can be the same as deposit addresss0x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93
pubkeysThe list of pubkeys obtained from the API call in step #1[0xb5f9e9368e937a9fc9ea640c337ccc5e549724bc7fcf1c319d94f37626c9a505e73e2b45ccfd2070940f476cc88001d6]
signaturesThe list of signatures obtained from the API call in step #1[0x9168a2f3d14ee8b5d2967bcc51b14ff4a6f3783de29cc3d396233a30d7ad707c00e633413ac7c10c8a1d993efdcdcfd70420ef63259cd0b9b840c43bc3be3858a85824250802efff217e90cad506bc8e1c63bf9ca1d016fe99e52dc7a386a69e]
paramsSigThe params signature returned from the API call in step #1, must be the same as what is returned0xf33d630533af372fb5d1b388256caa86878aeacacac594cd90b262846679655c6c06e640e2c06abc5a2a4c7883bbc4bc87d38c808e0208ceee08dbe3a8d1430b1c
extradataThe extradata returned from the API call in step #1, must be the same as what is returned11828
tipThe reserved data field0

Upon successful contract call, staking is completed. It will usually take 1-2 days or more for the validator to be active, depending on the queue of pending validators in ETH network.

Step 2: Check the status via https://beaconcha.in/validator/${pubkey} for Mainnet; https://goerli.beaconcha.in/validator/${pubkey} for Testnet. The pubkey is returned from the previous API call

  1. Check claimable rewards via Reward Pool Contract
    Mainnet:
    https://etherscan.io/address/0xb7019c9184580b2E1f66fCDc3EB6c62621732064#readProxyContract
    Testnet:
    https://goerli.etherscan.io/address/0xaD13252977ec93F8Ce36c918F5882B81c427A23B#readProxyContract 
  • Fill up the parameters accordingly in function “7.getPendingReward
ParameterDescriptionExample value
claimaddr (address)The claim address provided in the API call #10x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93
  1. Claim rewards via Reward Pool Contract
    Mainnet:
    https://etherscan.io/address/0xb7019c9184580b2E1f66fCDc3EB6c62621732064#writeProxyContract
    Testnet:
    https://goerli.etherscan.io/address/0xaD13252977ec93F8Ce36c918F5882B81c427A23B#writeProxyContract
  • Fill up the parameters accordingly in function “1.claimRewards
ParameterDescriptionExample value
beneficiary (address)Any address that you have access to receive the rewards0x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93
amountThe amount of ETH rewards to claim100000000000000000
  1. Query validator info in Stake Contract
    Mainnet:
    https://etherscan.io/address/0xe8239B17034c372CDF8A5F8d3cCb7Cf1795c4572#readProxyContract
    Testnet:
    https://goerli.etherscan.io/address/0x2176FF25DBcd2FA1E61184cdb1Be2644EA90862A#readProxyContract
  • Fill up the parameters accordingly in function “11.getValidatorInfos”
  • Map the pubkeys returned to determine the validatorId
ParameterDescriptionExample value
fromThe starting Id for query1
toThe ending Id for query5

Validator Status tracking

Validators status such as staking rewards, tx fee rewards, validator status etc can be tracked. There are 2 ways to get the latest data of validator status:

  1. Staking Dashboard
  2. Query via API
  • Prepare the API payload
curl -X POST -d '{
    "searchKey":$SEARCHKEY,
    "keywords":$KEYWORDS,
    "status":[$STATUS]
}' -H "Authorization:Bearer $TOKEN"
https://stake-api.rockx.com/api/v1/eth2/validator/list
  • Replace the variables accordingly and make the HTTPS API call 
Field nameTypeMandatory?DescriptionNotes
TOKENstringYesThe access token of API user
datalimitintNoThe amount of results per queryUsed for pagination 
offsetintNoThe offset of the current query if limit is indicatedUsed for pagination 
statusarrayNoThe status to filter the transactions returnedEnum:pending,active,exit,slashed
searchKeystringNoThe search type for the keywordsEnum:”pubKey”, “withdrawAddress”, “claimAddress”, “validatorId”
keywordsstringNoThe info to search based on the searchKey givenFor example, search based on claimAddress, by passing in:
{“searchKey”:”claimAddress”,  “keywords”:”0x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93”,}
  • Upon successful API call, a standard JSON format response will be returned with the following data structure:
Field nameTypeDescriptionNotes
codestringHTTP status code

message
stringMessage returned from server
datatotalintThe amount of validators returned in current query
limitintThe amount of results per query
offsetintThe offset of the current query if limit is indicated
Data[]pubkeysstringList of pubkeys created for stakingMust keep the sequence as it is 
withdrawAddressstringThe withdrawal address to receive the staking rewards and 0x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93
claimAddressstringThe address to claim tx recipient / MEV rewards0x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93
validatorIndexintThe index of validator on-chain
validatorIdintThe index id of validators tracked in staking contract
balancestringThe eth balance of the validator
protocolRewardsstringThe staking rewards
activationintThe timestamp when validator was activated
statusstringThe validator statusEnum:pending,active,exit,slashed

Unstaking

Unstaking Flow Chart

Steps to unstake

There are 2 functions to exit the validator(s). To exit, the user will need to check the validatorId per pubkey accordingly.

  1. (Optional) Check the validatorId of the pubkey

There are 2 options to get the validatorId of the pubkey mentioned in above document:

  • Call staking contract function “11.getValidatorInfos
  • Query validator list API (Recommended)
  1. Withdrawal of a single validator
ParameterDescriptionExample value
claimaddr (address)Any address that you have access to receive the rewards0x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93
validatorIdThe validator Id you want to un-stake1
  1. Bulk withdrawal
  • To initiate the exit messages, the user must input claimaddr with the exact validatorIds 
  • Stake Contract 

Mainnet:
https://etherscan.io/address/0xe8239B17034c372CDF8A5F8d3cCb7Cf1795c4572#writeProxyContract
Testnet:
https://goerli.etherscan.io/address/0x2176FF25DBcd2FA1E61184cdb1Be2644EA90862A#writeProxyContract

  • Fill up the parameters accordingly in function “2.batchExit” for Mainnet; “1.batchExit” for Testnet
ParameterDescriptionExample value
claimaddr (address)Any address that you have access to receive the rewards0x333e6Ea9d938eC7a4ED0Cb7cc553f3c3fd386c93
validatorIdsThe validator Id you want to un-stake[1,2]

More APIs for Staking Management

MainnetTestnet (Goerli)Testnet (Holesky)
Staking OverviewGet Pending Queue Infohttps://stake-api.rockx.com/api/v2/eth2/pendingQueue/infohttps://beta-stake-api.rockx.com/api/v2/eth2/pendingQueue/infohttps://holesky-stake-api.rockx.com/api/v2/eth2/pendingQueue/info
Get summary of Total Rewardshttps://stake-api.rockx.com/api/v2/eth2/rewards/summaryhttps://beta-stake-api.rockx.com/api/v2/eth2/rewards/summaryhttps://holesky-stake-api.rockx.com/api/v2/eth2/rewards/summary
Get summary of Total Balancehttps://stake-api.rockx.com/api/v2/eth2/balance/summmaryhttps://beta-stake-api.rockx.com/api/v2/eth2/balance/summmaryhttps://holesky-stake-api.rockx.com/api/v2/eth2/balance/summmary
Get the list of Daily Rewardshttps://stake-api.rockx.com/api/v2/eth2/dailyRewards/listhttps://beta-stake-api.rockx.com/api/v2/eth2/dailyRewards/listhttps://holesky-stake-api.rockx.com/api/v2/eth2/dailyRewards/list
Get the list of Cumulative Rewardshttps://stake-api.rockx.com/api/v2/eth2/cumulativeRewards/listhttps://beta-stake-api.rockx.com/api/v2/eth2/cumulativeRewards/listhttps://holesky-stake-api.rockx.com/api/v2/eth2/cumulativeRewards/list
Get Annual Rewards Ratehttps://stake-api.rockx.com/api/v2/eth2/annualRewardsRate/summaryhttps://beta-stake-api.rockx.com/api/v2/eth2/annualRewardsRate/summaryhttps://holesky-stake-api.rockx.com/api/v2/eth2/annualRewardsRate/summary
Get the list of WIthdrawal Addresshttps://stake-api.rockx.com/api/v2/eth2/withdrawalAddress/listhttps://beta-stake-api.rockx.com/api/v2/eth2/withdrawalAddress/listhttps://holesky-stake-api.rockx.com/api/v2/eth2/withdrawalAddress/list
OrderAdd New Orderhttps://stake-api.rockx.com/api/v1/eth2/order/addhttps://beta-stake-api.rockx.com/api/v1/eth2/order/addhttps://holesky-stake-api.rockx.com/api/v1/eth2/order/add
Get Order Listhttps://stake-api.rockx.com/api/v1/eth2/order/listhttps://beta-stake-api.rockx.com/api/v1/eth2/order/listhttps://holesky-stake-api.rockx.com/api/v1/eth2/order/list
Delete Order Listhttps://stake-api.rockx.com/api/v1/eth2/order/deletehttps://beta-stake-api.rockx.com/api/v1/eth2/order/deletehttps://holesky-stake-api.rockx.com/api/v1/eth2/order/delete
Delete Order by Batchhttps://stake-api.rockx.com/api/v1/eth2/order/delete/batchhttps://beta-stake-api.rockx.com/api/v1/eth2/order/delete/batchhttps://holesky-stake-api.rockx.com/api/v1/eth2/order/delete/batch
Get Order Detailhttps://stake-api.rockx.com/api/v1/eth2/order/detailhttps://beta-stake-api.rockx.com/api/v1/eth2/order/detailhttps://holesky-stake-api.rockx.com/api/v1/eth2/order/detail
ValidatorGet Validator Listhttps://stake-api.rockx.com/api/v1/eth2/validator/listhttps://beta-stake-api.rockx.com/api/v1/eth2/validator/listhttps://holesky-stake-api.rockx.com/api/v1/eth2/validator/list
Get Validator Summaryhttps://stake-api.rockx.com/api/v1/eth2/validator/summaryhttps://beta-stake-api.rockx.com/api/v1/eth2/validator/summaryhttps://holesky-stake-api.rockx.com/api/v1/eth2/validator/summary
SummaryGet Summary of Staking of User Accounthttps://stake-api.rockx.com/api/v1/eth2/validator/summary/infohttps://beta-stake-api.rockx.com/api/v1/eth2/validator/summary/infohttps://holesky-stake-api.rockx.com/api/v1/eth2/validator/summary/info
Reward PoolGet Reward Pool Listhttps://stake-api.rockx.com/api/v1/eth2/rewardPool/listhttps://beta-stake-api.rockx.com/api/v1/eth2/rewardPool/listhttps://holesky-stake-api.rockx.com/api/v1/eth2/rewardPool/list
Get Reward Pool Historyhttps://stake-api.rockx.com/api/v1/eth2/rewardPool/historyhttps://beta-stake-api.rockx.com/api/v1/eth2/rewardPool/historyhttps://holesky-stake-api.rockx.com/api/v1/eth2/rewardPool/history
Get CSV file of Reward Pool Historyhttps://stake-api.rockx.com/api/v1/eth2/rewardPool/history/getCSVhttps://beta-stake-api.rockx.com/api/v1/eth2/rewardPool/history/getCSVhttps://holesky-stake-api.rockx.com/api/v1/eth2/rewardPool/history/getCSV
Get Reward Pool Summaryhttps://stake-api.rockx.com/api/v1/eth2/rewardPool/summaryhttps://beta-stake-api.rockx.com/api/v1/eth2/rewardPool/summaryhttps://holesky-stake-api.rockx.com/api/v1/eth2/rewardPool/summary
WithdrawalGet Withdrawal Historyhttps://stake-api.rockx.com/api/v1/eth2/withdrawal/historyhttps://beta-stake-api.rockx.com/api/v1/eth2/withdrawal/historyhttps://holesky-stake-api.rockx.com/api/v1/eth2/withdrawal/history
Get CSV file of Withdrawal Historyhttps://stake-api.rockx.com/api/v1/eth2/withdrawal/history/getCSVhttps://beta-stake-api.rockx.com/api/v1/eth2/withdrawal/history/getCSVhttps://holesky-stake-api.rockx.com/api/v1/eth2/withdrawal/history/getCSV
Get Withdrawal Summaryhttps://stake-api.rockx.com/api/v1/eth2/withdrawal/summaryhttps://beta-stake-api.rockx.com/api/v1/eth2/withdrawal/summaryhttps://holesky-stake-api.rockx.com/api/v1/eth2/withdrawal/summary
Get Withdrawal Validator Listhttps://stake-api.rockx.com/api/v1/eth2/withdrawal/listhttps://beta-stake-api.rockx.com/api/v1/eth2/withdrawal/listhttps://holesky-stake-api.rockx.com/api/v1/eth2/withdrawal/list
Get the list of Full Exited Withdrawn Validatorshttps://stake-api.rockx.com/api/v1/eth2/withdrawal/validators/listhttps://beta-stake-api.rockx.com/api/v1/eth2/withdrawal/validators/listhttps://holesky-stake-api.rockx.com/api/v1/eth2/withdrawal/validators/list

Conclusion

Integrating native ETH staking into your Web3 product with RockX’s comprehensive guide provides a streamlined, secure pathway to harnessing the full potential of ETH staking. This guide, enriched with practical steps, and environmental details, equips institutions with the necessary tools to customize and enhance their staking offerings. By following the outlined steps and leveraging RockX’s robust solutions, your institution can confidently navigate the complexities of ETH staking, ensuring a seamless experience for your clients and a solid foundation for your staking strategies.

For more information, you may contact our team directly, or read our case studies for a practical look at the application of the above information.

Total
0
Shares
Related Posts