LogoLogo
These products have been deprecated and are no longer being maintained. For a better experience and support, please check out our new stack Aragon OSx.
Aragon Legacy Documentation
Aragon Legacy Documentation
  • 🔷Aragon
    • Aragon Legacy Documentation
    • Aragon Values, Finances, and Legal
      • Legal and technical infrastructure
      • Financial infrastructure
      • Meet your DAO support network
    • Learn about DAOs
      • What is a DAO?
      • Why do we need DAOs?
      • What is decentralized autonomous governance?
      • What is the AN DAO?
      • TAO Voting
      • Why use Aragon to build a DAO?
  • 🌐Products
    • Prerequisites
    • Quickstart
    • Setting up a Metamask Wallet
      • Getting started with Ethereum
      • Getting started with Goerli Testnet
      • Getting started with Polygon
      • Getting started with Mumbai Testnet
      • Getting started with Harmony
      • Getting started with Harmony testnet
      • Getting started with Metis Andromeda
      • Getting started with Stardust Testnet
      • Getting started with BSC Testnet
      • How to sign a transaction?
      • Import your seed wallet to Metamask
      • Gas Tracker
    • Setting up a Frame Wallet
    • Setting up a Gnosis Safe MultiSig Wallet
    • Aragon Client
      • What is Aragon Client
      • How to create a DAO
        • Templates
        • Using the Company Template
        • Using the Membership Template
        • Use the Reputation template
      • How to create a DAO on Polygon
      • How to create a DAO on Harmony
      • How to navigate your DAO
        • Home
        • The Apps
          • Tokens App
          • Voting App
          • Finance App
          • Agent App
            • How to install the Agent App in your DAO
            • Using Agent with Frame
        • System Setting
          • Permissions Setting
          • App Center
          • Organization Setting
      • After you've started a DAO
        • How to change the Quorum of your DAO
          • Change Quorum using Aragon Console
          • Change Quorum using EVMcrispr
        • How to create a Legal Wrapper for your DAO with Otoco
        • How to Operate your DAO from your Mobile Phone
      • How to Brick your DAO 🧱
    • Aragon Govern
      • What is Aragon Govern?
      • How to create a Govern DAO
      • Navigate into your Govern DAO
        • How to mint and assign DAO tokens to others
        • How to deposit funds
        • Challenging a transaction
      • Reasons for the delay period in the transaction
      • Collateral for scheduling or challenging a transaction. Why?
      • Acting as a guardian for an Aragon Govern dispute
      • Using the Client DAO with the Govern DAO
    • Aragon Voice
      • What is Aragon Voice?
      • Creating a voting proposal
      • Creating a voting proposal using your token
      • Voting on a proposal
    • Aragon Vocdoni
      • What is Aragon Vocdoni
      • Creating a Vodconi organization
      • Accessing your Vocdoni organization
      • Navigating your Vocdoni organization
        • Creating a voting proposal
        • Voting on a proposal (anonymous voting disabled)
        • Voting on a proposal (anonymous voting enabled)
    • Aragon Court
      • What is Aragon Court
      • Court Dashboard
      • Dispute lifecycle
      • Acting as guardian for a dispute
      • Glossary
  • 🛠️Developers
    • Legacy Developer Documentation
    • General Tools
      • The Basics
        • Before starting
        • Quick start
        • Tech Stack
        • App permissions
        • Forwarding
        • Upgradeability
        • Package management
        • Templates
        • Aragon client
        • Human readable transactions
      • Guides
        • How to create your first custom DAO using Aragon CLI!
        • How to use the Agent App
          • Installing Aragon Agent from aragonCLI
          • Setting and Checking permissions
          • Interacting with Aragon Agent
        • How to build your first Aragon App!
        • How to publish an Aragon App to aragonPM
        • How to migrate existing Aragon App to Buidler plugin
        • How to change the Quorum of your DAO
          • Change Quorum using Aragon Console
          • Change Quorum using EVMcrispr
        • Deploying Aragon Client in new Chains
          • Deployments information
            • Harmony testnet
            • BSC Tesnet
            • Harmony
            • Metis stardust
            • Metis Andromeda
        • How to Brick your DAO 🧱
        • How to sign with Web3 providers
          • Setting up a Metamask Wallet
            • Import your seed phrase into Metamask
            • Import your private key into Metamask
            • Sign a transaction with Metamask
          • Setting up a Frame Wallet
            • Sign a Transaction with Frame
        • Troubleshooting
      • aragonOS
        • Introduction
        • Motivations
        • Developing with aragonOS
        • Reference documentation
        • Migrating to aragonOS 4 from aragonOS 3
        • Reference (aragonOS 3)
        • Smart Contract References
          • ACL
            • ACL
            • ACLSyntaxSugar
            • ACLHelpers
            • IACL
            • IACLOracle
          • APM
            • APMNamehash
            • APMRegistry
            • APMInternalAppNames
            • Repo
          • APPS
            • AppProxyBase
            • AppProxyPinned
            • AppProxyUpgradeable
            • AppStorage
            • AragonApp
            • UnsafeAragonApp
          • COMMON
            • Autopetrified
            • ConversionHelpers
            • DelegateProxy
            • DepositableDelegateProxy
            • DepositableStorage
            • EtherTokenConstant
            • IForwarder
            • IForwarderFee
            • IVaultRecoverable
            • Initializable
            • IsContract
            • Petrifiable
            • ReentrancyGuard
            • SafeERC20
            • TimeHelpers
            • Uint256Helpers
            • UnstructuredStorage
            • VaultRecoverable
          • ENS
            • ENSConstants
            • ENSSubdomainRegistrar
          • EVMSCRIPT
            • EVMScriptRegistry
            • EVMScriptRunner
            • IEVMScriptExecutor
            • IEVMScriptRegistry
            • EVMScriptRegistryConstants
            • ScriptHelpers
          • EVMSCRIPT/EXECUTORS
            • BaseEVMScriptExecutor
            • CallsScript
          • FACTORY
            • APMRegistryFactory
            • AppProxyFactory
            • DAOFactory
            • ENSFactory
            • EVMScriptRegistryFactory
          • KERNEL
            • IKernel
            • IKernelEvents
            • Kernel
            • KernelAppIds
            • KernelNamespaceConstants
            • KernelProxy
            • KernelStorage
      • aragonCLI
        • Introduction
        • Main commands
        • DAO commands
        • APM commands
        • IPFS commands
        • Global configuration
      • aragonPM
        • Introduction
        • Architecture
        • Reference documentation
      • aragonAPI
        • Introduction
        • Javascript
          • Quick Start
          • App API
          • React API
          • Wrapper
          • Providers
          • Architecture of apps
          • Background Scripts
      • aragonUI
        • Getting started
        • How to upgrade
        • BASE
          • Spacing
          • Colors
          • Text styles
          • Icons
          • Main
        • ACTIONS
          • Button
          • ContextMenu
        • NAVIGATION
          • Tabs
          • Pagination
          • BackButton
          • Link
          • Header
        • STRUCTURE
          • Bar
          • Box
          • Card
          • Split
          • DataView
          • Table
          • EmptyStateCard
          • IdentityBadge
          • TransactionBadge
          • Tag
          • Accordion
          • Timer
          • TokenAmount
          • EthIdenticon
          • TransactionProgress
        • DATA ENTRY
          • AutoComplete
          • DateRangePicker
          • DropDown
          • Switch
          • Radio
          • CheckBox
          • Slider
          • TextInput
          • SearchInput
          • AddressField
          • RadioGroup
          • RadioList
          • TextCopy
          • Field
        • VISUALIZATION
          • CircleGraph
          • LineChart
          • Distribution
        • FEEDBACK
          • Info
          • ProgressBar
          • LoadingRing
          • Toast
          • SyncIndicator
          • FloatIndicator
        • OVERLAYS
          • Help
          • Popover
          • Modal
          • SidePanel
        • ADVANCES
          • ButtonBase
          • FocusVisible
          • PublicUrl
          • Redraw
          • RedrawFromDate
          • Root
          • RootPortal
          • Viewport
      • aragonDS
        • Guidelines
          • Layout
          • Color
          • Iconography
          • Typography
          • Illustrations
        • Components
          • Overview
      • Aragon Connect
        • Guides
          • Aragon Basics
          • Getting started
          • Usage with React
        • Advanced
          • Custom Subgraph queries
          • Writing an App Subgraph
          • Writing an App Connector
        • Connectors
          • Organizations
          • Tokens app
          • Voting app
          • Finance app
        • API reference
          • connect()
          • App
          • Connectors
          • Organization
          • Permission
          • Repo
          • Role
          • TransactionIntent
          • TransactionPath
          • TransactionRequest
          • Types
          • Errors
      • App Center
        • App Center
        • Preparing Assets
        • Submitting Your App to the App Center
    • Product Tools
      • Aragon Govern
        • README
        • Introduction
          • Concepts and background
            • Govern Core concepts
            • ERC3000
          • Developers
            • Getting started
            • Govern.js API
            • Historical deployments
            • GraphQL API
            • Smart contracts breakdown
        • Deployments
          • Mainnet
          • Rinkeby
        • Packages
          • ERC 3k
          • Govern Console
          • Govern contract utils
          • Types
          • govern-create
          • Govern Server
          • govern-subgraph
          • govern-token
          • govern.js
      • Aragon Vocdoni
    • Aragon Client Glossary
  • THE ANT TOKEN
    • Aragon Network Token
      • About ANT
      • Historical token sale
    • ANTv1
      • Non-standard behaviours and gotchas
      • About the MiniMe token
      • The initial token sale flow
    • ANTv2
      • Upgrade portal
        • Troubleshooting
      • Contract interaction
      • Migrating on-chain liquidity
    • Developers
      • Quick start
      • Integrating ANT
      • Historical deployments
      • Security policy
  • ‼️FAQ
    • Products
      • Aragon Client
        • Where is my DAO?
        • DAO creation taking a long time to confirm
        • DAO is taking a long time to load
        • Failed DAO creation transaction
        • Why do I see a Blue Screen?
        • An unexpected error has occurred
        • App does not appear in Firefox
        • Receiving funds directly to the Agent or Vault address
        • How to Recover Funds accidentally sent to an Aragon App address
        • Depositing EURS in the Finance app
        • Which templates are available on the Ethereum Network?
        • Which templates are available on the Polygon Network?
        • Which templates are available on the Harmony Network?
        • Which templates are available on the Metis Andromeda Network?
        • How to delete a DAO
      • Aragon Govern
        • Which was the wallet address used to create the Aragon Govern DAO?
        • Where are my DAO tokens?
        • How to delete a DAO
        • How can I transfer funds to the Aragon Govern DAO?
      • Aragon Vocdoni
        • Is Vocdoni easy to use?
        • Is Vocdoni anonymous?
        • Is Vocdoni free?
        • Is my data safe with Vocdoni?
        • As an Organization, what can I do with Vocdoni?
      • Aragon Court
        • What is the current duration of the different stages of a dispute?
        • Dispute - Which fees need to be paid to create a dispute?
        • Dispute - Do I need to put collateral to create a dispute?
        • Appeals - How much money is needed to appeal a dispute? And to confirm the appeal? What is it for?
        • Appeals - If I have tokens staked or activated, can I lose them if I appeal a dispute?
        • Appeals - What happens to the collateral put up
        • Voting - Is a majority needed to win a vote?
        • Voting - What happens if there is a tie?
        • Voting - What does "Refuse to vote" mean? What happens if it's the most voted option?
        • Voting - Another guardian tried to collude. Can I punish this guardian?
        • Voting - What's the penalty for leaked votes?
        • Governance - Which parameters of Court can be changed? How?
        • Governance - Do parameter changes affect ongoing disputes?
        • Technical - Where is the Court "hosted"?
        • Technical - Where can I find the source code and technical documentation for Aragon Court?
        • ANJ conversion - What date will the lock-up period end?
        • ANJ conversion - If I have not staked my $ANJ, do I still get the lockup period price?
        • ANJ conversion - Will I get the 0.044 conversion if I convert after September 5th 2021?
        • ANJ conversion - How much will it cost to be a Guardian in Aragon Court with $ANT?
        • I can't see my tokens in the Dashboard
        • I activated my tokens but I can't see my probability of being drafted
    • Miscellaneous
      • Metamask wallet transaction alert
      • Is Aragon open source?
      • Where can I browse through the DAOs created on Aragon?
      • How to migrate from "old" DAI to "new" DAI
      • Security notice for organizations created before Aragon 0.8
      • General troubleshooting tips
    • ANT Token
      • What can I do with ANT?
      • Who holds ANT?
      • Who are the biggest ANT holders?
      • Long-term holding ANT - What benefits?
      • Can I delegate my network votes to somebody else?
      • Can I do flash loans with ANT?
      • Is there an ANT options market?
      • Are you planning to launch new network tokens?
      • My wallet isn't available on the Upgrade Portal
      • How can connect my Ledger to the Upgrade Portal?
      • I accidentally sent my "old" ANT to an exchange
      • ANJ conversion - What is the minimum number of $ANJ I need to participate in the 0.044 conversion?
      • ANJ conversion - What is the conversion rate ANJ to ANT v2?
Powered by GitBook
On this page
  • Step by step guide
  • 1. Modify package.json with your username and Subgraph name
  • 2. Create your Subgraph in The Graph’s explorer dashboard
  • 3. Set up the Subgraph manifest files
  • 4. Provide the ABIs defined in your data source
  • 5. Define the Subgraph schema
  • 6. Define the Subgraph mappings
  • 7. Hook up your mappings
  • 8. Test your Subgraph with a few data sources
  • 9. Deploy your Subgraph with all data sources
  • Troubleshooting
  • Some data is missing in my Subgraph
  • I’m getting errors about missing ABIs when the Subgraph is indexing
  • My callHandlers aren’t working

Was this helpful?

  1. Developers
  2. General Tools
  3. Aragon Connect
  4. Advanced

Writing an App Subgraph

PreviousCustom Subgraph queriesNextWriting an App Connector

Last updated 1 year ago

Was this helpful?

Creating a Subgraph for an Aragon app is not much different from any other kind of Subgraph. If you’re not already familiar with what can be done in a Subgraph, we recommend checking out .

In our app Subgraphs, we merely hook into a number of Aragon related data sources that will detect any installed organization, app, token, etc associated to an Aragon deployment. This is all hidden from you, so writing the Subgraph is as similar as possible to writing a normal Subgraph.

Step by step guide

To create a new Subgraph for Aragon, start by creating a copy of an existing Subgraph, such as . Then follow the steps below to modify the contents for your needs.

1. Modify package.json with your username and Subgraph name

In package.json, you’ll find a number of scripts that reference the user "aragon" and the application "voting". Change these to your user (or Github organization’s name) and your application’s name.

2. Create your Subgraph in The Graph’s explorer dashboard

The scripts in package.json will generate your subgraph.yaml manifest file and deploy your Subgraph with a very specific nomenclature.

For example, if you run yarn deploy-mainnet, you’ll deploy a Subgraph named "Aragon Voting Mainnet". If you run yarn deploy-mainnet-staging, you’ll deploy a Subgraph named "Aragon Voting Mainnet Staging". Make sure these Subgraphs are already created in .

The specification for the nomenclature is: Aragon <AppName> <Network> [Staging].

Staging Subgraphs are intended for development, as they index very quickly. We’ll expand more on this in .

3. Set up the Subgraph manifest files

The way we handle data sources in these Subgraphs is a bit sophisticated, so the subgraph.yaml file at the root is actually a generated file and should not be edited. This is why you may not find this file at the root of the project until it is generated first.

Instead, edit subgraph.template.yaml. You will notice that there are a number of tags in this file. You don't have to worry about this yet! Initially, the only sections you should modify is whatever is not a Mustache tag. You can define static data sources in the dataSources section and dynamic data sources in the templates section.

If you are writing a Subgraph for an Aragon app, its data source specification should go in the latter, since its instances are be generated dynamically (as organizations install your app). As an example, the Voting app's template declares the "Voting" data source template. This data source will be hooked up to any installed instances of Voting found in all deployed Aragon organizations.

If you’d like to disable a specific injected data source, such as the OrganizationTemplates data source, you can use an exclamation symbol:

{ { !> OrganizationTemplates.yaml } }

4. Provide the ABIs defined in your data source

As with any Subgraph, ABIs referenced in your manifest should be provided in the abis folder.

You may obtain such ABI files from Etherscan or the contract developer.

5. Define the Subgraph schema

This is the same as defining a GraphQL schema for any Subgraph. Start with the high level entities, and iterate.

In the case of the example Voting Subgraph, we defined the Vote and Cast entities. These entities were defined with just an ID, and their properties were added as the Subgraph was developed.

6. Define the Subgraph mappings

The data sources defined in subgraph.template.yaml reference files in src that need to be implemented. In the example Voting Subgraph, you’ll find such definitions in src/Voting.ts. These mappings specify what the Subgraph should do whenever a relevant event to a Voting app was detected.

7. Hook up your mappings

In src/aragon-hooks, you’ll find a series of hooks that can be used to react to specific events that occur in the background of any specific app. For example, you can react to when an organization was first detected by creating an entity that is then used by your Subgraph.

Most importantly, the getTemplateForApp\(...\) hook allows you to specify the name of a data source template that you’d like to create when a specific app instance is newly detected. See the example Voting Subgraph's aragon-hooks as an example of this applied to instances of the Voting app.

8. Test your Subgraph with a few data sources

At this point, you’re ready to take your Subgraph for a spin!

Run any of the deploy commands with -staging. This will use data provided from manifest/data's JSON files to determine which data sources to use for indexing the staging version of your Subgraph.

For example, if you run yarn deploy-mainnet-staging, manifest/data/mainnet-staging.json will be used to generate your Subgraph manifest. This JSON file defines a single data source with the PieDAO organization. The resulting deployment will effectively sync very quickly, which should allow you to iterate on your Subgraph without having to wait for long periods of time before you can start testing.

You need to export your The Graph access token as the GRAPHKEY environment variable before running a deploy- script.

9. Deploy your Subgraph with all data sources

Once you are confident that your Subgraph will behave as expected, you can run GRAPHKEY=<key> yarn deploy-mainnet (without -staging!). This will use manifest/data/mainnet.json, which contains many Aragon data sources, such as the templates used by most users to create an organization. This will allow your Subgraph to find all the organizations out there, and as in the example, index all instances of the specified apps.

Of course, this deployment will take much more time to index − potentially days.

Troubleshooting

Some data is missing in my Subgraph

Even though the provided templates collect data from many sources, there may still be some cases in which a contract is deployed in a way that isolates it from the general data sources.

For example, you may deploy an organization manually, without using the official templates or factories. If this is the case, the organization will not be detected by our pre-defined data sources.

There may also be bugs in how a template scans the data sources. If you find missing information in your Subgraph, please contact us to discuss your case to see if there’s a bug in the template. If a bug is not the case, you may have to manually insert specific data sources in your Subgraph, such as isolated organizations, apps or, tokens.

I’m getting errors about missing ABIs when the Subgraph is indexing

When a reducer is run, it’s run in the context of the data source that defined it. For example, hooks are triggered by src/base/Kernel.ts when the NewAppProxy event is detected in an Organization. You need to include the missing ABI in manifest/templates/contracts/Kernel.template.yaml for it to be available in this reducer.

As a rule of thumb, if your data source will be triggered by a base Aragon data source (organization templates, organization factories, etc), include its ABI in the manifest/templates/contracts files.

My callHandlers aren’t working

Unfortunately, . For this reason, our templates avoid them altogether. In general, we prefer to code Subgraphs in a way that is compatible with all networks. Alternatively, if you have no other choice than to use this feature, consider hosting your own Subgraph.

🛠️
The Graph does not support callHandlers in Rinkeby
The Graph’s documentation
connect-the-graph-voting
The Graph’s explorer dashboard
Mustache
step 8