Polkadot
Unified API + Polkadot Integration Workflow
In the following guide, the integration process for the polkadot
chain and westend
network is covered. The Polkadot integration aligns with the general Unified API process but with network-specific parameters.
Get an authentication token to start using the Unified API.
Request examples are provided using cURL.
To check the integration guides for other chains, refer to the Networks section.
Key Polkadot-specific details
chain
— blockchain network, always set topolkadot
for Polkadot-related requests.network
— environment in which the transaction is processed (kusama
,westend
ormainnet
).stakerAddress
— account address initiating staking, unstaking or withdrawal transactions.amount
— amount of tokens in DOT, min amount is 1.
Staking Flow
1. Create Staking Bond Request
Send a POST request to /api/v1/unified/staking/stake.
Example request (for mainnet
network):
curl --request POST \
--url https://api-test.p2p.org/api/v1/unified/staking/stake \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
"chain": "polkadot",
"network": "westend",
"stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ",
"amount": "1"
}'
chain
— blockchain network, always set topolkadot
for Polkadot-related requests.network
— environment in which the transaction is processed (kusama
,westend
ormainnet
).stakerAddress
— account address initiating staking, unstaking or withdrawal transactions.amount
— amount of tokens to stake in DOT, min amount is 1.
Example response:
{
"error": null,
"result": {
"amount": 1,
"createdAt": "2025-03-07T07:10:20.966Z",
"extraData": {
"unsignedTransaction": "0xa8040600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e",
"stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ",
"rewardDestinationType": "account",
"rewardDestination": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ"
}
}
}
amount
— amount of tokens to stake in DOT.createdAt
— timestamp of the transaction in the ISO 8601 format.extraData
— additional transaction details.
2. Sign and Send Transaction
Use unsignedTransactionData
to sign the transaction using the Polkadot-specific signing logic.
To broadcast the signed transaction to the Polkadot network, send a POST request to /api/v1/unified/transaction/broadcast.
Example request:
curl --request POST \
--url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
"chain": "polkadot",
"network": "westend",
"stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ",
"signedTransaction": "0x410284007427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e01f214ddb36378b5f5927b06028eccfe284d9cb736f8552e301cc09c2006998b098f84bf6386a201aa952fe298dd5f0c5fb6f03fc7b9f7efafd87b6ee321500b8e450340000600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e"
}'
chain
— blockchain network.network
— environment in which the transaction is processed.stakerAddress
— account address initiating the staking transaction.signedTransaction
— signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network.
Example response:
{
"error": null,
"result": {
"status": "failed",
"extraData": {
"network": "westend",
"signedTransaction": "0x450284007427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e011c38a0ce7dad52c9500843dddb52645bc790891c61963a454dcb79cbc3e0545fcc64d1fcbebea0769392248dc3d34e60568452ebbe44bd0f876ecae73a8eae8915012000000600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e",
"blockHash": "0x5cffd50711d3de0a896687ce2939313dd00491edc820d3abeaefe6a997be3a4f",
"blockId": 25052458,
"extrinsicId": 2,
"transactionHash": "0xb5546fbfb7221c358d8e593cc094430a884a9f41b765003674b59aaf16d0f5f2",
"signerAccount": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ",
"data": {
"args": {
"value": "1,000,000,000,000",
"payee": {
"Account": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ"
}
},
"method": "bond",
"section": "staking"
},
"createdAt": "2025-03-07T03:57:30.386Z"
}
}
}
3. Create Staking Nominate Request
Send a POST request to /api/v1/unified/staking/stake.
Example request:
curl --request POST \
--url https://api-test.p2p.org/api/v1/unified/staking/stake \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
"chain": "polkadot",
"network": "westend",
"stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ",
"amount": "1",
"extra": {
"stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ"
}
}'
Example response:
{
"error": null,
"result": {
"createdAt": "2025-03-07T03:59:22.666Z",
"extraData": {
"unsignedTransaction": "0x19010406050800be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f00fe65717dad0447d715f660a0a58411de509b42e6efb8375f562f58a554d5860e",
"stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ",
"targets": [
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY",
"5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc"
]
}
}
}
4. Sign and Send Transaction
Use unsignedTransactionData
to sign and send the transaction following the Polkadot-specific signing logic.
Unstaking Flow
1. Create Unstaking Request
Send a POST request to /api/v1/unified/staking/unstake.
Example request:
curl --request POST \
--url https://api-test.p2p.org/api/v1/unified/staking/unstake \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
"chain": "polkadot",
"network": "westend",
"stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ"
"extra": {
"amount": 1
}
}'
Example response:
{
"error": null,
"result": {
"createdAt": "2025-03-07T04:02:18.033Z",
"extraData": {
"unsignedTransaction": "0x24040602070010a5d4e8",
"stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ",
"amount": 1
}
}
}
2. Sign and Send Transaction
Use unsignedTransactionData
to sign and send the transaction following the Polkadot-specific signing logic.
3. Create Withdrawal Request
Note that the withdrawal is available after ~28 days after unstaking.
Send a POST request to /api/v1/unified/staking/withdraw.
Example request:
curl --request POST \
--url https://api-test.p2p.org/api/v1/unified/staking/withdraw \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
"chain": "polkadot",
"network": "westend",
"stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ"
}'
Example response:
{
"error": null,
"result": {
"stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ",
"unsignedTransactionData": "0x1c04060300000000",
"createdAt": "2025-03-07T04:30:47.854Z",
"extraData": {}
}
}
4. Sign and Send Transaction
Use unsignedTransactionData
to sign and send the transaction following the Polkadot-specific signing logic.
What's Next?
Updated about 2 hours ago