Ethereum
Prepare Withdrawal Transaction
Construct a serialized transaction to initiate the withdrawal process for EOA validators, utilizing the functionalities of P2P smart contract.
POST
/
api
/
v1
/
eth
/
staking
/
direct
/
tx
/
withdrawal
Prepare Withdrawal Transaction
curl --request POST \
--url https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"pubkeys": [
"0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39"
]
}
'import requests
url = "https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal"
payload = { "pubkeys": ["0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39"] }
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({
pubkeys: [
'0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39'
]
})
};
fetch('https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal', 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/v1/eth/staking/direct/tx/withdrawal",
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([
'pubkeys' => [
'0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39'
]
]),
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/v1/eth/staking/direct/tx/withdrawal"
payload := strings.NewReader("{\n \"pubkeys\": [\n \"0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39\"\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/v1/eth/staking/direct/tx/withdrawal")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"pubkeys\": [\n \"0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal")
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 \"pubkeys\": [\n \"0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": null,
"result": {
"serializeTx": "0x02f9010f83088bb08083989680847ca9ed4e830186a094158f2bbef21cf9f92cf4a294999ba422948c824280b8e466792ba1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000867b22616374696f6e223a227769746864726177222c227075626b657973223a5b223078393532313131663737353764313436393431326230663363313531356535363466343230386263323136323165343536326663626561303036636262316630303837343234323236366236633963383164633237653438383730346464393563225d7d0000000000000000000000000000000000000000000000000000c0",
"to": "0x158f2bbEf21CF9F92Cf4A294999BA422948c8242",
"gasLimit": "100000",
"data": "0x66792ba1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000867b22616374696f6e223a227769746864726177222c227075626b657973223a5b223078393532313131663737353764313436393431326230663363313531356535363466343230386263323136323165343536326663626561303036636262316630303837343234323236366236633963383164633237653438383730346464393563225d7d0000000000000000000000000000000000000000000000000000",
"value": "0",
"chainId": 560048,
"type": 2,
"maxFeePerGas": "2091511118",
"maxPriorityFeePerGas": "10000000"
}
}Authorizations
Body
application/json
Prepare Withdrawal Transaction
curl --request POST \
--url https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"pubkeys": [
"0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39"
]
}
'import requests
url = "https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal"
payload = { "pubkeys": ["0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39"] }
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({
pubkeys: [
'0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39'
]
})
};
fetch('https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal', 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/v1/eth/staking/direct/tx/withdrawal",
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([
'pubkeys' => [
'0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39'
]
]),
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/v1/eth/staking/direct/tx/withdrawal"
payload := strings.NewReader("{\n \"pubkeys\": [\n \"0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39\"\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/v1/eth/staking/direct/tx/withdrawal")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"pubkeys\": [\n \"0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal")
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 \"pubkeys\": [\n \"0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": null,
"result": {
"serializeTx": "0x02f9010f83088bb08083989680847ca9ed4e830186a094158f2bbef21cf9f92cf4a294999ba422948c824280b8e466792ba1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000867b22616374696f6e223a227769746864726177222c227075626b657973223a5b223078393532313131663737353764313436393431326230663363313531356535363466343230386263323136323165343536326663626561303036636262316630303837343234323236366236633963383164633237653438383730346464393563225d7d0000000000000000000000000000000000000000000000000000c0",
"to": "0x158f2bbEf21CF9F92Cf4A294999BA422948c8242",
"gasLimit": "100000",
"data": "0x66792ba1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000867b22616374696f6e223a227769746864726177222c227075626b657973223a5b223078393532313131663737353764313436393431326230663363313531356535363466343230386263323136323165343536326663626561303036636262316630303837343234323236366236633963383164633237653438383730346464393563225d7d0000000000000000000000000000000000000000000000000000",
"value": "0",
"chainId": 560048,
"type": 2,
"maxFeePerGas": "2091511118",
"maxPriorityFeePerGas": "10000000"
}
}