Withdrawal
The withdrawal process in the Polkadot network using the Staking API can be done following these steps:
- Create Unbond Request: unbond tokens within the Polkadot network that were previously staked or bonded.
It takes 7 days (28 eras) to unbond on Kusama, 28 days (28 eras) on Polkadot, and 12 hours (2 eras) on Westend.
- Withdraw Unbonded Request: withdraw tokens within the Polkadot network that were previously unbonded. Note that this request is available after the unbond period.
Staking directly
1. Create Unbond Request
-
Send a POST request to /api/v1/polkadot/{network}/staking/unbond.
Example request (for
westend):curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/unbond \ --header 'accept: application/json' \ --header 'authorization: Bearer <token>' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "amount": 3 }'stashAccountAddress— main stash account address which keeps tokens for bonding.amount— amount of tokens to unbond. DOT is used for the main network, KSM for Kusama, and WND for Westend.
Example response:
{ "result": { "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f", "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "amount": 3, "createdAt": "2023-08-15T15:07:54.795Z" } }unsignedTransaction— unsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action.stashAccountAddress— main stash account address which keeps tokens for bonding.amount— amount of tokens for bond operations. DOT is used for the main network, KSM for Kusama, and WND for Westend.createdAt— timestamp of the transaction in the ISO 8601 format.
-
Sign and broadcast the
unsignedTransactionto the Polkadot network.
2. Withdraw Unbonded Request
-
Send a POST request to /api/v1/polkadot/{network}/staking/withdrawal-unbonded.
Example request (for
westend):curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/withdrawal-unbonded \ --header 'accept: application/json' \ --header 'authorization: Bearer <token>' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5" }'stashAccountAddress— main stash account address which keeps tokens for bonding.
Example response:
{ "result": { "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f", "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "createdAt": "2023-08-15T15:07:54.795Z" } }unsignedTransaction— unsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action.stashAccountAddress— main stash account address which keeps tokens for bonding.createdAt— timestamp of the transaction in the ISO 8601 format.
-
Sign and broadcast the
unsignedTransactionto the Polkadot network.
Staking via a nomination pool
1. Create Unbond Request
-
Send a POST request to api/v1/polkadot/{network}/staking/pool/unbond.
Example request (for
westend):curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/{network}/staking/pool/unbond \ --header 'accept: application/json' \ --header 'authorization: Bearer <token>' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "amount": 3 }'stashAccountAddress— main stash account address which keeps tokens for bonding.amount— amount of tokens to unbond. DOT is used for the main network, KSM for Kusama, and WND for Westend.
Example response:
{ "result": { "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f", "amount": 3, "createdAt": "2023-08-15T15:07:54.795Z" } }unsignedTransaction— unsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action.amount— amount of tokens for bond operations. DOT is used for the main network, KSM for Kusama, and WND for Westend.createdAt— timestamp of the transaction in the ISO 8601 format.
-
Sign and broadcast the
unsignedTransactionto the Polkadot network.
2. Withdraw Unbonded Request
-
Send a POST request to api/v1/polkadot/{network}/staking/pool/withdraw-unbonded.
Example request (for
westend):curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/withdrawal-unbonded \ --header 'accept: application/json' \ --header 'authorization: Bearer <token>' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "poolId": "1" }'stashAccountAddress— main stash account address which keeps tokens for bonding.poolId— ID of the nomination pool in which you participate in.
Example response:
{ "result": { "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f", "createdAt": "2023-08-15T15:07:54.795Z" } }unsignedTransaction— unsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action.createdAt— timestamp of the transaction in the ISO 8601 format.
-
Sign and broadcast the
unsignedTransactionto the Polkadot network.
What's Next?
- Getting Started.
- Staking API reference.
Updated 4 months ago