TypeScript examples for checking Injective SDK behavior and endpoint responses.
The repo is intentionally small: examples can be run by name through a typed runner, or directly as TypeScript files when you want to inspect and tweak one case.
- Node.js
- pnpm 10.7.0
pnpm install
cp .env.example .envPRIVATE_KEY is only required for examples that build transactions. Transaction
examples default to simulation or no-op behavior. Set
BROADCAST_TRANSACTIONS=true only when you explicitly want an example to
broadcast.
List available examples:
pnpm example listRun an example by id:
pnpm example query:spot-markets
pnpm example tx:simulate-msg-sendRun a file directly:
pnpm exec tsx src/examples/queries/spot-markets.tsAdd a .ts file under src/examples/<category>/. The runner auto-discovers
example files, so no registry edit is needed.
Each example should export lightweight metadata and a run function:
import type { ExampleMetadata } from "../types";
import { runDirectly } from "../../lib/direct-run";
export const metadata: ExampleMetadata = {
id: "query:example-id",
category: "queries",
title: "Example title",
description: "Short description shown by pnpm example list.",
};
export const run = async (): Promise<void> => {
const { SomeSdkClient } = await import("@injectivelabs/sdk-ts");
// Example implementation.
};
runDirectly(module, run);Keep SDK-heavy imports inside run so pnpm example list can import metadata
without initializing clients or requiring environment variables.
Common environment variables:
INJECTIVE_NETWORK: network name accepted by@injectivelabs/networks.INJECTIVE_RPC_ENDPOINT: overrides the RPC endpoint for RPC/CosmJS examples.PRIVATE_KEY: shared hex private key for transaction examples.SEED_PHRASE: shared mnemonic used by examples that accept mnemonic signing.DESTINATION_INJECTIVE_ADDRESS: recipient address for send examples. Some examples default to the source account when unset.SEND_AMOUNT_INJ: optional amount override for examples that send a fixed amount.BROADCAST_TRANSACTIONS: must betruebefore any broadcast-capable example sends a transaction.
pnpm example <id>
pnpm example:list
pnpm lint
pnpm typecheck
pnpm test
pnpm check
pnpm deps:injective:updatepnpm deps:injective:update updates @injectivelabs/* packages explicitly.
It is not part of postinstall, so normal installs remain reproducible.
Apache-2.0