---
name: lodestar-publish
description: Publish a subgraph to The Graph Network without Subgraph Studio, through Lodestar (lodestar-dashboard.com/move). Use when the user wants to publish or move a subgraph off Studio, publish a new version, set a subgraph's name, image or links, signal on it, or find out whether indexers are serving it yet and what URL to query. Works with a human signing in the browser, or headlessly with a key.
---

# Publishing a subgraph through Lodestar

Subgraph Studio's query URL is being retired chain by chain. What replaces it is a subgraph
published on Arbitrum One that indexers serve through the gateway. Lodestar does the whole path:
publish, signal, watch indexers sync, hand back the query URL.

There are two ways to do it. Pick by whether you hold a key.

## Decide first

- **No private key, or the user has not said you may spend from one:** use the browser handoff.
  You build, the human signs. This is the default.
- **The user has given you a key file and said to publish with it:** use the headless script.

Everything here is mainnet. Publishing mints a permanent NFT; signalling moves GRT and pays a 1%
curation tax. Before any transaction, tell the user what it will do and wait for a yes, unless
they already said to go ahead. Never print a key, never accept one pasted into chat: ask for a
file path.

## Path A: the human signs

From the subgraph's directory:

```sh
graph codegen
graph publish --webapp-url https://www.lodestar-dashboard.com/move
```

Add `--subgraph-id <id>` when it is a new version of a subgraph they already published, and
`--api-key <key>` if they have a gateway key. The CLI builds, uploads to IPFS and opens Lodestar
with the deployment filled in. Give the user that link if no browser opens. They connect a
wallet, sign in once, fill in the details and confirm one transaction.

Coming from Studio with nothing to rebuild? Send them to
`https://www.lodestar-dashboard.com/move?from=<their Studio query URL>` instead.

Then follow progress yourself with `status` below. It needs no key.

## Path B: headless

The script is `scripts/lodestar-publish.mjs` beside this file. It needs Node 20+, and `viem`
installed in the directory you run it from (`npm i -D viem`). The key is read from the file named
by `LODESTAR_KEY_FILE`; that wallet will own the subgraph and needs a little ETH on Arbitrum One.

1. Build and upload. The last line gives the deployment hash.

   ```sh
   graph codegen && graph build --ipfs https://api.thegraph.com/ipfs/
   # Build completed: Qm…
   ```

2. Publish. `--name` is required; the rest are what Explorer shows.

   ```sh
   node lodestar-publish.mjs publish <Qm> --name "My subgraph" \
     --description "What it indexes" --image logo.png \
     --website https://… --repo https://github.com/… --categories DeFi,DEX \
     --version-label v0.0.1
   ```

   A new version of an existing subgraph: add `--subgraph-id <id>`. Only its owner can.
   It refuses a deployment that is already published, so a retry cannot mint a duplicate.
   The JSON it prints has `subgraphId` and `queryUrl`.

3. Signal, so indexers pick it up. Ask the user how much; 500 GRT is the floor that counts
   towards indexers' rewards eligibility, and less than that may attract nobody.

   ```sh
   node lodestar-publish.mjs signal <Qm> 500
   ```

   Or post a sync bounty: GRT held by a contract and paid to the first indexer that syncs the
   deployment and presents a proof of indexing to the protocol. Signal invites; a bounty pays.
   What the developer can do to get it back depends on the board, which the script reads from its
   version: on version 3 it is locked for 72 hours once posted and then the developer can cancel;
   a board with no cancel (version 4) returns it only if nobody has been paid it by 72 hours after
   its expiry. The report says which, as `cancellableFrom` or `refundableAfter`. The contract is
   verified but unaudited, so tell the user both before sending.

   ```sh
   node lodestar-publish.mjs bounty <Qm> 200 --days 30
   node lodestar-publish.mjs bounties <Qm>          # what is posted, and whether it was paid
   node lodestar-publish.mjs bounty-pay <id>        # send it to the indexer that earned it
   ```

4. Wait for an indexer.

   ```sh
   node lodestar-publish.mjs status <Qm> --wait
   ```

   Exit 0 means published and at least one indexer is at the chain head: give the user
   `queryUrl`. Exit 4 means an indexer hit a deterministic error, which is a bug in the mapping:
   show them `errors`, fix it, rebuild, and publish the new hash with `--subgraph-id`. Exit 3 is
   "not yet". Indexers usually allocate within hours, so do not sit in `--wait` for a user who is
   waiting on you; report where it stands and check back.

Other commands: `details <subgraph id> --description …` changes any field and keeps the rest;
`unsignal <Qm>` withdraws this wallet's signal; `bounty-cancel <id>` takes an unpaid bounty back
after its lock, or returns an expired one, and refuses when an indexer has already earned it (tell the
user, and use `--force` only if they insist); on a board with no cancel it only returns one whose
expiry and 72-hour claim window have passed, and says when that will be. By default the script
posts to and reads version 4 alone: a bounty still on version 3 is reached with
`LODESTAR_BOUNTY_BOARD=0xfBFcbb2e2da78dB189443a340Bc13C54BB703710`, and one on an older board by naming
that board the same way; `bounty-pay <id>` can be run by anyone, pays the
indexer and never the sender, and exits 1 without sending when nobody has earned it yet. It has to
be run within about a day of the indexer presenting its POI, because the contract checks the POI
against the chain's own record of that block and the chain does not keep it longer; `deprecate <subgraph id>` retires a subgraph.

## What to tell the user at the end

The query URL, which needs a gateway API key from <https://thegraph.com/studio/apikeys/>:

```
https://gateway.thegraph.com/api/<api-key>/subgraphs/id/<subgraphId>
```

Point their app at the subgraph id, not the deployment, so later versions reach it without
another change. And the page that follows it live: `https://www.lodestar-dashboard.com/move?from=<Qm>`.

## Things that go wrong

- `signalGrt` or `indexers` read zero just after a transaction. Those come from Lodestar's
  reader, which is a few minutes behind the chain. `published` is read from the chain itself.
- "belongs to 0x…, not to 0x…": the key is not the subgraph's owner. Publish a new subgraph
  without `--subgraph-id`, or get the right key.
- Image refused: PNG or JPEG only, 1 MB at most.
- `--network arbitrum-sepolia` on the CLI: Lodestar publishes to Arbitrum One only.
- No indexers after a day: the signal is too low for the chain, or the chain has few indexers.
  Say so plainly; it is not something a retry fixes.
