{"id":18492984,"url":"https://github.com/graphprotocol/origin-subgraph","last_synced_at":"2025-05-14T01:13:04.997Z","repository":{"id":43019879,"uuid":"164510480","full_name":"graphprotocol/origin-subgraph","owner":"graphprotocol","description":"Origin is a protocol for creating peer-to-peer marketplaces using the Ethereum blockchain and IPFS.","archived":false,"fork":false,"pushed_at":"2022-03-22T23:54:50.000Z","size":136,"stargazers_count":0,"open_issues_count":2,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-16T23:13:10.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphprotocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-07T22:57:19.000Z","updated_at":"2019-10-28T12:21:58.000Z","dependencies_parsed_at":"2022-09-09T13:40:29.465Z","dependency_job_id":null,"html_url":"https://github.com/graphprotocol/origin-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/graphprotocol%2Forigin-subgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphprotocol%2Forigin-subgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphprotocol%2Forigin-subgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphprotocol%2Forigin-subgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphprotocol","download_url":"https://codeload.github.com/graphprotocol/origin-subgraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254049879,"owners_count":22006171,"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":[],"created_at":"2024-11-06T13:12:07.677Z","updated_at":"2025-05-14T01:13:04.957Z","avatar_url":"https://github.com/graphprotocol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Origin-subgraph\n[Origin](https://github.com/OriginProtocol) is a protocol for creating peer-to-peer marketplaces using the Ethereum blockchain and IPFS.\n\n## Events and Contracts\n\nThe Origin smart contracts are set up so that the majority of the events are emitted from a single address. The Solidity file that has these events is `Marketplace.sol`.\n\nAll events in this subgraph are tracked.\n\nThis subgraph can be used for Origin on the mainnet, and all testnets. In order to run it for a \ntestnet, the `subgraph.yaml` file will need to have the contract addresses changed to point to the \ncorrect address for each respective network.\n\nThe subgraph takes less than 10 minutes to sync. \n\n\u003e Note - This subgraph currently only `ipfs cats` up to block 7,100,000 for the mappings. This is because the ipfs node running alongside The Graph Node get hung \nup on searching for the file for too long, so they are pinned up to there. The subgraph should be able to connect to the origin ipfs node via swarm, but we are waiting to coordinate that. You can access all the origin IPFS files through https at `https://ipfs.originprotocol.com/ipfs/`.\n\n## Brief Description of The Graph Node Setup\n\nA Graph Node can run multiple subgraphs. The subgraph ingests event data by calling to Infura through http. It can also connect to any geth node or parity node that accepts RPC calls. Fast synced geth nodes work. To use parity, the `--no-warp` flag must be used. Setting up a local Ethereum node is more reliable and faster, but Infura is the easiest way to get started. \n\nThis subgraph has three types of files which tell the Graph Node to ingest events from specific contracts. They are:\n* The subgraph manifest (subgraph.yaml)\n* A GraphQL schema      (schema.graphql)\n* Mapping scripts       (marketplace.ts) \n\nThis repository has these files created and ready to compile, so a user can start this subgraph on their own. The only thing that needs to be edited is the contract addresses in the `subgraph.yaml` file to change between mainnet and testnets.  \n\nWe have provided a quick guide on how to start up the origin-subgraph graph node below. If these steps aren't descriptive enough, the [getting started guide](https://github.com/graphprotocol/graph-node/blob/master/docs/getting-started.md) has in depth details on running a subgraph. \n\n## Steps to Deploying The Origin-Subgraph Locally\n  1. Install IPFS and run `ipfs init` followed by `ipfs daemon`\n  2. Install PostgreSQL and run `initdb -D .postgres` followed by `pg_ctl -D .postgres start` and `createdb graph-node-mainnet` (note this db name is used in the commands below for the mainnet examples)\n  3. If using Ubuntu, you may need to install additional packages: `sudo apt-get install -y clang libpq-dev libssl-dev pkg-config`\n  4. Clone this repository, and run the following:\n     * `yarn`\n     * `yarn codegen` \n  5. Clone https://github.com/graphprotocol/graph-node from master and `cargo build` (this might take a while)\n  6. a) Now that all the dependencies are running, you can run the following command to connect to Infura Mainnet (it may take a few minutes for Rust to compile). PASSWORD might be optional, it depends on your postrgres setup:\n\n```\n  cargo run -p graph-node --release -- \\\n  --postgres-url postgresql://USERNAME:[PASSWORD]@localhost:5432/graph-node-mainnet \\\n  --ipfs 127.0.0.1:5001 \\\n  --ethereum-rpc mainnet-infura:https://mainnet.infura.io --debug\n```\n  6. b) Or Mainnet with a Local Ethereum node. This is very common if you are working with brand new contracts, and you have deployed them to a testnet environment like *ganache* (note that ganache commonly uses port 9545 rather than 8545):\n```\n  cargo run -p graph-node --release -- \\\n  --postgres-url postgresql://USERNAME:[PASSWORD]@localhost:5432/graph-node-mainnet \\\n  --ipfs 127.0.0.1:5001 \\\n  --ethereum-rpc mainnet-local:http://127.0.0.1:8545 \n```\n  6. c) Or Infura Rinkeby _(NOTE: Infura testnets are not reliable right now, we get inconsistent results returned. If Rinkeby data is needed, it is suggested to run your own Rinkeby node)_\n```\n    cargo run -p graph-node --release --   \\\n    --postgres-url postgresql://USERNAME:[PASSWORD]@localhost:5432/graph-node-testnet \\\n    --ipfs 127.0.0.1:5001 \\\n    --ethereum-rpc rinkeby-infura:https://rinkeby.infura.io \n\n```\n\n 7. Now create the subgraph locally on The Graph Node with `yarn create-local`. \n  \n 8. Next deploy the Origin subgraph to The Graph Node with `yarn deploy --debug`. You should see a lot of blocks being skipped in the `graph-node` terminal, and then it will start ingesting events from the moment the contracts were uploaded to the network. \n\nNow that you have subgraph is running you may open a [Graphiql](https://github.com/graphql/graphiql) browser at `127.0.0.1:8000` and get started with querying.\n\n## Viewing the Subgraph on the Graph Hosted Service\nThis subgraph has already been deploy to the hosted service, and you can see it under on [The Graph Explorer](https://thegraph.com/explorer/). To understand how deploying to the hosted service works, check out the [Deploying Instructions](https://thegraph.com/docs/deploy-a-subgraph) in the official documentation. The most important part of deploying to the hosted service is ensuring that the npm script for `deploy` is updated to the correct name that you want to deploy with. \n\n## Getting started with querying \n\nBelow are a few ways to show how to query the origin-subgraph for data. \n\n### Querying all User Information\nThe query below shows all the information for one user. This would represent what is on the users profile page in the Origin Dapp. There are many other filtering options that can be used, just check out the [querying api](https://github.com/graphprotocol/graph-node/blob/master/docs/graphql-api.md).\n\n```graphql\n{\n  user(id: \"0x6c6e93874216112ef12a0d04e2679ecc6c3625cc\"){\n    id\n    attestations{\n      id\n      schemaId\n      userAddress\n      issuerURL\n      issueDate\n      issuerName\n      issuerAddress\n      method\n      verified\n      signature\n      signatureVersion\n      base58Hash    \n    }\n    listings{\n      id\n      blockNumber\n      seller\n      depositManager\n      deposit\n      status\n      offers{\n        id\n        listingID\n        blockNumber\n        value\n        commission\n        refund\n        buyer\n        affiliate\n        arbitrator\n        finalizes\n        status\n        base58Hash\n        reviews{\n          id\n          blockNumber\n          schemaId\n          rating\n          text\n          offerID\n        }\n        disputer\n        ruling\n        schemaId\n        listingType\n        unitsPurchased\n        price\n        currency\n        commissionPrice\n        commissionCurrency\n        ipfsCatSuccess\n        offerExtraData{\n          id\n          offerID\n          sender\n          bytesHash\n          base58Hash\n        }\n        extraDataCount\n      }\n      extraDataCount\n      base58Hash\n      price\n      currency\n      commissionAmount\n      commissionCurrency\n      commissionPerUnit\n      commissionPerUnitCurrency\n      schemaId\n      listingType\n      category\n      subCategory\n      language\n      title\n      description\n      unitsTotal\n      dappSchemaId\n      media{\n        id\n        url\n        contentType\n        listingID\n      }\n      ipfsCatSuccess\n    }\n    profile{\n      id\n      firstName\n      lastName\n      description\n      avatar\n      schemaId\n      base58Hash\n    }\n    schemaId\n    ipfsCatSuccess\n  }\n}\n```\n\n### Query all Information on a Listing\nThis query will return all data related to a listing, which would be used for viewing a listing in the Origin Dapp. \n\n```graphql\n{\n  listing(id: \"713\") {\n    id\n    blockNumber\n    seller\n    depositManager\n    deposit\n    status\n    offers {\n      id\n      listingID\n      blockNumber\n      value\n      commission\n      refund\n      buyer\n      affiliate\n      arbitrator\n      finalizes\n      status\n      base58Hash\n      reviews {\n        id\n        blockNumber\n        schemaId\n        rating\n        text\n        offerID\n      }\n      disputer\n      ruling\n      schemaId\n      listingType\n      unitsPurchased\n      price\n      currency\n      commissionPrice\n      commissionCurrency\n      ipfsCatSuccess\n      offerExtraData {\n        id\n        offerID\n        sender\n        bytesHash\n        base58Hash\n      }\n      extraDataCount\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphprotocol%2Forigin-subgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphprotocol%2Forigin-subgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphprotocol%2Forigin-subgraph/lists"}