{"id":22699731,"url":"https://github.com/open-attestation/token-registry-subgraph","last_synced_at":"2026-04-28T22:32:14.846Z","repository":{"id":43434163,"uuid":"463233058","full_name":"Open-Attestation/token-registry-subgraph","owner":"Open-Attestation","description":"Subgraph for TradeTrust Token Registry Contracts","archived":false,"fork":false,"pushed_at":"2023-08-11T05:55:13.000Z","size":197,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-16T07:55:58.771Z","etag":null,"topics":["blockchain","ethereum","graphprotocol","subgraph","tradetrust"],"latest_commit_sha":null,"homepage":"https://www.tradetrust.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Open-Attestation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-24T17:08:38.000Z","updated_at":"2025-01-05T19:09:37.000Z","dependencies_parsed_at":"2025-02-04T19:43:17.324Z","dependency_job_id":"55a7d7b4-a8f7-4938-98d3-15b00743dc94","html_url":"https://github.com/Open-Attestation/token-registry-subgraph","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Open-Attestation/token-registry-subgraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Attestation%2Ftoken-registry-subgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Attestation%2Ftoken-registry-subgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Attestation%2Ftoken-registry-subgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Attestation%2Ftoken-registry-subgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Open-Attestation","download_url":"https://codeload.github.com/Open-Attestation/token-registry-subgraph/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Attestation%2Ftoken-registry-subgraph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32402666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","ethereum","graphprotocol","subgraph","tradetrust"],"created_at":"2024-12-10T06:08:26.770Z","updated_at":"2026-04-28T22:32:14.831Z","avatar_url":"https://github.com/Open-Attestation.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Token Registry Subgraph\n\nThe subgraph for the OpenAttestation [Token Registry](https://github.com/Open-Attestation/token-registry) contracts.\n\nThis subgraph allows anyone to easily query the network for information about the records from and create opportunities for applications to build on top of your Token Registry contracts.\n\n## Table of Contents\n- [Development](#development)\n  - [Configuration](#configuration)\n  - [Installation](#installation)\n- [Deployment](#deployment)\n  - [Graph Studio](#graph-studio)\n  - [Hosted Service](#hosted-service)\n- [Example Queries](#example-queries)\n\n## Development\n\n### Configuration\nConfigure your Token Registry contract addresses in the `config.json` file.\n\n```json\n{\n  \"network\": \"mumbai\",\n  \"dataSources\": [\n    {\n      \"address\": \"0xabc\",\n      \"startBlock\": 12345678\n    },\n    ...\n  ]\n}\n```\n\n* The `network` field can be any one of the many network names supported by the Graph protocol, for eg, `mainnet` for Ethereum mainnet, `goerli` for Ethereum Goerli, `matic` for Polygon, `mumbai` for Polygon Mumbai, etc.\n* The `address` is the address of your Token Registry contract and `startBlock` is the start block of your contract.\n* You can index multiple Token Registry contracts by adding to the `dataSources` array\n\n### Installation\nNext, install and generate the subgraph:\n\n```\n# Install all dependencies\nnpm install\n\n# Generate the subgraph\nnpm run codegen\n\n# You can also build the subgraph:\nnpm run build\n```\n\nAfter the installation, the `subgraph.yaml` file should be automatically generated for you based on your configurations\nin `config.json`. If you have changes in `config.json`, you will need to run the `prepare` script to re-generate it:\n\n```\nnpm run prepare\n```\n\n## Deployment\n\nThe deployment can be done either to the Graph Studio or Hosted Service depending on the network.\n\n### Graph Studio\n\nAuthenticate with your Graph deployment key:\n\n```\ngraph auth\n```\n\nThen deploy the subgraph:\n\n```\nnpm run deploy:studio\n```\n\nThis deploys the subgraph under the name `token-registry-subgraph`. You can change the name in the `package.json` file.\n\n### Hosted Service\n\nAuthenticate with your Graph deployment key:\n\n```\ngraph auth --product hosted-service\n```\n\nThen deploy the subgraph:\n\n```\ngraph deploy --product hosted-service GITHUB_USERNAME/token-registry-subgraph\n```\n\nAlternatively, you can edit the Github username and subgraph name in `package.json` and run `npm run deploy:hosted` to\ndeploy the subgraph to the hosted service.\n\n### Example Queries\n\nThere are many interesting queries that can be made. Here are some example queries:\n\n* What are all the document IDs and their surrender statuses in my Token Registries?\n  ```graphql\n  {\n    tokenRegistries {\n      tokens {\n        documentId\n        surrendered\n      }\n    }\n  }\n  ```\n* What are all the documents that the user `0xbabe` is currently a beneficiary?\n  ```graphql\n  {\n    accounts(where: { id: \"0xbabe\" }) {\n      id\n      titleEscrowsAsBeneficiary {\n        token {\n          documentId\n        }\n      }\n    }\n  }\n  ```\n* What about listing snapshots of a document at the time of all actions (issuance, surrender, etc)?\n  ```graphql\n  {\n    tokens(\n      where: { documentId: \"0x0ddba11\" }\n    ) {\n      tokenSnapshots (orderBy: timestamp) {\n        timestamp\n        action\n        beneficiary {\n          id\n        }\n        holder {\n          id\n        }\n        nominee {\n          id\n        }\n        surrendered\n        accepted \n      }\n    }\n  }\n  ```  \n* Can I have the complete token transfers (including holder transfers) and approval histories of the document ID `0x0ddba11`? I want to know the beneficiaries and holders that were transferred to and from.\n  \u003e 💡 This query is useful (and also a much easier and elegant way) for building the [endorsement chain](https://docs.tradetrust.io/docs/tradetrust-website/endorsement-chain/) of a document or just trying to retrieve the ownership details of any documents.\n  ```graphql\n  {\n    tokens(\n      where: { documentId: \"0x0ddba11\" }\n    ) {\n      beneficiaryTransfers(orderBy: timestamp) {\n        timestamp\n        from {\n          id\n        }\n        to {\n          id\n        }\n      }\n      holderTransfers(orderBy: timestamp) {\n        timestamp\n        from {\n          id\n        }\n        to {\n          id\n        }\n      }\n      nominations(orderBy: timestamp) {\n        timestamp\n        nominee {\n          id\n        }\n      }\n    }\n  }\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-attestation%2Ftoken-registry-subgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-attestation%2Ftoken-registry-subgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-attestation%2Ftoken-registry-subgraph/lists"}