contract_id, which you then use to create the vault map the contract reads and writes.
This code goes back in quickstart.ts — the Node/TypeScript project from Quickstart — not in the agent-vault-starter Rust repo. Append it to the bottom using the cat >> quickstart.ts << 'EOF' pattern from Running the code samples in this guide.
Before you run this code, make sure you have:
- An authenticated
TenantClientnamedtenant. If you have not created one yet, complete Quickstart and Set Up Dev Env first. - A compiled WASM file at
target/wasm32-wasip2/release/agent_vault_starter.wasm, inside the separateagent-vault-starterfolder you cloned in Write your TEE contract — not inside your Node project. - Your
tenantDid, for exampledid:t3n:abcdef0123456789abcdef0123456789abcdef01.
Choose a contract tail
Thetail is the local name of your contract inside your tenant namespace. Pass only the part after z:<tid>:. This walkthrough uses the tail vault, which becomes:
z:<tid>: in the tail; the SDK and host derive that from the authenticated tenant.
A tail may contain letters, digits, _, -, and . — but not /. The SDK rejects slashes (tail must match /^[a-zA-Z0-9_-][a-zA-Z0-9_.-]{0,127}$/).
Pick a stable tail for each contract you plan to maintain. When you register a new build at the same tail, increase the version value; changing the tail creates a separate contract entry.
Keep tails short and simple (a few words, hyphen-separated) rather than long or descriptive. The full canonical name (
z:<tid>:<tail>) gets reused downstream in places like delegation grants, and a handful of teams have hit unexpectedly-strict length limits further down the pipeline when using long tails. The 128-character limit above is enforced at registration; treat it as a ceiling, not a target.A contract and a map are named separately, so the contract
z:<tid>:vault and the map z:<tid>:vault it stores records in don’t collide.Register the WASM
WASM_PATH above assumes you cloned agent-vault-starter as a sibling folder next to your Node project (i.e. ../agent-vault-starter/... from quickstart.ts) — if you put it somewhere else, update the path accordingly. The --register flag keeps later runs of quickstart.ts from registering again, and running --register a second time is harmless: an already-registered version is skipped.
Keep the contract_id it prints. T3N returns it only from register, and there’s no call to look it up later.
Registration does not run your code, create maps, or grant anyone access. It only stores the component and records the versioned contract entry for your tenant — which is why the map is created as a separate call straight after.
Create the vault map
The contract reads and writesz:<tid>:vault, and that map must exist before the first store. The call above creates it private, readable and writable only by your contract’s contractId:
readersmust be set explicitly — leave it off and the contract’s own reads fail withAccessDenied.- If the map already exists (you registered before, then raised
CONTRACT_VERSION), the code updates itsreadersandwritersto the newcontractIdinstead of failing onmap already exists. - There are no secrets to seed: this contract makes no outbound calls.
What T3N stores
The register payload is just{ tail, version, wasm }; there is no manifest.
Host-side, T3N:
- Stores the WASM blob in content-addressed storage.
- Allocates a numeric
ContractId. - Records the contract under your tenant registry.
world.wit, not from this registration request. See Capabilities come from your WIT imports.
First-run troubleshooting
The contract is registered and its map exists. Next, store a record, grant your agent and let it check.