Skip to content

Getting Started

Use the TypeScript SDK when you want application code to build signed NOOSChain transactions and call node APIs without hand-writing HTTP requests or duplicating protocol payload schemas.

The SDK source is currently in:

text
apps/nooschain-ts/

Build it from the repository root:

powershell
npm run nooschain-ts:build

Run its tests:

powershell
npm run nooschain-ts:test

Import The Client

Package consumers import from @nooschain/client:

ts
import { NooschainClient } from "@nooschain/client";

Local monorepo examples may import from the source entrypoint while the package is not published externally:

ts
import { NooschainClient } from "../src/index.js";

Create A Client

Create a client with the node base URL:

ts
const client = new NooschainClient({
  baseUrl: "http://127.0.0.1:3000",
});

The client normalizes trailing slashes, applies request timeouts, parses JSON, and throws typed SDK errors for failed HTTP responses.

Operator-only endpoints also need an operator token:

ts
const operatorClient = new NooschainClient({
  baseUrl: "http://127.0.0.1:3000",
  operatorToken: process.env.NOOS_OPERATOR_TOKEN,
});

Do not ship operator tokens in public browser clients.

Choose The Runtime Entry

Node.js tools can use the full package surface, including filesystem helpers such as loadContractPackageFromDirectory(...).

Browser clients can use transaction builders, query helpers, signing interfaces, package descriptor validation helpers, and the browser signing backend. They cannot load packages from local filesystem paths.

First Transaction

ts
import { NooschainClient, PemTransactionSigner } from "@nooschain/client";

const client = new NooschainClient({
  baseUrl: "http://127.0.0.1:3000",
});

const signer = new PemTransactionSigner({
  publicKey: process.env.NOOS_SIGNER_PUBLIC_KEY!,
  privateKeyPem: process.env.NOOS_SIGNER_PRIVATE_KEY_PEM!,
});

const built = await client.transactions.registerOrganization({
  signer,
  nonce: "auto",
  payload: {
    id: "org-example",
    name: "Example Organization",
    metadata: {},
  },
});

await client.transactions.submit(built.transaction);

This builds and submits transaction REGISTER_ORGANIZATION.

nonce: "auto" calls GET /identity/nonce and sends the signer public key in the x-noos-signer-public-key-base64 header. Use an explicit nonce when you need offline signing, deterministic batch construction, or external nonce coordination.

First Query

ts
const head = await client.chain.head();
console.log(head.height);

Query helpers do not sign transactions. Some operator and observability queries still require an operator token because they expose local node diagnostics.

Next Steps

Audience-first NOOSChain documentation.