> ## Documentation Index
> Fetch the complete documentation index at: https://docs.p2p.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Sui

> Unified API + Sui Integration Workflow

In the following guide, the integration process for the `sui` chain is covered. The Sui integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters.

[Get an authentication token](/docs/authentication) to start using the Unified API.

Request examples are provided using [cURL](https://curl.se/).

> To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section.

<Note>
  **Key Sui-specific details**

  * `chain` — always set to `sui` for Sui-related requests.
  * `network` — environment in which the transaction is processed: `testnet` or `mainnet`.
  * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions.
  * `amount` — amount of tokens in MIST (1 SUI = 10⁹ MIST).
</Note>

## Staking flow

### 1. Create staking request

Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction).

Example request (for `testnet` network):

<CodeGroup>
  ```bash bash theme={null}
  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": "sui",
    "network": "testnet",
    "stakerAddress": "0xe6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b6",
    "amount": 1000000000
  }'
  ```
</CodeGroup>

* `chain` — blockchain network, always set to `sui` for Sui-related requests.
* `network` — environment in which the transaction is processed: `mainnet` or `testnet`.
* `stakerAddress` — `0x`-prefixed account address initiating the staking transaction.
* `amount` — amount of tokens to stake in MIST (1 SUI = 10⁹ MIST).

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "amount": 1000000000,
          "stakerAddress": "5DHyW8yCpJEAzFm1jyk5qbNXicd3Dg1tyNAEcPVLjTBCQEgG",
          "unsignedTransactionData": "0x550104010208...",
          "extraData": {
              "targets": ["5G6Zhgm59oujA5UW8wMu4XHFP59uenjC2xp1zshyrWVa638J"],
              "rewardDestinationType": "account",
              "rewardDestination": "5DHyW8yCpJEAzFm1jyk5qbNXicd3Dg1tyNAEcPVLjTBCQEgG",
              "createdAt": "2024-12-19T11:51:03.477Z"
          }
      }
  }
  ```
</CodeGroup>

* `amount` — amount of tokens to stake in MIST.

* `stakerAddress` — account address initiating the staking transaction.

* `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action.

* `extraData` — additional transaction details:

  * `targets` — addresses of the validators selected in the targets.

  * `rewardDestinationType` — rewards destination type:

    * `staked` — rewards will be sent to the stash account and added to the current bond (compounding rewards).
    * `stash` — rewards will be sent to the stash account as a transferrable balance (not compounding rewards).
    * `account` — rewards will be sent to any account specified as a transferrable balance.

  * `rewardDestination` — rewards destination account address.

  * `createdAt` — timestamp of the transaction in the ISO 8601 format.

### 2. Sign and send transaction

Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the Sui-specific signing logic.

To broadcast the signed transaction to the Sui network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send).

Example request:

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
    --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "chain": "sui",
      "network": "testnet",
      "stakerAddress": "0xe6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b6",
      "signedTransaction": "signature",
      "extra": {
        "unsignedTransaction": "0x000003000800ca9a3b00000000010100000000000000000000000000000000000000000000000000000000000000050100000000000000010020ab4fb3eeaa7b0ab4f91eedab33adf140c6750e60ca5e44b3df82491937d7bab4020200010100000000000000000000000000000000000000000000000000000000000000000000030a7375695f73797374656d11726571756573745f6164645f7374616b6500030101000200000102002c0def86e107ae6ca6a610b4188bb3c2802c30350ac01817be6a02d2a247faf5012a009f3cd4188b8363f5d6a9af5875a0ac663abd1c1bd706be6036d7c51d548d4400001800000000209f43be7aae4cb75d3995057ba075a5cfdc55c3fe6a6cfab5f034309807f5f6072c0def86e107ae6ca6a610b4188bb3c2802c30350ac01817be6a02d2a247faf5e803000000000000809698000000000000"
      }
    }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — account address initiating the staking transaction.
* `signedTransaction` — signature produced for the `unsignedTransactionData`.
* `extra` — additional parameters:
  * `unsignedTransaction` — 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:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "extraData": {
              "transactionDigest": "9ugm8p16MZtDGuMz6uHq7cPJw9GY6mYaZqtyeyx1FJiD"
          }
      }
  }
  ```
</CodeGroup>

* `extraData` — additional transaction details:
  * `transactionDigest` — transaction hash to check the transaction in Sui explorers.

## Unstaking flow

### 1. Create withdrawal request

Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-unstake-transaction).

Example request:

<CodeGroup>
  ```bash bash theme={null}
  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": "sui",
      "network": "testnet",
      "stakerAddress": "0xe6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b6",
      "extra": {
        "stakeId": "0x5d920b8fca6a6043d898ab1a9a8ab167d8aa323fe2b9e76a27312f7f16e20a67"
      }
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — account address initiating the withdrawal transaction.
* `extra`— additional parameters:
  * `stakeId`— identifier of the stake, required to perform a withdrawal.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "unsignedTransactionData": "0x000002010100000000000000000000000000000000000000000000000000000000000000050100000000000000010100421468e81f68bcce235e4d95e6bb318d7ed9a7f223edd4080f2c2c7fcc5ea6840f97531a0000000020300486c82d75f9d990e1238453677a9ef0f62104723a5bcbd7a9a300a07c7afc010000000000000000000000000000000000000000000000000000000000000000030a7375695f73797374656d16726571756573745f77697468647261775f7374616b650002010000010100e6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b601639ace0ef7601462aa3ee0babfccfdbd7972e30cb6b0990546b9678ff347b8fa9c955e1a00000000206fa50de99c02fd418f1df30f18f918f74d165eea343164ac39d98c2dbb1424f9e6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b6e803000000000000809698000000000000"
      }
  }
  ```
</CodeGroup>

* `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action.

### 2. Sign and send transaction

Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Sui-specific signing logic.


## Related topics

- [Unified API Reference](/reference/unified-create-stake-transaction.md)
- [Integration Workflow Example](/docs/unified-api-getting-started.md)
- [Networks](/docs/unified-api-networks.md)
