{"id":19233444,"url":"https://github.com/hop-protocol/subgraph","last_synced_at":"2025-04-16T14:38:40.851Z","repository":{"id":43168453,"uuid":"380665154","full_name":"hop-protocol/subgraph","owner":"hop-protocol","description":"🇬 The Hop Protocol v1 Subgraphs for The Graph","archived":false,"fork":false,"pushed_at":"2024-06-05T08:41:39.000Z","size":1108,"stargazers_count":25,"open_issues_count":0,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T05:23:27.504Z","etag":null,"topics":["graphql","hop","hop-protocol","subgraph","thegraph","thegraphprotocol"],"latest_commit_sha":null,"homepage":"https://github.com/hop-protocol/hop-subgraph","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hop-protocol.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":"2021-06-27T06:11:13.000Z","updated_at":"2024-09-11T13:38:58.000Z","dependencies_parsed_at":"2023-11-07T02:24:16.782Z","dependency_job_id":"7c3870fe-e11b-4e1a-9c6b-e92b8c137baf","html_url":"https://github.com/hop-protocol/subgraph","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-protocol%2Fsubgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-protocol%2Fsubgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-protocol%2Fsubgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-protocol%2Fsubgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hop-protocol","download_url":"https://codeload.github.com/hop-protocol/subgraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249250939,"owners_count":21237965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["graphql","hop","hop-protocol","subgraph","thegraph","thegraphprotocol"],"created_at":"2024-11-09T16:10:34.578Z","updated_at":"2025-04-16T14:38:40.815Z","avatar_url":"https://github.com/hop-protocol.png","language":"TypeScript","readme":"# Hop Subgraph\n\n\u003e The Hop Protocol Subgraph for [The Graph](https://thegraph.com/).\n\n\n## Subgraphs\n\nMainnet\n\n- [Mainnet](https://thegraph.com/explorer/subgraph/hop-protocol/hop-mainnet)\n- [Polygon](https://thegraph.com/explorer/subgraph/hop-protocol/hop-polygon)\n- [xDai](https://thegraph.com/explorer/subgraph/hop-protocol/hop-xdai)\n- [Optimism](https://thegraph.com/explorer/subgraph/hop-protocol/hop-optimism)\n- [Arbitrum](https://thegraph.com/explorer/subgraph/hop-protocol/hop-arbitrum)\n- [Base](https://thegraph.com/explorer/subgraph/hop-protocol/hop-base)\n\nGoerli\n\n- [Goerli](https://thegraph.com/explorer/subgraph/hop-protocol/hop-goerli)\n- [Mumbai](https://thegraph.com/explorer/subgraph/hop-protocol/hop-mumbai)\n- [Optimism Goerli](https://thegraph.com/explorer/subgraph/hop-protocol/hop-optimism-goerli)\n\n## Development\n\n### Authenticate\n\n```bash\nnpx graph auth https://api.thegraph.com/deploy/ \u003caccess-token\u003e\n```\n\nThe access token is found on the hosted-service [dashboard](https://thegraph.com/hosted-service/dashboard).\n\n## Instructions to Add new chain config or new addresses\n\n1. Update `scripts/mapping_config.json` with the new chain network and subgraph name mapping.\n\n2. Update the `@hop-protocol/sdk` package version in `package.json`.\n\n3. Add the `build-deploy` npm script in `package.json`.\n\n4. Update `.gitignore` and `clean.sh` (this step can probably be automated).\n\n5. Run `npm i` to install the latest `@hop-protocol/sdk` package\n\n6. Run `npm run generate-config-json` to create the updated config files\n\nThe config generation script is run automatically when building the subgraph with npm `build-deploy` command and can also be ran with `npm run generate-config-json`.\n\nThe generation script `scripts/generate_config_json.js` will read the chain/token config from `@hop-protocol/sdk` and output/override the config JSON files to `config/`.\n\n7. [Install Docker](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository)\n\n8. After bumping the version of `@hop-protocol/sdk` in `package.json` and pushing to github and github action finishes building the [docker image](https://hub.docker.com/r/hopprotocol/subgraph), run the following commands to build and deploy the subgraph locally or on a server using docker compose:\n\n```bash\n# change this values to deploy a different subgraph. Refer to `scripts/mapping_config.json` for the subgraph name\nexport NETWORK=base-goerli\nexport RPC=https://goerli.base.org\n\n# download docker-compose file\nwget https://raw.githubusercontent.com/hop-protocol/subgraph/master/docker-compose.yml\n\n# start services\n# the `-d` is used to run in background\n# the `--pull=always` is used to update the image when there is one available\n\n# NOTE: The NETWORK and RPC are redundant, but sometimes cause issues if they do not exist\nsudo RPC=https://rpc.linea.build NETWORK=linea docker compose up --pull=always\n```\n\nAfter a minute or so the graph should be available at http://localhost:8000/subgraphs/name/hop-protocol/hop-base-goerli/graphql\n\n9. Troubleshooting\n\n* If your server is unreachable from outside, ensure you enabled port `8000` with UFW\n  * Disable and enable UFW after this\n\n## Pre-setup notes\n\n_**These are deprecated in favor of the local Docker instructions. Only reference these if Docker is not used.**_\n\n```bash\n# Required for AbortController\nnvm install 16.6.1\nnvm use 16.6.1\n\n# Various requirements\nsudo apt install npm\nsudo apt install -y jq\nnpm i @graphprotocol/graph-cli@0.53.0\n``````\n\n#### Troubleshooting\n\n- Depending on your NPM version, oboe@2.1.4  \u0026 multiaddr@6.1.1 appears to hang when installing NPM packages. In reality, they just take a long time to install (up to or over an hour, depending on the instance type \u0026 resources).\n\n- Auth key starts with 70cc\n\n- When setting it up locally and running a load balancer, each of these should work for debugging at various stages\n  - http://ec2...com:8000/subgraphs/name/hop-protocol/hop-base-mainnet\n  - http://lb...com/subgraphs/name/hop-protocol/hop-base-mainnet\n  - https://base.subgraph.hop.exchange/subgraphs/name/hop-protocol/hop-base\n\n\n- If you get the following error, you need to run comment out two lines in `buildfile.template.sh`\n\n```\n# Error\nFailed to deploy to Graph node https://api.thegraph.com/deploy/: subgraph failure::Subgraph [hop-protocol/hop-base-mainnet] not found\n\n# Lines to comment\nnpx graph auth https://api.thegraph.com/deploy/ $ACCESS_TOKEN\nnpx graph deploy --product hosted-service --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ \"$GITHUB_ORG/{{subgraphName}}\"\n```\n### Build and deploy\n\n```bash\nnpm run build-deploy:mainnet\nnpm run build-deploy:mainnet-subgraph-studio\nnpm run build-deploy:polygon\nnpm run build-deploy:xdai\nnpm run build-deploy:optimism\nnpm run build-deploy:arbitrum\n\n# testnet\nnpm run build-deploy:goerli\nnpm run build-deploy:mumbai\nnpm run build-deploy:optimism-goerli\n\n# local\nnpm run build-deploy:arbitrum-goerli\nnpm run build-deploy:nova\nnpm run build-deploy:zksync\nnpm run build-deploy:base-goerli\nnpm run build-deploy:base-mainnet\nnpm run build-deploy:linea\nnpm run build-deploy:polygonzk\n```\n\nBy default, it will deploy under `hop-protocol` github org.\n\nSet `GITHUB_ORG` to deploy another a different account.\n\nExample:\n\n```bash\nGITHUB_ORG=\u003cgithub-username\u003e npm run build-deploy:mainnet\n```\n\nThe following subgraphs will need to be created on the dashboard:\n\n- `hop-mainnet`\n- `hop-polygon`\n- `hop-xdai`\n- `hop-optimism`\n- `hop-arbitrum`\n- `hop-goerli`\n- `hop-mumbai`\n- `hop-optimism-goerli`\n\n### Clean build files:\n\n```bash\nnpm run clean\n```\n\n## Deploying locally:\n\nUpdate networks in `docker-compose.yml`:\n\nFor Optimism Regenesis:\n\n```yml\nethereum: 'optimism:https://mainnet-replica-4.optimism.io'\n```\n\nFor Arbitrum Nova:\n\n```yml\nethereum: 'nova:https://nova.arbitrum.io/rpc'\n```\n\nFor zkSync:\n\n```yml\nethereum: 'zksync:https://zksync2-testnet.zksync.dev'\n```\n\nFor Base:\n\n```yml\nethereum: 'base-mainnet:https://developer-access-mainnet.base.org'\n```\n\nFor Linea:\n\n```yml\nethereum: 'linea:https://rpc.linea.build'\n```\n\nFor Polygonzk:\n\n```yml\nethereum: 'polygonzk:https://zkevm-rpc.com'\n```\n\nFor Linea (Goerli):\n\n```yml\nethereum: 'linea-goerli:https://consensys-zkevm-goerli-prealpha.infura.io/v3/YOUR_PROJECT_ID'\n```\n\nFor Base (Goerli):\n\n```yml\nethereum: 'base-goerli:https://goerli.base.org'\n```\n\nFor Arbitrum (Goerli):\n\n```yml\nethereum: 'arbitrum-goerli:https://goerli-rollup.arbitrum.io/rpc'\n```\n\nStart containers:\n\n```bash\ndocker-compose up\n```\n\nCreate local subgraph (in another terminal):\n\nFor Optimism Regenesis:\n\n```bash\nnpx graph create hop-protocol/hop-optimism --node http://127.0.0.1:8020\n```\n\nFor Arbitrum Nova:\n\n```bash\nnpx graph create hop-protocol/hop-nova --node http://127.0.0.1:8020\n```\n\nFor zkSync:\n\n```bash\nnpx graph create hop-protocol/hop-zksync --node http://127.0.0.1:8020\n```\n\nFor Base:\n\n```bash\nnpx graph create hop-protocol/hop-base-mainnet --node http://127.0.0.1:8020\n```\n\nFor Base:\n\n```bash\nnpx graph create hop-protocol/hop-linea --node http://127.0.0.1:8020\n```\n\nFor Polygonzk:\n\n```bash\nnpx graph create hop-protocol/hop-polygonzk --node http://127.0.0.1:8020\n```\n\nFor Linea (Goerli):\n\n```bash\nnpx graph create hop-protocol/hop-linea-goerli --node http://127.0.0.1:8020\n```\n\nFor Base (Goerli):\n\n```bash\nnpx graph create hop-protocol/hop-base-goerli --node http://127.0.0.1:8020\n```\n\nFor Arbitrum (Goerli):\n\n```bash\nnpx graph create hop-protocol/hop-arbitrum-goerli --node http://127.0.0.1:8020\n```\n\nDeploy subgraph after building (add this line at the bottom of `buildfiles.template.sh` and comment out existing `npx graph deploy` line):\n\nFor Optimism Regenesis:\n\n```bash\nnpx graph deploy --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-optimism\n```\n\nFor Arbitrum Nova:\n\n```bash\nnpx graph deploy --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-nova\n```\n\nFor zkSync:\n\n```bash\nnpx graph deploy --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-zksync\n```\n\nFor Base:\n\n```bash\nnpx graph deploy --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-base-mainnet\n```\n\nFor Linea:\n\n```bash\nnpx graph deploy --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-linea\n```\n\nFor Polygonzk:\n\n```bash\nnpx graph deploy --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-polygonzk\n```\n\nFor Linea (Goerli):\n\n```bash\nnpx graph deploy --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-linea-goerli\n```\n\nFor Base (Goerli):\n\n```bash\nnpx graph deploy --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-base-goerli\n```\n\nFor Arbitrum (Goerli):\n\n```bash\nnpx graph deploy --debug --ipfs http://localhost:5001 --node http://localhost:8020 hop-protocol/hop-arbitrum-goerli\n```\n\nBuild and deploy:\n\nFor Optimism Regenesis:\n\n```bash\nnpm run build-deploy:optimism\n```\n\nFor Arbitrum Nova:\n\n```bash\nnpm run build-deploy:nova\n```\n\nFor zkSync:\n\n```bash\nnpm run build-deploy:zksync\n```\n\nFor Base:\n\n```bash\nnpm run build-deploy:base-mainnet\n```\n\nFor Linea:\n\n```bash\nnpm run build-deploy:linea\n```\n\nFor Polygonzk:\n\n```bash\nnpm run build-deploy:polygonzk\n```\n\nFor Linea (Goerli):\n\n```bash\nnpm run build-deploy:linea-goerli\n```\n\nFor Base (Goerli):\n\n```bash\nnpm run build-deploy:base-goerli\n```\n\nFor Arbitrum (Goerli):\n\n```bash\nnpm run build-deploy:arbitrum-goerli\n```\n\nQuery subgraphs\n\nFor Optimism Regenesis:\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-optimism\n\nFor Arbitrum Nova:\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-nova\n\nFor zkSync:\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-zksync\n\nFor Base:\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-base-mainnet\n\nFor Linea:\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-linea\n\nFor Polygonzk:\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-polygonzk\n\nFor Linea (Goerli):\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-linea-goerli\n\nFor Base (Goerli):\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-base-goerli\n\nFor Arbitrum (Goerli):\n\nhttp://localhost:8000/subgraphs/name/hop-protocol/hop-arbitrum-goerli\n\n## Github Actions\n\nRun github action build locally with [act](https://github.com/nektos/act):\n\n```sh\nact --workflows .github/workflows/build.yml\n```\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhop-protocol%2Fsubgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhop-protocol%2Fsubgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhop-protocol%2Fsubgraph/lists"}