Withdrawal using VEM
There are several ways to initiate withdrawals on the Ethereum network using the DVT Staking API by retrieving the Validator Exit Message (VEM):
- Off-chain signature.
- On-chain signature.
Request examples are provided using cURL.
Off-chain signature
-
Generate an Elliptic Curve Diffie-Hellman (ECDH) key pair. Retain the private key securely for future steps, as it is needed to decrypt the VEM.
We use keys on the
NIST P-256
curve (akasecp256r11
akaprime256v1
) for the ECDH algorithm inside the ECIES encryption scheme. Keep your private key secret and discard it when it’s not needed any more. You will also need it when making the initial request.Those public keys have to be a base64-encoded string of a PEM block with the
x509 SPKI
(akaPKIX
) formatted public key on theP-256
curve.Example of such a key:
1. "ecdhPublicKey":"LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFNWgwcmRaSEZaZWNSbWIxR2RqQis3T0dUMnovegozMG1TRnZhWTdQaTltek5HT3J6SjZVbS9GbUMwb2lXMVFBT1FhOVFldGFpZm1EMU0zc09iU0JwV3N3PT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg=="
Example of its base64-decoded version:
-----BEGIN PUBLIC KEY----- MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE5h0rdZHFZecRmb1GdjB+7OGT2z/z 30mSFvaY7Pi9mzNGOrzJ6Um/FmC0oiW1QAOQa9QetaifmD1M3sObSBpWsw== -----END PUBLIC KEY-----
This ECDH public key will be used to produce a ECDH shared secret inside the ECIES scheme by P2P server. The server’s ECDH public key is encoded in the first N bytes (65 in case of the
P-256
curve) as it is required in SEC 1 v2. -
Prepare
id
which is a previously generated arbitrary UUID of the initial SSV request. -
Retrieve the full validator keys by sending a POST request to api/v1/eth/staking/{network}/ssv/request/create with the
with-encrypt-key
value of thetype
variable specified.Example request:
curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/ssv/request/create \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "validatorsCount": 1, "withdrawalAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "ssvOwnerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "type": "with-encrypt-key", "operationPeriodInDays": 365, "ecdhPublicKey": LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFNWgwcmRaSEZaZWNSbWIxR2RqQis3T0dUMnovegozMG1TRnZhWTdQaTltek5HT3J6SjZVbS9GbUMwb2lXMVFBT1FhOVFldGFpZm1EMU0zc09iU0JwV3N3PT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg== } '
id
— arbitrary UUID.validatorsCount
— number of validators. One validator is equal to 32 ETH.withdrawalAddress
— withdrawal address for the client.feeRecipientAddress
— Eth1 address that receives the fee recipient rewards.ssvOwnerAddress
— Eth1address that acts as the owner of the SSV cluster.type
— type of operation:with-encrypt-key
— validator private key maintained by P2P to initiate withdrawals when requested by the client.
operationPeriodInDays
— operation period in days.ecdhPublicKey
— your ECDH public key to obtain an encrypted validator private key.
Example response:
{ "error": null, "result": true }
-
Prepare the JSON
vem_request
structure embedding the validators'pubkeys
for withdrawal andecdh_client_pubkey
.Example
vem_request
structure:{ "action": "vem_request", "pubkeys": [ "0x867a9f95287decd74e076b8fefca3022fcb2c3c37de246e950ade0cc3609c74d4badda62657a64c2c4009f1b6625c647", "0x93e298f6ac5fb8f262a23450d1638aec1c45f77fd1ac86beb19b696b3b84fef3694e9b2166b337783911a3d7df13fbf1" ], "ecdh_client_pubkey": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFNWgwcmRaSEZaZWNSbWIxR2RqQis3T0dUMnovegozMG1TRnZhWTdQaTltek5HT3J6SjZVbS9GbUMwb2lXMVFBT1FhOVFldGFpZm1EMU0zc09iU0JwV3N3PT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==" }
action
— action type to be requested, here specified as a VEM request.pubkeys
— array of public keys identifying the validators you are withdrawing from.ecdh_client_pubkey
— your ECDH public key for secure communication.
-
Submit the VEM request by sending a POST request to /api/v1/eth/staking/{network}/direct/vem/create.
Example request:
curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/goerli/direct/vem/create \ --header 'accept: application/json' \ --header 'authorization: Bearer <token>' \ --header 'content-type: application/json' \ --data ' { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "type": "", "vemRequest": "{\"action\": \"vem_request\",\"pubkeys\": [\"0x867a9f95287decd74e076b8fefca3022fcb2c3c37de246e950ade0cc3609c74d4badda62657a64c2c4009f1b6625c647\", \"0x93e298f6ac5fb8f262a23450d1638aec1c45f77fd1ac86beb19b696b3b84fef3694e9b2166b337783911a3d7df13fbf1\"],\"ecdh_client_pubkey\": \"LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFNWgwcmRaSEZaZWNSbWIxR2RqQis3T0dUMnovegozMG1TRnZhWTdQaTltek5HT3J6SjZVbS9GbUMwb2lXMVFBT1FhOVFldGFpZm1EMU0zc09iU0JwV3N3PT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==\"}", "vemRequestSignature": "0x.....", "vemRequestSignedBy": "0x.....", "vemRequestTxId": "", "vemRequestProof": "" } '
id
— UUID to identify the VEM set-up request.type
— VEM request type used. Two types are supported:off_chain
andon_chain
.vemRequest
— JSON formatted string that represents the VEM request.vemRequestSignature
— signature of thevem_request
by eitherwithdrawalAddress
or
controllerAddress
. Required if the type isoff_chain
.vemRequestSignedBy
— Ethereum address (withdrawalAddress
orcontrollerAddress
) that signed the request. Required if the type isoff_chain
.vemRequestTxId
— hash of the successfulvem_request
transaction. Required if the type ison_chain
.vemRequestProof
— hash of the signedvemRequestTxId
transaction. Required if the type ison_chain
.
Example response:
{ "result": true }
To authorize the withdrawal process, the
vem_request
must be digitally signed using the Ethereum private key associated with yourwithdrawalAddress
orcontrollerAddress
.vem_request_signature
is a 0x prefixed hex encoded signature of theKeccak256
hash of thevem_request
field, done using the private key of either thewithdrawalAddress
orcontrollerAddress
. This private key should be a standard Ethereum key on thesecp256k1
curve and use the standard Ethereum extended ECDSA signature algorithm.The signature verifies that the requestor has the authority to perform the transaction and is an essential security measure to prevent unauthorized withdrawals.
-
Check the request status and retrieve the signed VEM by sending a GET request to /api/v1/eth/staking/{network}/ssv/request/status/{id}.
Example request:
curl --request GET \ --url https://api.p2p.org/api/v1/eth/staking/goerli/direct/vem/status/3fa85f64-5717-4562-b3fc-2c963f66afa6 \ --header 'accept: application/json' \ --header 'authorization: Bearer <token>' \
id
— arbitrary UUID specified when retrieving full validator keys.
Example response:
{ "error": null, "result": { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "status": "processing", "type": "", "vemRequest": "{\"action\": \"vem_request\",\"pubkeys\": [\"0x867a9f95287decd74e076b8fefca3022fcb2c3c37de246e950ade0cc3609c74d4badda62657a64c2c4009f1b6625c647\", \"0x93e298f6ac5fb8f262a23450d1638aec1c45f77fd1ac86beb19b696b3b84fef3694e9b2166b337783911a3d7df13fbf1\"],\"ecdh_client_pubkey\": \"LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFNWgwcmRaSEZaZWNSbWIxR2RqQis3T0dUMnovegozMG1TRnZhWTdQaTltek5HT3J6SjZVbS9GbUMwb2lXMVFBT1FhOVFldGFpZm1EMU0zc09iU0JwV3N3PT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==\"}", "vemRequestSignature": "0x.....", "vemRequestSignedBy": "0x.....", "vemRequestTxId": "", "vemRequestProof": "", "error": "", "vemResult": "", "forkVersion": "" } }
id
— arbitrary UUID specified when retrieving full validator keys.status
— current status of the VEM request:processing
— request is in progress.success
— answer is ready.error
— there is an issue with the data, unable to create VEM.fault
— error occurred on the server side.
type
— VEM request type used. Two types are supported:off_chain
andon_chain
.vemRequest
— base64-encoded VEM request.vemRequestSignature
— digital signature of the request.vemRequestSignedBy
— Ethereum address that signed the request, providing a linkage to the withdrawal or controller account.vemRequestTxId
— hash of the successfulvem_request
transaction.vemRequestProof
— hash of the signedvemRequestTxId
transaction.error
— error message (if exists).vemResult
— encrypted VEM results.forkVersion
— version of the Ethereum fork.
Upon receipt of the
vemResult
, use your private ECDH key to decrypt the message using the ECIES scheme and retrieve the signed VEM for your staked Ethereum. -
Create the serialized transaction initiating the process of removing validator from the cluster by sending a GET request to /api/v1/eth/staking/{network}/ssv/tx/remove-validator/{id}
Example request:
curl --request GET \ --url https://api.p2p.org/api/v1/eth/staking/goerli/ssv/tx/remove-validator/3fa85f64-5717-4562-b3fc-2c963f66afa5 \ --header 'accept: application/json'
id
— UUID of the initial SSV request.
Example response:
{ "result": { "list": [ { "serializeTx": "0x02f9078605010210830f424094c3cd9a0ae89fff83b71b58b6512d43f8a41f363d80b9076406e8fb9c00000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000016c7ded605b5c0000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046f3111b30000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000016c7ded605b5c0000000000000000000000000000000000000000000000000000000000000000030b4b5f251eac53f34eb1da2b6659d35db303e408c4c830156cf090441564474f356abd023a0e679aa97cefeed850abb2700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000520971aade51840b84fc5b88fee2ef1ed80ce57c2ea9a8fb610d2fdb3a287589a87c421b845e3f1cb4ef5a84eaba6c31d4c159ead3c818758d6fc988a207ea467ff35fb90ab502805569f8ff94042d870ebedc327ea0778476559c95076a99c7cd1b78b94bb2a5098c10b50000c7419476f295e0d1e94b17c1f985c76adfad8b7897bdf34b58388b6b201104616e179e93888016e92ab60b4bf5d844b1a8fd9fdd97e3dba2cfadbe65f1bc3b66aeed8b1be8407a150ae6a028fe72e50d70121e7eab424e02922422ce66fb45c5878eb0d307fae5b5b0637cee897a119563d18082c33fe5ac017d3cfd3a42e2f5f7d8bece98e679000fb7cfd339fbc1470177963d5cd73b6b4001e77f3dcb348cb07797b25fd3b6811e4dfbafe78a4a9d70861fd27001d88253500347ba8ff907bd647b83aa6b5bf727929ee35ce5360a0b7810b355f8e524426e8a6db75e240af29527b398c2d5a926e4867f04483ec61338d7f413cd419d17bc572a0b3ecd98e04426964a8350d1545493e2fe039828f8e74fb48da7f4ee26166b4c2b2b05fa94bf4721a0b6888a8065062ed45bd23f9d3fcbb80ecf3febfb8c90522b20ae724a94f12fb9de80c95dd7b1762d6b15312c3bbde291224fb7b809384404bde5d78bd36801a67154addc466d20c6e6146eda1e263167a96a9d21a1b4fef6d532957cfca20d3311ac2f5bfd6c4601df0eebec49b5a74adce8c1b7fbf82c5333d25c499f72928d3bfe47fa9c54ec9f55c63586758af8a256683952376b4feef745bbc2280e66bb475e48edc4a90eb128bfb3322b30065f3fedf6dcd3180798375eee05abc20433f79e3d6e73948a84057ca7b72b6ba756f257ca1a11f2fa3b130bcf28d9ef80cb946bf11e6008815ee6c100ab1527f13c064bac2b67a8f832ab70c98d39d77940f975c35c8dea26f2e25a5e706da368fa0dd08958ea11904b1b51ca40aab37e581e58a5c60ea1caa08063461b3319e6c8ff21b75f2ff9358ddccf27abea55e7dbad4f474741ff14fe9e63d9c001eec990531a5bc6b2196269cfa0050beced2e2ce55f9dfea48c0c81f3d1a1f4f6548e29de76b085f83f9399c29b89880a15b80e049de2fa9eef3eab7a1a15cd1d6ae2bc8fdc9837f59baf56c11ed7405bda5d2cd2de6fd80c7b7461abfb757c742b3216ef79d8268501cb3531a5fcf9d46b58e828e6aaea4bef8484cc8945912ac611827463d4a3dabe56f608181dfba8ffc7cb1cfdef5a09a9f107652b44d290fc42b0d5e3e16634342af07f205153b0c7d095e0d418f1d0aef8a7e00d41e5af183ceed36d5832169bdd91810b4ad686b85130ec07aeaccfbc26d440684ac34c8005c12b38caa41d18ecd51167afaba0aae2b605cb0cefcae1b4f64ff220167d1f93b73abd75368dd67c3a6ad48448021c66086daf62419d6de350ee3f25aef4784340c0932362da25cff3f1ed7316afce3034d264f1206322c6510aacddb9315f8b532516a52f2483d0a191caa38a10cb40d00494c43ddcc49b54349fd809409a8d6131746ef7adc57a9f7feea9bb3a4142d418e5b1f89ccde686a1627c9a9d5ac9bc6a06685017b15eb549e9bc2e7cf98720b616d8bea14b5b9194280bb1386154be5fd31dc6f64cfe5bbf80fff95e2a82a2a803e579e302c0db931470b78fb32fb1774840002417b86c4ad621e43ec36d2496a7f6b63d470fae3edb863f909ee0e4ce43ca293770a229cbcbd542c9bd123889298c3a6e32c2e5c5f4861afa640a16d5c5089373d3e6ddfdebc223a2d966c3e37d135f3f8805eb3432ff46befac6c41aff89739b1bab6ccee383fb524ff985b5054091fed2d351bff38ec78800200c0", "to": "0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D", "gasLimit": "0.000000000001", "data": "0x06e8fb9c00000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000016c7ded605b5c0000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046f3111b30000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000016c7ded605b5c0000000000000000000000000000000000000000000000000000000000000000030b4b5f251eac53f34eb1da2b6659d35db303e408c4c830156cf090441564474f356abd023a0e679aa97cefeed850abb2700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000520971aade51840b84fc5b88fee2ef1ed80ce57c2ea9a8fb610d2fdb3a287589a87c421b845e3f1cb4ef5a84eaba6c31d4c159ead3c818758d6fc988a207ea467ff35fb90ab502805569f8ff94042d870ebedc327ea0778476559c95076a99c7cd1b78b94bb2a5098c10b50000c7419476f295e0d1e94b17c1f985c76adfad8b7897bdf34b58388b6b201104616e179e93888016e92ab60b4bf5d844b1a8fd9fdd97e3dba2cfadbe65f1bc3b66aeed8b1be8407a150ae6a028fe72e50d70121e7eab424e02922422ce66fb45c5878eb0d307fae5b5b0637cee897a119563d18082c33fe5ac017d3cfd3a42e2f5f7d8bece98e679000fb7cfd339fbc1470177963d5cd73b6b4001e77f3dcb348cb07797b25fd3b6811e4dfbafe78a4a9d70861fd27001d88253500347ba8ff907bd647b83aa6b5bf727929ee35ce5360a0b7810b355f8e524426e8a6db75e240af29527b398c2d5a926e4867f04483ec61338d7f413cd419d17bc572a0b3ecd98e04426964a8350d1545493e2fe039828f8e74fb48da7f4ee26166b4c2b2b05fa94bf4721a0b6888a8065062ed45bd23f9d3fcbb80ecf3febfb8c90522b20ae724a94f12fb9de80c95dd7b1762d6b15312c3bbde291224fb7b809384404bde5d78bd36801a67154addc466d20c6e6146eda1e263167a96a9d21a1b4fef6d532957cfca20d3311ac2f5bfd6c4601df0eebec49b5a74adce8c1b7fbf82c5333d25c499f72928d3bfe47fa9c54ec9f55c63586758af8a256683952376b4feef745bbc2280e66bb475e48edc4a90eb128bfb3322b30065f3fedf6dcd3180798375eee05abc20433f79e3d6e73948a84057ca7b72b6ba756f257ca1a11f2fa3b130bcf28d9ef80cb946bf11e6008815ee6c100ab1527f13c064bac2b67a8f832ab70c98d39d77940f975c35c8dea26f2e25a5e706da368fa0dd08958ea11904b1b51ca40aab37e581e58a5c60ea1caa08063461b3319e6c8ff21b75f2ff9358ddccf27abea55e7dbad4f474741ff14fe9e63d9c001eec990531a5bc6b2196269cfa0050beced2e2ce55f9dfea48c0c81f3d1a1f4f6548e29de76b085f83f9399c29b89880a15b80e049de2fa9eef3eab7a1a15cd1d6ae2bc8fdc9837f59baf56c11ed7405bda5d2cd2de6fd80c7b7461abfb757c742b3216ef79d8268501cb3531a5fcf9d46b58e828e6aaea4bef8484cc8945912ac611827463d4a3dabe56f608181dfba8ffc7cb1cfdef5a09a9f107652b44d290fc42b0d5e3e16634342af07f205153b0c7d095e0d418f1d0aef8a7e00d41e5af183ceed36d5832169bdd91810b4ad686b85130ec07aeaccfbc26d440684ac34c8005c12b38caa41d18ecd51167afaba0aae2b605cb0cefcae1b4f64ff220167d1f93b73abd75368dd67c3a6ad48448021c66086daf62419d6de350ee3f25aef4784340c0932362da25cff3f1ed7316afce3034d264f1206322c6510aacddb9315f8b532516a52f2483d0a191caa38a10cb40d00494c43ddcc49b54349fd809409a8d6131746ef7adc57a9f7feea9bb3a4142d418e5b1f89ccde686a1627c9a9d5ac9bc6a06685017b15eb549e9bc2e7cf98720b616d8bea14b5b9194280bb1386154be5fd31dc6f64cfe5bbf80fff95e2a82a2a803e579e302c0db931470b78fb32fb1774840002417b86c4ad621e43ec36d2496a7f6b63d470fae3edb863f909ee0e4ce43ca293770a229cbcbd542c9bd123889298c3a6e32c2e5c5f4861afa640a16d5c5089373d3e6ddfdebc223a2d966c3e37d135f3f8805eb3432ff46befac6c41aff89739b1bab6ccee383fb524ff985b5054091fed2d351bff38ec78800200", "value": "0.0", "chainId": "5", "type": "2", "maxFeePerGas": "0.000000000000000016", "maxPriorityFeePerGas": "2" } ] }, "error": {} }
list
includes a list of data fields that contain the following data:serializeTx
— serialized unsigned transaction.to
— recipient address for this transaction.gasLimit
— maximum gas limit for this block.data
— transaction data.value
— amount this transaction is sending in Wei.chainId
— chain ID this transaction is authorized on, as specified by EIP-155.type
— EIP-2718 type of this transaction envelope.maxFeePerGas
— maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei.maxPriorityFeePerGas
— price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize miners to prioritize this transaction.
-
Use
serializeTx
to sign and send the signed transaction to the Ethereum network.
What's Next?
- Withdrawal.
- Getting Started.
- DVT Staking API reference.
Updated 3 months ago