Sui config
Declaring the local Sui network, RPC, faucet, indexer, and forking for a stack.
sui() gives a stack its network — the node, RPC endpoint, faucet, and GraphQL indexer that every
other member (packages, accounts, coins, services) builds on. Add one sui() member and the rest of
your config has a chain to publish to, fund from, and read against.
With no options, sui() boots a local validator with RPC, a faucet, and the GraphQL indexer all on.
That single line is the whole network for local development: created fresh each boot, torn down with
the stack.
import { defineDevstack, sui } from '@mysten-incubation/devstack';
const localnet = sui();
export default defineDevstack({ members: [localnet] });Modes
sui() runs in one of four modes, chosen by the options you pass. Local is the default; the others
point at networks you don't run.
| Mode | Selector | What it does |
|---|---|---|
local | sui() | In-stack validator + faucet + GraphQL, published from scratch |
local-rpc | sui({ mode: 'local-rpc', rpcUrl }) | Wraps a Sui process you already run — no container |
live | sui({ mode: 'live', network }) | Reads/trades against testnet, mainnet, devnet, or a custom RPC |
fork | sui({ mode: 'fork', upstream }) | A sui-fork node mirroring a real chain at a checkpoint |
A stack is single-network: one sui() member, one network. To ship an app that switches between
local and live networks at runtime, you layer those deployments at the Vite merge step rather than
inside the stack — see Live networks and
Going to production.
Local mode
const localnet = sui(); // RPC + faucet + GraphQL indexer
const rpcOnly = sui({ indexer: false }); // RPC + faucet, no GraphQL, no sidecarThe GraphQL indexer is on by default, so a bare sui() gives you the full GraphQL surface with no
extra wiring. To support it, devstack runs a Postgres sidecar (auto-creating its sui_indexer
database) and starts the validator with --with-graphql against it.
You can turn the indexer down or point it elsewhere:
-
indexer: false— RPC and faucet only. No GraphQL, no Postgres sidecar. -
indexerDb— point GraphQL at a Postgres you already run, so devstack provisions no sidecar:const localnet = sui({ indexerDb: { url: 'postgres://user:pass@host:5432', network: 'my-network', // a docker network the validator can reach the DB on database: 'sui_indexer', // appended to the DSN if it carries no path; default 'sui_indexer' }, });
Other local-mode options:
suiToolsRef— themysten/sui-toolstag or commit SHA the validator image is built on ('testnet-v1.80.0', or a 40-character SHA). Omit it for devstack's bundled pin. The-arm64suffix is added for you on Apple Silicon. TheDEVSTACK_SUI_TOOLS_REFenvironment variable sets the same thing for a single run; config wins when both are present. Either way the choice also selects the CLI a stack boot runssui move summarywith, so generated bindings match the toolchain that publishes. (The stack-freedevstack codegenverb uses the hostsuiCLI and fails when the stack pins a release the host CLI does not match.) The config field cannot be combined withimage: { pull }, which names a complete image; the env var is simply ignored whenimage: { pull }is set.image— override the validator image:{ pull: '<ref>' }skips the build, or{ build: { context, dockerfile? } }builds your Dockerfile with devstack's build args (including the resolvedSUI_TOOLS_IMAGE) and a content-hashed tag.ports— pin exact host ports keyed by container port ({ 9000: 9000 }). Omit it and devstack assigns host ports for you, reassigning on collision; the public9000/9123/9125entrypoints stay fixed through the router.readyTimeout— the ready-probe timeout, an EffectDuration(e.g.Duration.seconds(120)).
Live mode
Live mode reads and trades against a network you don't run. Known networks default their endpoints;
custom requires an rpcUrl.
const testnet = sui({ mode: 'live', network: 'testnet' });
const custom = sui({
mode: 'live',
network: 'custom',
rpcUrl: 'https://my-fullnode.example:443',
faucetUrl: 'https://my-faucet.example', // optional
graphqlUrl: 'https://my-graphql.example/graphql', // optional
graphqlHeaders: { Authorization: `Bearer ${process.env.GRAPHQL_TOKEN}` }, // optional
chainId: '…', // optional pin; omit to probe the RPC endpoint
});local-rpc mode is the local counterpart — pass rpcUrl (and optional faucetUrl / graphqlUrl /
graphqlHeaders / chainId) to wrap a Sui process you're already running, with no container and no
sidecar.
Authenticated GraphQL
graphqlHeaders attaches HTTP headers (an Authorization token, an API key, …) to the Sui GraphQL
reads the devstack dashboard makes. Known networks accept it too, so you can keep the default
endpoint and just add credentials, or pair it with your own graphqlUrl.
The headers stay in the devstack process. They are never written to codegen output or the deployment envelope, and never sent to the browser: while they are set, the dashboard sends its Sui GraphQL reads through a relay on the dashboard server that attaches them. The relay only accepts connections from the same machine (loopback), so other hosts on your network can't use your credentials through it. Processes on your machine that can reach loopback, which may include containers on Docker Desktop, are not excluded.
Rotating a token doesn't invalidate your snapshots: the headers aren't part of the stack's snapshot
identity. A running devstack up keeps the headers it started with, though, so restart it after
changing them. devstack apply against a running session tells you when a restart is needed.
As with direct reads, a graphqlUrl that doesn't end in /graphql has /graphql appended. Setting
graphqlHeaders on a network with no GraphQL endpoint (for example devnet without a graphqlUrl)
fails at boot.
Fork mode
sui({ mode: 'fork', upstream }) runs a sui-fork node mirroring a real chain at a checkpoint. See
Forking for the options, the whale-based fork faucet, and the full walkthrough.
suiToolsRef applies here too, and matters more: naming a sui-tools build that ships sui-fork
replaces a ten-minute source compile with an image pull.
The resolved network
Whatever the mode, sui() resolves one network into the deployment's per-network connection fields:
| Field | Meaning |
|---|---|
rpc | The RPC endpoint the app reads synchronously. |
chainId | The node's genesis-digest chain identifier (not the network name). |
faucet | The faucet URL, or null when the network has none. |
graphql | The GraphQL endpoint, or null when the indexer is off. |
These ride the resolved NetworkDeployment and surface in app code through config.network and
config.networks — see Config & deployments.