Withdrawal
The withdrawal process in the Sui network using the Staking API can be done following these steps:
- Get the list of stakes for your account address.
- Create a withdrawal request.
- Sign and broadcast the transaction.
Request examples are provided using cURL.
1. Get List Stakes
To identify which stake to withdraw, send a GET request to /api/v1/sui/[network]/transaction/stake-list/[address].
Example request (for testnet
network):
curl --request GET
--url 'https://api-test.p2p.org/api/v1/sui/testnet/transaction/stake-list/0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3' \
--header 'Authorization: Bearer <token>'
network
— Sui network:mainnet
ortestnet
.address
— staker account address.
Example response:
{
"error": null,
"result": {
"validatorAddress": "0xab4fb3eeaa7b0ab4f91eedab33adf140c6750e60ca5e44b3df82491937d7bab4",
"stakerAddress": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3",
"stakes": [
{
"stakeId": "0x5d920b8fca6a6043d898ab1a9a8ab167d8aa323fe2b9e76a27312f7f16e20a67",
"amount": 1000000000,
"status": "Pending"
}
]
}
}
validatorAddress
— validator address.stakerAddress
— staker account address.stakes
— detailed information on each stake:stakeId
— identifier of the stake, required to perform a withdrawal.amount
— amount of tokens to stake in MIST (1 SUI = 10⁹ MIST).status
— staking transaction status. You can withdraw at any time while the stake status is eitherpending
oractive
.
2. Create Withdrawal Request
Initiate the withdrawal process by sending a POST request to /api/v1/sui/[network]/staking/withdraw.
Example response:
curl --request
--url 'https://api-test.p2p.org/api/v1/sui/testnet/staking/withdraw' \
--header 'accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"sender": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3",
"gasPrice": 1000,
"gasBudget": 10000000,
"stakeId": "0x5d920b8fca6a6043d898ab1a9a8ab167d8aa323fe2b9e76a27312f7f16e20a67"
}'
sender
— staker account address.gasPrice
— price per unit of gas in MIST for processing the Sui transaction.gasBudget
— maximum gas limit for the transaction.stakeId
— identifier of the stake to withdraw from, obtained through the previous step.
Example response:
{
"error": null,
"result": {
"unsignedTransaction": "0x000003000800ca9a3b00000000010100000000000000000000000000000000000000000000000000000000000000050100000000000000010020ab4fb3eeaa7b0ab4f91eedab33adf140c6750e60ca5e44b3df82491937d7bab4020200010100000000000000000000000000000000000000000000000000000000000000000000030a7375695f73797374656d11726571756573745f6164645f7374616b650003010100020000010200696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3024af02b603f7d65cced30be6ed44300d7d9d66522940e501e1a2083cfc25429e5a60bd0140000000020abca58a9797ecf7cc82596d71b4a154f8dd14b18e3190beee205b905611fbfa29c6ca3ef6b075ab6294342fe06c323768659879813e0544d3fd25a7db7875cca440000180000000020405515b0e64b00c04ebdb0517c2a1f07f3e32cba49adf4ea87d4daadc265c1f0696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3e8030000000000000065cd1d0000000000..."
}
}
unsignedTransaction
— serialized unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action.
3. Sign and Send Transaction
Use unsignedTransaction
from the previous step to sign and send the signed transaction to the Sui network. The withdrawal is immediate and processed within seconds.
What's Next?
- Sign and Send Transaction
- Staking API reference
Updated 8 days ago