Near
Unified API + Near Integration Workflow
In the following guide, the integration process for the near
chain is covered. The Near 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 Near-specific details
chain
— always set tonear
for Near-related requests.network
— environment in which the transaction is processed (mainnet
only).stakerAddress
— account address initiating staking, unstaking or withdrawal transactions.amount
— amount of tokens in NEAR.
Staking Flow
1. Create Staking 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": "near",
"network": "mainnet",
"stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040",
"amount": "1"
}'
chain
— blockchain network, always set tonear
for Near-related requests.network
— environment in which the transaction is processed (mainnet
only).stakerAddress
— Near implicit account address.amount
— amount of tokens to stake, minimum amount is 1.
Example response:
{
"error": null,
"result": {
"amount": 1,
"stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040",
"unsignedTransactionData": "400000006339636434396461346662336361646535343264363235666139303961633434336537376131636231306530323837646636633562386466376534636330343000c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc0400f146f9cac7e0000130000007032702d6f72672e706f6f6c76312e6e6561723bf366edf6cf4e3890d95360b8fbc35cb7a2290076a0aa1224c256efbeb4caf30100000002110000006465706f7369745f616e645f7374616b65260000007b22616d6f756e74223a2231303030303030303030303030303030303030303030303030227d00203d88792d0000000000a1edccce1bc2d3000000000000",
"createdAt": "2025-02-19T21:48:10.228Z",
"extraData": {
"transactionId": "548f7bce-6e03-411d-9118-2d59a021f177",
"stakeId": "e0081662-8a9c-47b5-9c26-45320b8ce951",
"gasEstimate": {
"amount": "0.025000000000000000",
"gasLimit": "50000000000000"
}
}
}
}
amount
— amount of tokens to stake in NEAR.stakerAddress
— staking account address receiving the staked tokens.unsignedTransactionData
— unsigned transaction in Base64 encrypted 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.extraData
— additional transaction details:transactionId
— unique identifier of the transaction within this staking session.stakeId
— unique identifier for the staking request.gasEstimate
— estimated gas usage details:amount
— estimated transaction fee in NEAR.gasLimit
— maximum gas limit for the transaction execution in yoctoNEAR (1 NEAR = 10¹⁸ yoctoNEAR).
2. Sign and Send Transaction
Use unsignedTransactionData
to sign the transaction.
To broadcast the signed transaction to the Near 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": "near",
"network": "mainnet",
"signedTransaction": "400000006339636434396461346662336361646535343264363235666139303961633434336537376131636231306530323837646636633562386466376534636330343000c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc04012146f9cac7e0000130000007032702d6f72672e706f6f6c76312e6e6561728c7d5ee5f77c298039c9ccd944ebb6218a7a036737c12356e75ef912662509870100000002110000006465706f7369745f616e645f7374616b65260000007b22616d6f756e74223a2231303030303030303030303030303030303030303030303030227d00203d88792d0000000000a1edccce1bc2d300000000000000ebc276fccd41088080c127999bd78cc5ecfbb8ce6282638b5cd19e3f465bd402c8cf30f8e5b4aa4fccae9f81d8340862d4748b102e4e2621533e9f788a793705",
"stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040",
"extra": {
"transactionId": "548f7bce-6e03-411d-9118-2d59a021f177"
}
}'
chain
— blockchain network.network
— environment in which the transaction is processed.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.stakerAddress
— staking account address receiving the staked tokens.extra
— additional request parameters:transactionId
— unique identifier of the transaction, obtained from the previous step.
Example response:
{
"error": null,
"result": {
"extraData": {
"transactionHash": "HvnL1nyej4cCJnUbeghqWdxeVFkXdDjroA4yN6zcHv9f"
}
}
}
extraData
— additional transaction details:transactionHash
— hash of the block in which the transaction has been included.
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": "near",
"network": "mainnet",
"stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040",
"extra": {
"amount": "1"
}
}'
chain
— blockchain network.network
— environment in which the transaction is processed.stakerAddress
— account address initiated the staking transaction.extra
— additional request parameters:amount
— amount of tokens to withdraw in NEAR.
Example response:
{
"error": null,
"result": {
"amount": "1",
"stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040",
"unsignedTransactionData": "400000006339636434396461346662336361646535343264363235666139303961633434336537376131636231306530323837646636633562386466376534636330343000c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc0400b146f9cac7e0000130000007032702d6f72672e706f6f6c76312e6e656172afa6fb301707310d7c898f7c9f83fc8bc91be960e3a286145afe416f8c418942010000000207000000756e7374616b65260000007b22616d6f756e74223a2231303030303030303030303030303030303030303030303030227d00203d88792d000000000000000000000000000000000000",
"createdAt": "2025-02-10T22:36:14.547Z",
"extraData": {
"transactionId": "69f8b6f1-8b36-4429-843c-90107cfb5bfb",
"stakeId": "6f102d59-b479-4a87-905b-7572b904bb01",
"gasEstimate": {
"amount": "0.025000000000000000",
"gasLimit": "50000000000000"
}
}
}
}
amount
— amount of tokens to withdraw in NEAR.stakerAddress
— account address initiated the staking transaction.unsignedTransactionData
— unsigned transaction in Base64 encrypted 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.extraData
— additional transaction details:transactionId
— unique identifier of the transaction within this withdrawal session.stakeId
— unique identifier of the withdrawal request.gasEstimate
— estimated gas usage details:amount
— estimated transaction fee in NEAR.gasLimit
— maximum gas limit for the transaction execution in yoctoNEAR (1 NEAR = 10¹⁸ yoctoNEAR).
2. Sign and Send Transaction
Use unsignedTransactionData
to sign and send the transaction following the Near-specific signing logic.
3. Create Withdrawal Request
Note that the withdrawal is available only after the unstaking period of 4 epochs (~72 hours).
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": "near",
"network": "mainnet",
"stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040"
}'
chain
— blockchain network.network
— environment in which the transaction is processed.stakerAddress
— account address initiating the withdrawal transaction.
Example response:
{
"error": null,
"result": {
"amount": "1",
"stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040",
"unsignedTransactionData": "400000006339636434396461346662336361646535343264363235666139303961633434336537376131636231306530323837646636633562386466376534636330343000c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc0400b146f9cac7e0000130000007032702d6f72672e706f6f6c76312e6e656172afa6fb301707310d7c898f7c9f83fc8bc91be960e3a286145afe416f8c418942010000000207000000756e7374616b65260000007b22616d6f756e74223a2231303030303030303030303030303030303030303030303030227d00203d88792d000000000000000000000000000000000000",
"createdAt": "2025-02-10T22:36:14.547Z",
"extraData": {
"transactionId": "69f8b6f1-8b36-4429-843c-90107cfb5bfb",
"stakeId": "6f102d59-b479-4a87-905b-7572b904bb01",
"gasEstimate": {
"amount": "0.025000000000000000",
"gasLimit": "50000000000000"
}
}
}
}
amount
— amount of tokens to withdraw in NEAR.stakerAddress
— account address initiated the withdrawal transaction.unsignedTransactionData
— unsigned transaction in Base64 encrypted 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.extraData
— additional transaction details:transactionId
— unique identifier of the transaction within this withdrawal session.stakeId
— unique identifier of the withdrawal request.gasEstimate
— estimated gas usage details:amount
— estimated transaction fee in NEAR.gasLimit
— maximum gas limit for the transaction execution in yoctoNEAR (1 NEAR = 10¹⁸ yoctoNEAR).
4. Sign and Send Transaction
Use unsignedTransactionData
to sign and send the transaction following the Near-specific signing logic.
What's Next?
Updated 7 days ago