Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions pages/en/deploying/deploying-a-subgraph-to-hosted.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,23 @@ If your previously deployed subgraph is still in status `Syncing`, it will be im

In some cases, you will want to deploy the same subgraph to multiple Ethereum networks without duplicating all of its code. The main challenge that comes with this is that the contract addresses on these networks are different.

### graph-cli >=0.29.0
### Using graph-cli

From version `0.29.0` the `build` command accepts two new options:
Both `graph build` (since `v0.29.0`) and `graph deploy` (since `v0.32.0`) accept two new options:

```sh
graph build [options] [<subgraph-manifest>]

Options:

...
--network <name> Network to use from networks.json
--network-file <path> Networks file (default: "./networks.json")
--network <name> Network configuration to use from the networks config file
--network-file <path> Networks config file path (default: "./networks.json")
```

You can use the `--network` option to specify a network configuration from a `json` standard file (defaults to `networks.json`) to easily update your subgraph during development.

**Note:** The `init` command will now auto-generate a `networks.json` based on the provided information. You will then be able to update existing or add additional networks.

If you don't have a `networks.json` file, you'll need to manually create one with the follwing structure:
If you don't have a `networks.json` file, you'll need to manually create one with the following structure:

```json
{
Expand Down Expand Up @@ -182,7 +180,7 @@ This is what your networks config file should look like:
}
```

Now we can run the following command:
Now we can run one of the following commands:

```sh
# Using default networks.json file
Expand All @@ -207,9 +205,19 @@ dataSources:
kind: ethereum/events
```

Now you are ready to `yarn deploy`
Now you are ready to `yarn deploy`.

**Note:** As mentioned earlier, since `graph-cli 0.32.0` you can directly run `yarn deploy` with the `--network` option:

```sh
# Using default networks.json file
yarn deploy --network ropsten

# Using custom named file
yarn deploy --network ropsten --network-file path/to/config
```

### graph-cli \<0.29.0
### Using subgraph.yaml template

One solution for older graph-cli versions that allows to parameterize aspects like contract addresses is to generate parts of it using a templating system like [Mustache](https://mustache.github.io/) or [Handlebars](https://handlebarsjs.com/).

Expand Down