Quickstart - Terminal 3 Documentation

Main Content

This page gets you to one working, authenticated call — nothing else. No Rust, no WASM, no blockchain knowledge required for this part. Once this works, move on to Write your first TEE contract for the real thing.

1. Get your API key

Go to the claim page and sign in. You get an API key and test credits instantly — no approval wait.

Your key is shown once. Copy it somewhere safe before you navigate away — there’s no way to view it again.

2. Set up your project

Create a fresh project and install the SDK:

mkdir my-t3n-app && cd my-t3n-app
npm init -y
npm pkg set type=module        # required — the code below uses top-level await
npm install @terminal3/t3n-sdk tsx

Then put the key from Step 1 into your shell’s environment — the code in the next step reads it from there, it isn’t written into any file:

export T3N_API_KEY="<the key you copied from the claim page>"

Using Next.js, Vite, or another bundler?

A handful of teams have hit WASM-loading errors under Next.js/Turbopack, Vite, and older Webpack setups — the SDK loads a WASM component, and some bundlers try to process it in ways that break it. If you hit a WASM parse or module-loading error later in this guide and you’re in a bundled framework, try running the SDK code from a plain Node script or a server-only route first, to confirm your setup works before debugging the bundler. If you’re on Next.js specifically, adding your bundler’s equivalent of an external-packages/no-bundle exception for @terminal3/t3n-sdk is worth trying. We’re tracking this as a known rough edge — if you find a config that fixes it, tell us in the developer Telegram and we’ll document it here properly.

3. Connect and authenticate

Create a file named quickstart.ts in your project and paste this in — don’t run any of it in a terminal directly, it’s TypeScript, not shell commands:

import {
  T3nClient,
  setEnvironment,
  loadWasmComponent,
  eth_get_address,
  metamask_sign,
  createEthAuthInput,
} from "@terminal3/t3n-sdk";

setEnvironment("testnet"); // the SDK defaults to production — set this explicitly while building

const T3N_API_KEY = process.env.T3N_API_KEY!;
const wasmComponent = await loadWasmComponent(); // all crypto runs inside this component
const address = eth_get_address(T3N_API_KEY);

const t3n = new T3nClient({
  wasmComponent,
  handlers: {
    EthSign: metamask_sign(address, undefined, T3N_API_KEY),
  },
});

await t3n.handshake();
const did = await t3n.authenticate(createEthAuthInput(address));
const tenantDid = did.value; // did:t3n:... — you'll reuse this exact variable in every later step

console.log("Connected as:", tenantDid);

Never hardcode or derive your tenant DID. It’s not related to your wallet address — it’s an opaque ID the platform assigns you the first time you sign in. Always read it back from the authenticated session, like tenantDid above — and keep both t3n (the client) and tenantDid (the value) around, since Set Up Dev Env and the rest of the walkthrough build directly on top of them.

“Reuse this variable” means literally keep coding in this same file.t3n and tenantDid are plain JavaScript variables — they only exist inside this one running script. The code samples on later pages (TenantClient, contract registration, invocation) assume t3n/tenantDid/tenant are already in scope, so append each new snippet to the bottom of this same quickstart.ts rather than starting a new file, unless you deliberately repeat the connect-and-authenticate block above at the top of it.

Under the Hood: what is setEnvironment doing?

setEnvironment("testnet" | "production") tells the SDK which T3N cluster to resolve a node URL from for every client you create afterward — you never hardcode a node URL yourself. It defaults to "production", which is why setting it explicitly matters while you’re still building against testnet.

4. Run it

From the same directory as quickstart.ts:

npx tsx quickstart.ts
# Connected as: did:t3n:9f2a...

If you see a did:t3n:... value printed, you’re connected.

  1. Get your API key from the claim page — shown once, copy it somewhere safe.
  2. Save our skill file as .claude/skills/t3n-adk-quickstart/SKILL.md in your project.
  3. Describe what you’re building. Claude Code scaffolds the project (package.json/ESM setup, your API key in the environment), writes and runs the connection code, and checks a known-pitfalls list before guessing at fixes.

You should still end up with a working t3n client and tenantDid — the same things the manual path produces — just without typing the steps yourself.

1. Get your API key from the claim page — shown once, copy it somewhere safe.

2. Save the same skill file as AGENTS.md in your project root — Codex reads it automatically.

3. Describe what you’re building. It follows the same order as the manual path: working connection first, contract code second.

What’s next

You now have two things every later page assumes you already have: an authenticated t3n client and its tenantDid. Keep both around (same variable names, same file) as you continue: