Skip to content

Commit

Permalink
new billing section (#198)
Browse files Browse the repository at this point in the history
* new billing section

* Small fixes

A few small fixes based on Nena's feedback

* Updates

Making changes based on Adam's feedback

* 2 small fixes

Fixed:
-mentioning the network switcher in subgraph studio
-Clarity on the billing policy
  • Loading branch information
MichaelMacaulay authored Sep 14, 2022
1 parent 5ef6f36 commit 5971b1c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 63 deletions.
6 changes: 3 additions & 3 deletions navigation/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const navigation = (locale: AppLocale): NavItemDefinition[] => [
},
],
},
{
slug: 'billing',
},
{
divider: true,
},
Expand Down Expand Up @@ -133,9 +136,6 @@ export const navigation = (locale: AppLocale): NavItemDefinition[] => [
{
slug: 'querying-the-hosted-service',
},
{
slug: 'billing',
},
],
},
{
Expand Down
76 changes: 76 additions & 0 deletions pages/en/billing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Billing on Subgraph Studio
---

### Overview

For a quick demo of how billing works on the Subgraph Studio, check out the video below:

<VideoEmbed youtube="UrfIpm-Vlgs" />

Invoices are statements of payment amounts owed by a customer and are typically generated on a weekly basis in the system. You'll be required to pay fees based on the query fees you generate using your API keys. While The Graph protocol operates on Ethereum Mainnet, the billing contract lives on the [Polygon](https://polygon.technology/) network to reduce transaction times and cost. It'll allow you to:

- Add and remove GRT from your wallet
- Keep track of your balances based on how much GRT you have added to your account, how much you have removed, and your invoices
- automatically pay invoices based on query fees generated, as long as there is enough billing balance in your account.

There are 4 states your invoice can be in:

1. Pending - the invoice is in the queue to be paid from your billing balance
2. Paid - your invoice has been successfully paid
3. Unpaid - there is not enough GRT in your billing balance
4. Partially Paid - only part of the invoice was paid, since there was not enough billing balance

**See the diagram below for more information:**

![Billing Flow](/img/billing-flow.png)

### Adding GRT to Account

Before making queries on The Graph Network, you will need to add GRT to your account. This will take about 10-30 minutes depending on network traffic. To add GRT to your account, take the following steps:

1. Purchase GRT and ETH on an exchange or decentralized exchange of your choice
2. Send the GRT and ETH to your wallet
3. Bridge GRT to Polygon using the Subgraph Studio UI

a) You will receive 0.001 Matic within a few minutes of sending GRT to the Polygon bridge. You can monitor the transaction by inputting your wallet address into the search bar on [Polygonscan](https://polygonscan.com/).

4. Add bridged GRT to the billing contract on Polygon in the Subgraph Studio UI. The billing contract address is: [0x10829DB618E6F520Fa3A01c75bC6dDf8722fA9fE](https://polygonscan.com/address/0x10829DB618E6F520Fa3A01c75bC6dDf8722fA9fE).

a) In order to complete step #4, you must switch from Ethereum to the Polygon network. You can do this using the Subgraph Studio.

If you used your API keys over the course of any given week, you will receive an invoice based on the query fees you have generated during this period. This invoice will be paid using GRT available in your balance. Query volume is evaluated by the API keys you own. Your balance will be updated after fees are withdrawn.

### Understanding Invoices in Subgraph Studio

When using The Graph Network, dapps and users pay for query fees in GRT, the protocol's native work-utility token. Maintaining a positive balance for an account is the user's or dapp's responsibility.

Here are ways to be notified about and/or check a query fee balance:

- You can set up a billing notification that will be sent to an email address [here](https://thegraph.com/studio/settings/).

- You can query the billing subgraph API directly [here](https://thegraph.com/hosted-service/subgraph/graphprotocol/billing)

Also, you can learn how to (re)fill your query fee balance by watching [this video](https://www.loom.com/share/a81de6ef11d64c62872ea210c58c6af5).

> IMPORTANT: If there are 2 unpaid invoices, Indexers will stop serving queries for all API Keys associated with the account. Indexers will automatically start serving queries again once the billing balance is paid in full and GRT is added to the account for future query fees.
Lastly, learn how to prioritize price, speed, data freshness (among other factors) for your queries by watching [this video](https://www.loom.com/share/b5fc533e48584cb694017392c80c75e0). If you have any questions, please ask in [The Graph Discord](https://discord.gg/fjDWCTZE) and the community will be happy to help.

### How to Fill Your Account With a Mulisig Wallet

Multisigs are smart contracts that can exist only on the network they have been created, so if you created one on Ethereum Mainnet - it will only exist on Mainnet. Since our billing uses Polygon, if you were to bridge GRT to the multisig address on Polygon the funds would be lost.

To overcome this issue, we created [a dedicated tool](https://multisig-billing.thegraph.com/) that will help you deposit GRT on our billing contract (on behalf of the multisig) with a standard wallet / EOA (an account controlled by a private key).

You can access our Multisig Billing Tool here: https://multisig-billing.thegraph.com/

This tool will guide you to go through the following steps:

1. Connect your standard wallet / EOA (this wallet needs to own some ETH as well as the GRT you want to deposit)
2. Bridge GRT to Polygon. You will have to wait 7-8 minutes after the transaction is complete for the bridge transfer to be finalized.
3. Once your GRT is available on your Polygon balance you can deposit them to the billing contract while specifying the multisig address you are funding in the `Multisig Address` field.

Once the deposit transaction has been confirmed you can go back to [Subgraph Studio](https://thegraph.com/studio/) and connect with your Gnosis Safe Multisig to create API keys and use them to generate queries.

Those queries will generate invoices that will be paid automatically using the multisig's billing balance.
60 changes: 0 additions & 60 deletions pages/en/querying/billing.mdx

This file was deleted.

0 comments on commit 5971b1c

Please sign in to comment.