Ethereum
Prepare Staking Transaction
Construct a serialized transaction to deposit the stake amount, utilizing the functionalities of P2P smart contract.
POST
/
api
/
v1
/
eth
/
staking
/
direct
/
tx
/
deposit
Prepare Staking Transaction
curl --request POST \
--url https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"withdrawalAddress": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb",
"depositData": [
{
"pubkey": "0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4",
"signature": "0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88",
"depositDataRoot": "0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C",
"withdrawalCredentials": "<string>",
"amount": 1024500000000
}
]
}
'import requests
url = "https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit"
payload = {
"withdrawalAddress": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb",
"depositData": [
{
"pubkey": "0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4",
"signature": "0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88",
"depositDataRoot": "0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C",
"withdrawalCredentials": "<string>",
"amount": 1024500000000
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
withdrawalAddress: '0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb',
depositData: [
{
pubkey: '0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4',
signature: '0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88',
depositDataRoot: '0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C',
withdrawalCredentials: '<string>',
amount: 1024500000000
}
]
})
};
fetch('https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'withdrawalAddress' => '0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb',
'depositData' => [
[
'pubkey' => '0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4',
'signature' => '0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88',
'depositDataRoot' => '0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C',
'withdrawalCredentials' => '<string>',
'amount' => 1024500000000
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit"
payload := strings.NewReader("{\n \"withdrawalAddress\": \"0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb\",\n \"depositData\": [\n {\n \"pubkey\": \"0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4\",\n \"signature\": \"0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88\",\n \"depositDataRoot\": \"0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C\",\n \"withdrawalCredentials\": \"<string>\",\n \"amount\": 1024500000000\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"withdrawalAddress\": \"0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb\",\n \"depositData\": [\n {\n \"pubkey\": \"0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4\",\n \"signature\": \"0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88\",\n \"depositDataRoot\": \"0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C\",\n \"withdrawalCredentials\": \"<string>\",\n \"amount\": 1024500000000\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"withdrawalAddress\": \"0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb\",\n \"depositData\": [\n {\n \"pubkey\": \"0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4\",\n \"signature\": \"0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88\",\n \"depositDataRoot\": \"0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C\",\n \"withdrawalCredentials\": \"<string>\",\n \"amount\": 1024500000000\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": null,
"result": {
"serializeTx": "0x02f902d70580830167...",
"to": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb",
"gasLimit": "0",
"data": "",
"value": "0",
"chainId": "0",
"type": "0",
"maxFeePerGas": "0",
"maxPriorityFeePerGas": "0"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Withdrawal address for direct staking or EigenPodAddress for restaking.
Pattern:
^0x[a-fA-F0-9]{40}$Example:
"0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb"
Deposit data required for validator activation on the beacon chain.
Required array length:
1 - 400 elementsShow child attributes
Show child attributes
Prepare Staking Transaction
curl --request POST \
--url https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"withdrawalAddress": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb",
"depositData": [
{
"pubkey": "0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4",
"signature": "0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88",
"depositDataRoot": "0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C",
"withdrawalCredentials": "<string>",
"amount": 1024500000000
}
]
}
'import requests
url = "https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit"
payload = {
"withdrawalAddress": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb",
"depositData": [
{
"pubkey": "0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4",
"signature": "0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88",
"depositDataRoot": "0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C",
"withdrawalCredentials": "<string>",
"amount": 1024500000000
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
withdrawalAddress: '0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb',
depositData: [
{
pubkey: '0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4',
signature: '0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88',
depositDataRoot: '0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C',
withdrawalCredentials: '<string>',
amount: 1024500000000
}
]
})
};
fetch('https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'withdrawalAddress' => '0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb',
'depositData' => [
[
'pubkey' => '0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4',
'signature' => '0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88',
'depositDataRoot' => '0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C',
'withdrawalCredentials' => '<string>',
'amount' => 1024500000000
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit"
payload := strings.NewReader("{\n \"withdrawalAddress\": \"0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb\",\n \"depositData\": [\n {\n \"pubkey\": \"0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4\",\n \"signature\": \"0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88\",\n \"depositDataRoot\": \"0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C\",\n \"withdrawalCredentials\": \"<string>\",\n \"amount\": 1024500000000\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"withdrawalAddress\": \"0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb\",\n \"depositData\": [\n {\n \"pubkey\": \"0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4\",\n \"signature\": \"0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88\",\n \"depositDataRoot\": \"0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C\",\n \"withdrawalCredentials\": \"<string>\",\n \"amount\": 1024500000000\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.p2p.org/api/api/v1/eth/staking/direct/tx/deposit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"withdrawalAddress\": \"0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb\",\n \"depositData\": [\n {\n \"pubkey\": \"0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4\",\n \"signature\": \"0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88\",\n \"depositDataRoot\": \"0x784bfffb4DfEFb457BA9187B38E49a1Bc0f4af50EDDDaca9581AA0aA7F98E96C\",\n \"withdrawalCredentials\": \"<string>\",\n \"amount\": 1024500000000\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": null,
"result": {
"serializeTx": "0x02f902d70580830167...",
"to": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb",
"gasLimit": "0",
"data": "",
"value": "0",
"chainId": "0",
"type": "0",
"maxFeePerGas": "0",
"maxPriorityFeePerGas": "0"
}
}