linera-playground/README.md
A browser-based GraphQL playground for Linera applications. Enter a faucet URL, a
chain ID and an application ID, type a GraphQL query, and run it. The whole
client runs in the browser via the @linera/client WASM package: it spins up a
Client, creates a ChainClient for the chosen chain, synchronizes it from the
validators, and queries the application's GraphQL service. Mutations go through
the same path and are signed by a connected signer.
See DESIGN.md for the architecture.
pnpm (the repo uses pnpm workspaces).@linera/client and @linera/metamask packages under ../web are
consumed as workspace packages. pnpm install builds them if needed (this
compiles the WASM client and requires the Rust toolchain from
../web/rust-toolchain.toml).cd linera-playground
pnpm install
pnpm dev
Open the printed URL (default http://localhost:5173).
linera net up --with-faucet (see below).Reads work with no signer connected (the playground uses a throwaway key). To run a mutation you must connect a signer that owns the target chain:
A mutation builds and signs a block; the validators reject it if the connected owner is not an owner of the chain.
A self-contained image builds the WASM client from source and serves the static site with nginx (including the cross-origin-isolation headers the client needs). Build it from the repository root:
docker build -f docker/Dockerfile.playground -t linera-playground .
The first build compiles the whole workspace to WASM, so it is slow (~15-30 min) and needs network access for the toolchain and crates. Then run it:
docker run --rm -p 8080:80 linera-playground
Open http://localhost:8080 and set the faucet URL, chain ID and application ID in the UI. The faucet URL must be reachable from the browser (a public testnet faucet, or a local faucet exposed to the host).
From the root of the repository, start a local network with a faucet and deploy an example application (here, the counter):
export PATH="$PWD/target/debug:$PATH"
eval "$(linera net helper 2>/dev/null)"
LINERA_FAUCET_PORT=8079
export LINERA_FAUCET_URL=http://localhost:$LINERA_FAUCET_PORT
linera_spawn linera net up --with-faucet --faucet-port $LINERA_FAUCET_PORT
# In another shell, set up a wallet from the faucet and deploy the counter app,
# following examples/counter/README.md. Note the resulting CHAIN ID and
# APPLICATION ID.
Then in the playground:
http://localhost:8079query { value } — it should return the counter value.mutation { increment(value: 1) }, and re-run query { value } to see it
change.