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 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 Supported section.

📘

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.

Staking Flow

1. Create Approval 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": "grt",
  "network": "mainnet",
  "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
  "amount": "1",
  "extra": {
    "operationType": "approve"
  }
}'
  • 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 request parameters:
    • operationType — type of operation; set to approve to approve token transferring.

Example response:

{
    "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"
            }
        }
    }
}
  • 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). 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 the transaction.

To broadcast the signed transaction to the Graph 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": "grt",
    "network": "mainnet",
    "signedTransaction": "<signed_approval_tx_hex>",
    "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
    "extra": {
        "transactionId": "d3e006d5-3652-4265-b54b-dcff52753622"
    }
}'
  • 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 request parameters:
    • transactionId — unique identifier of the approval transaction.

Example response:

{
    "error": null,
    "result": {
        "extraData": {
            "transactionHash": "0x8592d8d4657b735b3662132c0f7b271f49796a8a716ae81bc448513bcefc880f"
        }
    }
}
  • extraData — additional transaction details:
    • transactionHash — transaction hash.

3. Create Delegate 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": "grt",
  "network": "mainnet",
  "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
  "amount": "1"
}'
  • 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:

{
    "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"
            }
        }
    }
}
  • 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). 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 the transaction following the Graph-specific signing logic.

Unstaking Flow

1. Create Undelegate Request

🚧

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

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": "grt",
  "network": "mainnet",
  "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
  "extra": {
    "amount": 1
  }
}'
  • chain — blockchain network.
  • network — environment in which the transaction is processed.
  • stakerAddress — Ethereum-compatible account address initiating the unstaking transaction.
  • extra — additional request parameters:
    • amount — amount of tokens to unstake in GRT; to be ignored since only full unstake is available.

Example response:

{
    "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"
            }
        }
    }
}
  • 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). 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 the transaction following the Graph-specific signing logic.

3. Create Withdrawal Request

📘

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

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": "grt",
  "network": "mainnet",
  "stakerAddress": "0x368f823e4dfe271dc820f4ea14689917bf8e4a21",
  "extra": {}
}'
  • chain — blockchain network.
  • network — environment in which the transaction is processed.
  • stakerAddress — Ethereum-compatible account address initiating the withdrawal transaction.

Example response:

{
    "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"
            }
        }
    }
}
  • 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). 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 the transaction following the Graph-specific signing logic.

What's Next?