Ethereum Staking API
1 Stake
Staking ETH through the InfStones Safe Stake SDK involves a straightforward process: users stake a multiple of 32 ETH and are provided with an activity ID. This activity ID can be utilized to access the raw transaction which users can then sign and broadcast to complete the staking process seamlessly.
1.1 Stake
We charge a monthly maintenance fee of $19 for each Ethereum validator. To cover this monthly validator maintenance fee, users are required to add a credit card or reload their account credit on our platform.
Through stake
API, users can stake ETH with their preferred payment method and get the activity ID.
Request
curl -X 'POST' \
'https://stakingapi.infstones.com/ethereum/stake' \
-H 'x-api-key: <access_token>' \
-H 'Content-Type: application/json' \
-d '{
"wallet": "<your_ethereum_wallet_address>",
"amount": "<stake_amount>",
"payment_method": "<payment_method>",
"withdrawal_credentials": "<your_withdrawal_credential_address>"
}'
<stake_amount>
should be a multiple of 32.
<payment_method>
should becredit_card
oraccount_credit
.
Response
{
"data": "3c3fb988-6dbb-475c-ac8c-185023a69060"
}
1.2 Get Raw Transaction
Open GraphQL Playground, users can retrieve the raw transaction associated with the activity ID from 1.1 Stake
.
Step 1: Input your access token in the Headers
section.
Step 2: Input the activity ID and run the command, and you will get the response with raw_tx
.
Request
{
get_activity(id:"3c3fb988-6dbb-475c-ac8c-185023a69060") {
activity {
wallet
amount
raw_tx
activity_status
}
}
}
Response
{
"data": {
"get_activity": {
"activity": [
{
"wallet": "0xf404571702cf424174a3badaba7906b6651a8afe",
"amount": "32",
"raw_tx": "{\"from_address\":\"0xf404571702cf424174a3badaba7906b6651a8afe\",\"to_address\":\"0xA4C31ed561f14151AC1849C6dC5B9D56d96af32c\",\"value\":\"0x1bc16d674ec800000\",\"data\":\"0xc82655b7000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000030b2821389947270af9fa95ffdf486eaff211a4a19258fd59271d1788e131b29a549556304b4127b972a310dc7cb437656000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020010000000000000000000000f404571702cf424174a3badaba7906b6651a8afe0000000000000000000000000000000000000000000000000000000000000060a77cb61846a815a05b244a642be0515e077c50f18336e0838d2d8b04210234ae711f7b6a90fae199fc282b2cb06ffc1c18dc0d8fb3dc96d0cce4895fcb8c08c4069e580cd77b12ad6cb6ad4d5410cb1d590c16ad58a33bac8a82baa72dee671600000000000000000000000000000000000000000000000000000000000000015c9df10abf9c31c91eee18e6edbc02e77b7b6d0b396fc1839cab7986916b8f8d\",\"gas_limit\":\"\"}",
"activity_status": "completed"
}
]
}
}
}
The activity status
completed
means the transaction details are fully prepared and ready for the next stepSign Transaction and Broadcast
.
1.3 Sign Transaction and Broadcast
Users can sign the raw transaction using their own wallet's private key and broadcast it to complete the staking process.
Follow the instructions to get your Ethereum Fast API endpoint.
import Web3 from "web3"
const web3 = new Web3("<ethereum_endpoint>") // Replace this with your Ethereum Fast API endpoint
const wallet = {
privateKey:
"<your_ethereum_wallet_private_key>",
address: "<your_ethereum_wallet_address>",
}
try {
console.log(`Attempting to send transaction from ${wallet.address} to ${addressTo}`)
//Sign tx with Private Key
const txCount = await web3.eth.getTransactionCount(wallet.address)
const nonce = await web3.utils.toHex(txCount)
const gasPrice = await web3.eth.getGasPrice();
let rawTx = {
nonce: nonce,
to: "0x3070eb0eac184cb84e825dfff97070521424accd", // This is InfStones Ethereum Staking Smart Contract Address
value: "<value>", // Retrieved from activity
data: "<data>", // Retrieved from activity
}
const estimateGas = await web3.eth.estimateGas(rawTx)
rawTx = { ...rawTx, gas: estimateGas.toString(), gasPrice: gasPrice.toString()}
const createTransaction = await web3.eth.accounts.signTransaction(
rawTx,
wallet.privateKey
)
//Send tx and wait for receipt
const createReceipt = await web3.eth.sendSignedTransaction(
createTransaction.rawTransaction
)
console.log(
`Transaction successful with hash: ${createReceipt.transactionHash}`
)
} catch (error) {
console.log(error)
}
Follow the instructions to sign Ethereum transaction with Ledger.
2 Unstake
Unstaking ETH through the InfStones Safe Stake SDK involves a straightforward process: users sign a message and are provided with a signature. This signature can be utilized to unstake a multiple of 32 ETH and generate an activity ID which can be used to retrieve the activity status.
2.1 Sign Message
Users can sign the message
using their own wallet's private key and get the signature.
Request
import Web3 from "web3"
const web3 = new Web3("<ethereum_mainnet_endpoint>") // Replace this with your Ethereum Fast API endpoint
const wallet = {
privateKey:
"<your_ethereum_wallet_private_key>",
address: "<your_ethereum_wallet_address>",
}
try {
const message = {validators: ["<ethereum_validator_address_1>","<ethereum_validator_address_2>"]}
const msgStr = JSON.stringify(message);
let res = await web3.eth.accounts.sign(msgStr, "0x"+wallet.privateKey)
console.log(res.signature)
} catch (error) {
console.log(error)
}
message
should include vallidator address information.
Response
0xb51cef2fc78552464c4632c0bf2f9cfd6c583daedbb4627bc65ff35404cabf9254191d7f7cf6674b9f8a8a31519190a345460a13a8577f2b819f106958320df31c
Follow the instructions to sign Ethereum message with Ledger.
2.2 Unstake
Through unstake
API, users can unstake a multiple of 32 ETH using the signature from 2.1 Sign Message
and get the activity ID.
Request
curl -X 'POST' \
'https://stakingapi.infstones.com/ethereum/unstake' \
-H 'x-api-key: <access_token>' \
-H 'Content-Type: application/json' \
-d '{
"wallet": "<your_ethereum_wallet_address>",
"amount": "<unstake_amount>",
"data": {
"message": "{\"validators\":[\"<ethereum_validator_address_1>\",\"<ethereum_validator_address_2>\"]}",
"signature": "0xb51cef2fc78552464c4632c0bf2f9cfd6c583daedbb4627bc65ff35404cabf9254191d7f7cf6674b9f8a8a31519190a345460a13a8577f2b819f106958320df31c"
}
}'
<unstake_amount>
should be a multiple of 32.
Response
{
"data": "0d24dcd9-d837-4095-8ad5-553ef1ddfe53"
}
2.3 Get Activity Status
Open GraphQL Playground, users can retrieve the activity status with the activity ID from 2.2 Unstake
.
Request
{
get_activity(id:"0d24dcd9-d837-4095-8ad5-553ef1ddfe53") {
activity {
activity_status
}
}
}
Response
{
"data": {
"get_activity": {
"activity": [
{
"activity_status": "completed"
}
]
}
}
}
The activity status
completed
means that the unstaking operation has been fully executed and confirmed.
3 Claim Reward
Claiming reward through the InfStones Safe Stake SDK involves a straightforward process: users sign a message and are provided with a signature. This signature can be utilized to claim reward and generate an activity ID which can be used to retrieve the activity status. Please note that we charge a real-time withdrawal fee for each claim reward transaction. Users can get the real-time withdrawal fee through thewithdrawal_fee
API.
3.1 Get Withdrawal Fee
Through withdrawal_fee
API, users can get the current withdrawal fee value using their <access_token>
.
Request
curl -h 'x-api-key: <access_token>' https://stakingapi.infstones.com/ethereum/withdrawal_fee
Response
{data:"0.00000089"}
Withdrawal fee updates in real time. It is recommended to check that your rewards are sufficient to pay the withdrawal fee before claiming reward.
3.2 Sign Message
Users can sign the message
using their own wallet's private key and get the signature.
Request
import Web3 from "web3"
const web3 = new Web3("<ethereum_mainnet_endpoint>") // Replace this with your Ethereum Fast API endpoint
const wallet = {
privateKey:
"<your_ethereum_wallet_private_key>",
address: "<your_ethereum_wallet_address>",
}
try {
const message = {validator: "<ethereum_validator_address>"}
const msgStr = JSON.stringify(message);
let res = await web3.eth.accounts.sign(msgStr, "0x"+wallet.privateKey)
console.log(res.signature)
} catch (error) {
console.log(error)
}
message
should include vallidator address information.
Response
0xe958b44df4181c698f1a7d3ca6e14c99f1b1753136daee3444fc880db729e40300ca4f15a9f524635368e593f7899738881ecbc2902ca484f639fc86a00171e51b
Follow the instructions to sign Ethereum message with Ledger.
3.3 Claim Reward
Through claim
API, users can claim reward using their <access_token>
and get the activity ID.
Request
curl --location 'https://stakingapi.infstones.com/ethereum/claim' \
-H 'x-api-key: <access_token>' \
-H 'Content-Type: application/json' \
-d '{
"wallet": "<your_ethereum_wallet_address>",
"data": {
"message": "{\"validator\":\"<ethereum_validator_address>\"}",
"signature": "0xe958b44df4181c698f1a7d3ca6e14c99f1b1753136daee3444fc880db729e40300ca4f15a9f524635368e593f7899738881ecbc2902ca484f639fc86a00171e51b"
}
}'
Response
{
"data": "0168fc5a-8dc3-48b3-b879-304a6368058c"
}
3.4 Get Activity Status
Open GraphQL Playground, users can retrieve the activity status with the activity ID from 3.3 claim reward
.
Request
{
get_activity(id:"0168fc5a-8dc3-48b3-b879-304a6368058c") {
activity {
activity_status
}
}
}
Response
{
"data": {
"get_activity": {
"activity": [
{
"activity_status": "completed"
}
]
}
}
}
The activity status
completed
means that the process of claiming reward has been confirmed, and the reward will be distributed to your wallet in approximately 24 hours.
Updated 23 days ago