Subgraphs

This page lists all the Subgraphs deployed and managed by the Orium team.

As mentioned before, the team is working on deploying the contracts and subgraphs in as many blockchains as possible. Here you will find all the Subgraph instances already deployed, but you can always request additional blockchains on Contact

Roles Registry

Github: https://github.com/OriumNetwork/roles-subgraph

Tracks roles granted and revoked using the ERC-7432 standard.

BlockchainGraphQL PlaygroundGraphQL Endpoint

Polygon

Cronos

Sample Queries

Fetch all NFTs of a user given its address

Returns all the NFTs of the given user. If the user has delegated their NFTs, the roleAssignments array will contain the grantee (borrower), and the expiration date.

Query

query findAllNftsOfUser($userAddress: String!, $tokenAddresses: [String!], $roles: [Bytes!], $now: BigInt, $rolesRegistry: String) {
  account(id: $userAddress) {
    id
    nfts(where: {tokenAddress_in: $tokenAddresses}) {
      tokenAddress
      tokenId
      roles(where: {roleHash_in: $roles, rolesRegistry: $rolesRegistry}) {
        id
        roleAssignments(where: {grantor: $userAddress, expirationDate_gt: $now}, orderBy: updatedAt, orderDirection: desc, first: 1) {
          grantee {
            id
          }
          expirationDate
          revocable
          data
          updatedAt
        }
      }
    }
  }
}

Variables

  • userAddress: The user's wallet address (in lowercase).

  • now: The current time in Unix timestamp.

  • roles: keccak of the role name (in lowercase).

  • tokenAddresses: List of the NFT's contract addresses (all in lowercase).

  • rolesRegistry: The address of the contract responsible for tracking roles (in lowercase).

{
  "userAddress": "0x04c8c6c56dab836f8bd62cb6884371507e706806",
  "now": "1697815832",
  "roles": [ "0x3d926b0dd5f4880fb18c9a49c890c7d76c2a97e0d4b4c20f1bb3fe6e5f89f0f4" ],
  "tokenAddresses": [ "0xa03c4e40d1fcaa826591007a17ca929ef8adbf1c" ],
  "rolesRegistry":"0xb2ad616e84e1ef7a9ed0fa3169aaf31ee51ea824"
}

Response

{
  "data": {
    "account": {
      "id": "0x04c8c6c56dab836f8bd62cb6884371507e706806",
      "nfts": [
        {
          "tokenAddress": "0xa03c4e40d1fcaa826591007a17ca929ef8adbf1c",
          "tokenId": "217",
          "roles": [
            {
              "id": "0xb2ad616e84e1ef7a9ed0fa3169aaf31ee51ea824-0xa03c4e40d1fcaa826591007a17ca929ef8adbf1c-217-0x3d926b0dd5f4880fb18c9a49c890c7d76c2a97e0d4b4c20f1bb3fe6e5f89f0f4",
              "roleAssignments": [
                {
                  "grantee": {
                    "id": "0xf446ed093f4223d1d8ffe2474938dac6b7f78c94"
                  },
                  "expirationDate": "1701982093",
                  "revocable": true,
                  "data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000e4348524f4e4f535f504c41594552000000000000000000000000000000000000",
                  "updatedAt": "1701895803"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}
Fetch all borrowed NFTs of a user

Return all the NFTs delegated to a given user.

Query

query findNftsDelegatedToUser($userAddress: String!, $tokenAddresses: [String!], $roles: [Bytes!], $rolesRegistry: String, $now: BigInt) {
  roles(
    where: { 
      roleHash_in: $roles,
      rolesRegistry: $rolesRegistry,
      roleAssignments_: { grantee: $userAddress, expirationDate_gt: $now },
      nft_: { tokenAddress_in: $tokenAddresses }
    }
  ) {
    nft {
      tokenAddress
      tokenId
    }
    roleAssignments(orderBy: updatedAt, orderDirection: desc, first: 1) {
      grantor {
        id
      }
      expirationDate
      revocable
      data
      updatedAt
    }
  }
}

Variables

  • userAddress: The user's wallet address (in lowercase).

  • now: The current time in Unix timestamp.

  • roles: keccak of the role name (in lowercase).

  • tokenAddresses: List of the NFT's contract addresses (all in lowercase).

  • rolesRegistry: The address of the contract responsible for tracking roles (in lowercase).

{
  "userAddress": "0xf446ed093f4223d1d8ffe2474938dac6b7f78c94",
  "now": "1702068926",
  "roles": [ "0x045820b3f199e0a7e9f6d6ea9d721736bfc1a774436a2289eeb2424c9aa73115" ],
  "tokenAddresses": [ "0xa03c4e40d1fcaa826591007a17ca929ef8adbf1c" ],
  "rolesRegistry":"0xb2ad616e84e1ef7a9ed0fa3169aaf31ee51ea824"
}

Response

{
  "data": {
    "roles": [
      {
        "nft": {
          "tokenAddress": "0xa03c4e40d1fcaa826591007a17ca929ef8adbf1c",
          "tokenId": "217"
        },
        "roleAssignments": [
          {
            "grantor": {
              "id": "0x04c8c6c56dab836f8bd62cb6884371507e706806"
            },
            "expirationDate": "1702155856",
            "revocable": true,
            "data": "0x",
            "updatedAt": "1701896664"
          }
        ]
      }
    ]
  }
}

Pagination

TheGraph implements pagination with two additional parameters:

  • first: Number of entities requested (defaults to 100).

  • skip: Number of entities to skip (defaults to 0).

In a nutshell, you can query the first 100 entities by passing first: 100, skip: 0, but to query for the next 100 entities, you should use first: 100, skip: 100.

You can learn more about pagination with TheGraph in the official documentation.

Last updated