> ## 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.

# The Graph

> Unified API + The Graph Integration Workflow

In the following guide, the integration process for the `grt` chain is covered. The Graph 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 Graph-specific details**

  * `chain` — always set to `grt` for Graph-related requests.
  * `network` — environment in which the transaction is processed: `mainnet` only.
  * `stakerAddress` — Ethereum-compatible account address initiating staking, unstaking or withdrawal transactions.
  * `amount` — amount of tokens in GRT.
</Note>

## Staking flow

### 1. Approve token management

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

Example request:

<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": "grt",
    "network": "mainnet",
    "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
    "amount": "1",
    "extra": {
      "operationType": "approve"
    }
  }'
  ```
</CodeGroup>

* `chain` — blockchain network, always set to `grt` for The Graph-related requests.
* `network` — environment in which the transaction is processed: `mainnet` only.
* `stakerAddress` — Ethereum-compatible account address initiating the approval transaction.
* `amount` — amount of tokens to approve in GRT. Minimum amount is 1 GRT.
* `extra` — additional parameters:
  * `operationType` — type of operation; set to `approve` to approve token transferring.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "amount": 1,
          "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
          "unsignedTransactionData": "{\"from\":\"0x368F823e4dfe271dc820f4Ea14689917bf8e4a21\",\"gasLimit\":\"0x012bee\",\"to\":\"0x9623063377AD1B27544C965cCd7342f7EA7e88C7\",\"data\":\"0x095ea7b3...\",\"nonce\":13,\"type\":2,\"maxFeePerGas\":\"0x01312d00\",\"maxPriorityFeePerGas\":\"0x00\",\"chainId\":42161}",
          "createdAt": "2025-05-29T00:19:57.734Z",
          "extraData": {
              "transactionId": "d3e006d5-3652-4265-b54b-dcff52753622",
              "stakeId": "5eacf5b6-a366-4376-beab-84e50c426a31",
              "gasEstimate": {
                  "amount": "0.000001535640000000",
                  "gasLimit": "76782"
              }
          }
      }
  }
  ```
</CodeGroup>

* `amount` — amount of tokens to approve in GRT.

* `stakerAddress` — Ethereum-compatible account address initiating the approval transaction.

* `unsignedTransactionData` — unsigned transaction in JSON format ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)). 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 session.

  * `stakeId` — unique identifier of the approval request.

  * `gasEstimate` — estimated gas usage details:

    * `amount` — estimated fee in ETH for processing the transaction.
    * `gasLimit` — maximum gas limit for the transaction.

### 2. Sign and send transaction

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

To broadcast the signed transaction to the Graph 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 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '{
      "chain": "grt",
      "network": "mainnet",
      "signedTransaction": "<signed_approval_tx_hex>",
      "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
      "extra": {
          "transactionId": "d3e006d5-3652-4265-b54b-dcff52753622"
      }
  }'
  ```
</CodeGroup>

* `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` — Ethereum-compatible account address initiating the transaction.
* `extra` — additional parameters:
  * `transactionId` — unique identifier of the approval transaction.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "extraData": {
              "transactionHash": "0x8592d8d4657b735b3662132c0f7b271f49796a8a716ae81bc448513bcefc880f"
          }
      }
  }
  ```
</CodeGroup>

* `extraData` — additional transaction details:
  * `transactionHash` — transaction hash.

### 3. Create staking request

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

Example request:

<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": "grt",
    "network": "mainnet",
    "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
    "amount": "1"
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — Ethereum-compatible account address initiating the staking transaction.
* `amount` — amount of tokens to delegate in GRT. Minimum amount is 1 GRT.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "amount": 1,
          "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
          "unsignedTransactionData": "{\"from\":\"0x368F823e4dfe271dc820f4Ea14689917bf8e4a21\",\"gasLimit\":\"0x01f998\",\"to\":\"0x00669A4CF01450B64E8A2A20E9b1FCB71E61eF03\",\"data\":\"0x026e402b...\",\"nonce\":15,\"type\":2,\"maxFeePerGas\":\"0x014f4420\",\"maxPriorityFeePerGas\":\"0x00\",\"chainId\":42161}",
          "createdAt": "2025-05-29T00:28:32.621Z",
          "extraData": {
              "transactionId": "1a605e71-ecae-4b50-b202-092b163a1b0f",
              "stakeId": "2a0269a7-6aeb-42e5-8f46-2f8fb69d48ac",
              "gasEstimate": {
                  "amount": "0.000002843879904000",
                  "gasLimit": "129432"
              }
          }
      }
  }
  ```
</CodeGroup>

* `amount` — amount of tokens to delegate in GRT.

* `stakerAddress` — Ethereum-compatible account address initiating the staking transaction.

* `unsignedTransactionData` — unsigned transaction in JSON format ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)). 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 of the staking request.

  * `gasEstimate` — estimated gas usage details:

    * `amount` — estimated fee in ETH for processing the transaction.
    * `gasLimit` — maximum gas limit for the transaction.

### 4. Sign and send transaction

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

## Unstaking flow

### 1. Create unstaking request

<Warning>
  Note that currently only full unstake is supported, partial withdrawals are unavailable. Regardless of the amount specified, the entire stake is removed.
</Warning>

Send a POST request to [/api/v1/unified/staking/unstake](/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/unstake \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '{
    "chain": "grt",
    "network": "mainnet",
    "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
    "extra": {
      "amount": 1
    }
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — Ethereum-compatible account address initiating the unstaking transaction.
* `extra` — additional parameters:
  * `amount` — amount of tokens to unstake in GRT; to be ignored since only full unstake is available.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "amount": 1,
          "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
          "unsignedTransactionData": "{\"from\":\"0x368F823e4dfe271dc820f4Ea14689917bf8e4a21\",\"gasLimit\":\"0x01b174\",\"to\":\"0x00669A4CF01450B64E8A2A20E9b1FCB71E61eF03\",\"data\":\"0x4d99dd16...\",\"nonce\":16,\"type\":2,\"maxFeePerGas\":\"0x01de5520\",\"maxPriorityFeePerGas\":\"0x00\",\"chainId\":42161}",
          "createdAt": "2025-05-29T00:30:26.502Z",
          "extraData": {
              "transactionId": "57481121-14fa-4c31-ab29-13b80cf26242",
              "stakeId": "7763655a-6e2b-466c-8c9f-997e848a5787",
              "gasEstimate": {
                  "amount": "0.000003478499472000",
                  "gasLimit": "110964"
              }
          }
      }
  }
  ```
</CodeGroup>

* `amount` — amount of tokens to unstake in GRT; to be ignored since only full unstake is available.

* `stakerAddress` — Ethereum-compatible account address initiating the unstaking transaction.

* `unsignedTransactionData` — unsigned transaction in JSON format ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)). 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 unstaking session.

  * `stakeId` — unique identifier of the unstaking request.

  * `gasEstimate` — estimated gas usage details:

    * `amount` — estimated fee in ETH for processing the transaction.
    * `gasLimit` — maximum gas limit for the transaction.

### 2. Sign and send transaction

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

### 3. Create withdrawal request

<Note>
  Note that the withdrawal is available only after the unbonding period of 28 days ends.
</Note>

Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-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": "grt",
    "network": "mainnet",
    "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — Ethereum-compatible account address initiating the withdrawal transaction.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "amount": 1,
          "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
          "unsignedTransactionData": "{\"from\":\"0x368F823e4dfe271dc820f4Ea14689917bf8e4a21\",\"gasLimit\":\"0x01b174\",\"to\":\"0x00669A4CF01450B64E8A2A20E9b1FCB71E61eF03\",\"data\":\"0x4d99dd16...\",\"nonce\":16,\"type\":2,\"maxFeePerGas\":\"0x01de5520\",\"maxPriorityFeePerGas\":\"0x00\",\"chainId\":42161}",
          "createdAt": "2025-05-29T00:30:26.502Z",
          "extraData": {
              "transactionId": "57481121-14fa-4c31-ab29-13b80cf26242",
              "stakeId": "7763655a-6e2b-466c-8c9f-997e848a5787",
              "gasEstimate": {
                  "amount": "0.000003478499472000",
                  "gasLimit": "110964"
              }
          }
      }
  }
  ```
</CodeGroup>

* `amount` — amount of tokens to withdraw in GRT.

* `stakerAddress` — Ethereum-compatible account address initiating the withdrawal transaction.

* `unsignedTransactionData` — unsigned transaction in JSON format ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)). 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 fee in ETH for processing the transaction.
    * `gasLimit` — maximum gas limit for the transaction.

### 4. Sign and send transaction

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


## Related topics

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