Skip to content

Conversation

@amder12
Copy link

@amder12 amder12 commented Sep 3, 2025


PR-Codex overview

This PR introduces a new integration script for interacting with the @thirdweb-dev/vault-sdk, enabling users to create clients, manage EOAs (Externally Owned Accounts), sign transactions, and create access tokens. It also includes configuration instructions and example usages.

Detailed summary

  • Added configuration section with environment variable setup.
  • Introduced main function for executing the integration script.
  • Implemented client creation with createVaultClient.
  • Added functionality to ping the Vault using ping.
  • Created an EOA with metadata using createEoa.
  • Parsed a transaction with parseTransaction.
  • Signed a transaction using signTransaction.
  • Created an access token linked to the EOA using createAccessToken.
  • Listed EOAs matching a specific address using listEoas.
  • Provided detailed instructions for setting up and running the script.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Documentation
    • Replaced the API Reference page with a runnable, Spanish-language Vault SDK example.
    • Added step-by-step setup and execution instructions, including environment configuration and commands.
    • Provided end-to-end usage flow: create client, ping service, create EOA, parse/sign a transaction, create an access token, and list EOAs.
    • Included sample project scaffolding and code snippets to simplify getting started and testing locally.

Signed-off-by: amder12 <[email protected]>
@amder12 amder12 requested review from a team as code owners September 3, 2025 06:37
@changeset-bot
Copy link

changeset-bot bot commented Sep 3, 2025

⚠️ No Changeset found

Latest commit: 5965f60

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@graphite-app
Copy link
Contributor

graphite-app bot commented Sep 3, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@vercel
Copy link

vercel bot commented Sep 3, 2025

@amder12 is attempting to deploy a commit to the thirdweb Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Walkthrough

Replaces the Vault SDK API Reference MDX page with a runnable Spanish example demonstrating end-to-end usage: initializing a client via env vars, pinging the service, creating an EOA, parsing and signing a transaction, creating an access token, and listing EOAs. Adds detailed run instructions and error handling within an async main() flow.

Changes

Cohort / File(s) Summary of Changes
Vault SDK API Reference Example
apps/portal/src/app/vault/sdk/api-reference/page.mdx
Rewrote MDX to a runnable Spanish tutorial: imports from @thirdweb-dev/vault-sdk and dotenv/config, uses process.env for VAULT_SECRET_KEY, VAULT_SIG_TOKEN, VAULT_BASE_TOKEN; defines async main() calling createVaultClient, ping, createEoa, parseTransaction, signTransaction, createAccessToken, listEoas; adds execution instructions, sample project scaffolding snippets (package.json, tsconfig, .env.example, .gitignore), and main().catch error handling.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer (runs example)
  participant Ex as Example Script (MDX code)
  participant SDK as Vault SDK
  participant Vault as Vault Service
  participant Chain as Blockchain (tx context)

  Dev->>Ex: Run main()
  Ex->>SDK: createVaultClient(SECRET_KEY, BASE_URL?)
  SDK->>Vault: Authenticate / setup
  Vault-->>SDK: Client ready

  Ex->>SDK: ping()
  SDK->>Vault: GET /ping
  Vault-->>SDK: pong
  SDK-->>Ex: pong

  Ex->>SDK: createEoa(metadata {externalAddress})
  SDK->>Vault: POST /eoa
  Vault-->>SDK: EOA details
  SDK-->>Ex: EOA created

  Ex->>SDK: parseTransaction(txInput)
  SDK-->>Ex: tx object (prepared)

  Ex->>SDK: signTransaction(tx, {from, SIG_TOKEN})
  SDK->>Vault: POST /tx/sign
  Vault-->>SDK: signed tx
  SDK-->>Ex: signed tx

  Ex->>SDK: createAccessToken({targetAddress, policy: eoa:signMessage})
  SDK->>Vault: POST /access-tokens
  Vault-->>SDK: access token
  SDK-->>Ex: token

  Ex->>SDK: listEoas({externalAddress})
  SDK->>Vault: GET /eoas?filter=externalAddress
  Vault-->>SDK: EOA list
  SDK-->>Ex: EOAs returned

  Note over Ex: Errors bubbled to main().catch -> console.error
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Portal Involves changes to the Portal (docs) codebase. label Sep 3, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (5)
apps/portal/src/app/vault/sdk/api-reference/page.mdx (5)

98-156: Docs language and section placement.

This API Reference page now hosts a Spanish “How to run” guide and project scaffolding. If the Portal is English-only, move this to a “Guides/Examples” page and keep reference content here, or add i18n routing.

I can split this into: 1) concise API reference (parameters/returns), 2) a separate “End-to-end example” guide.


160-177: Duplicate import block inside the

sample.

The SDK import is repeated twice.

 import {
   createVaultClient,
   ping,
   createEoa,
   listEoas,
   parseTransaction,
   signTransaction,
   createAccessToken,
 } from "@thirdweb-dev/vault-sdk";
-import {
-  createVaultClient,
-  ping,
-  createEoa,
-  listEoas,
-  parseTransaction,
-  signTransaction,
-  createAccessToken,
-} from "@thirdweb-dev/vault-sdk";

101-105: Remove BASE_TOKEN from .env examples if unused.

Avoid suggesting unneeded secrets in user environments.

-VAULT_BASE_TOKEN=tu_access_token_base

Also applies to: 149-151


20-27: Optional: add guardrails to skip network calls in examples.

Consider showing an environment toggle (e.g., if (!SECRET_KEY) throw) in the snippet to fail fast for readers.


82-91: Optional: narrow listEoas filter and show pagination.

Real responses may paginate. Demonstrate handling next page tokens or limits if the SDK exposes them.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b8f4966 and 5965f60.

📒 Files selected for processing (1)
  • apps/portal/src/app/vault/sdk/api-reference/page.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
apps/portal/src/app/vault/sdk/api-reference/page.mdx

[grammar] ~1-~1: There might be a mistake here.
Context: import { createVaultClient, ping, createEoa, ...

(QB_NEW_EN)


[grammar] ~8-~8: There might be a mistake here.
Context: ... signTransaction, createAccessToken, } from "@thirdweb-dev/vault-sdk"; import...

(QB_NEW_EN)


[grammar] ~9-~9: There might be a mistake here.
Context: ...Token, } from "@thirdweb-dev/vault-sdk"; import "dotenv/config"; // --- CONFIGUR...

(QB_NEW_EN)


[grammar] ~14-~14: There might be a mistake here.
Context: ...RET_KEY = process.env.VAULT_SECRET_KEY!; const SIG_TOKEN = process.env.VAULT_SIG_...

(QB_NEW_EN)


[grammar] ~15-~15: There might be a mistake here.
Context: ...IG_TOKEN = process.env.VAULT_SIG_TOKEN!; const BASE_TOKEN = process.env.VAULT_BAS...

(QB_NEW_EN)


[grammar] ~50-~50: There might be a mistake here.
Context: ...acción (usando la dirección como from) const signedTx = await signTransaction({...

(QB_NEW_EN)


[grammar] ~94-~94: There might be a mistake here.
Context: ...rección:", matchingEoas); } // Ejecutar main().catch((err) => { console.error(...

(QB_NEW_EN)


[grammar] ~95-~95: There might be a mistake here.
Context: ...; } // Ejecutar main().catch((err) => { console.error("Error durante la ejecució...

(QB_NEW_EN)


[grammar] ~96-~96: There might be a mistake here.
Context: ...ror("Error durante la ejecución:", err); }); ✅ Requisitos Instala las dependencia...

(QB_NEW_EN)


[grammar] ~97-~97: There might be a mistake here.
Context: ..."Error durante la ejecución:", err); }); ✅ Requisitos Instala las dependencias si...

(QB_NEW_EN)


[grammar] ~98-~98: There might be a mistake here.
Context: ...e la ejecución:", err); }); ✅ Requisitos Instala las dependencias si aún no las t...

(QB_NEW_EN)


[grammar] ~99-~99: There might be a mistake here.
Context: ...a las dependencias si aún no las tienes: npm install @thirdweb-dev/vault-sdk dote...

(QB_NEW_EN)


[grammar] ~100-~100: There might be a mistake here.
Context: ...m install @thirdweb-dev/vault-sdk dotenv Crea un archivo .env en la raíz del proy...

(QB_NEW_EN)


[grammar] ~101-~101: There might be a mistake here.
Context: ... en la raíz del proyecto con tus claves: VAULT_SECRET_KEY=tu_clave_secreta_del_va...

(QB_NEW_EN)


[grammar] ~102-~102: There might be a mistake here.
Context: ...LT_SECRET_KEY=tu_clave_secreta_del_vault VAULT_SIG_TOKEN=tu_access_token_para_fir...

(QB_NEW_EN)


[grammar] ~103-~103: There might be a mistake here.
Context: ...LT_SIG_TOKEN=tu_access_token_para_firmar VAULT_BASE_TOKEN=tu_access_token_base Ej...

(QB_NEW_EN)


[grammar] ~104-~104: There might be a mistake here.
Context: ...ar VAULT_BASE_TOKEN=tu_access_token_base Ejecuta el script: ts-node vault-integra...

(QB_NEW_EN)


[grammar] ~105-~105: There might be a mistake here.
Context: ...=tu_access_token_base Ejecuta el script: ts-node vault-integration.ts Estructura...

(QB_NEW_EN)


[grammar] ~152-~152: There might be a mistake here.
Context: ...EN=tu_access_token_base 4. 📄 .gitignore .env node_modules/ dist/ vault-integrat...

(QB_NEW_EN)


[grammar] ~153-~153: There might be a mistake here.
Context: ..._access_token_base 4. 📄 .gitignore .env node_modules/ dist/ vault-integration.t...

(QB_NEW_EN)


[grammar] ~155-~155: There might be a mistake here.
Context: .... 📄 .gitignore .env node_modules/ dist/ vault-integration.ts Este es el archivo ...

(QB_NEW_EN)


[style] ~158-~158: The word “ya” is non-standard. Did you mean “you”, “your” or “yes”?
Context: ...t-integration.ts Este es el archivo que ya construimos antes. Puedes copiarlo dire...

(YA)


[grammar] ~180-~180: There might be a mistake here.
Context: ...otenv/config"; // --- CONFIGURACIÓN --- const SECRET_KEY = process.env.VAULT_SEC...

(QB_NEW_EN)


[grammar] ~181-~181: There might be a mistake here.
Context: ...RET_KEY = process.env.VAULT_SECRET_KEY!; const SIG_TOKEN = process.env.VAULT_SIG_...

(QB_NEW_EN)


[grammar] ~182-~182: There might be a mistake here.
Context: ...IG_TOKEN = process.env.VAULT_SIG_TOKEN!; const BASE_TOKEN = process.env.VAULT_BAS...

(QB_NEW_EN)


[grammar] ~187-~187: There might be a mistake here.
Context: ...5E6E9FEb21aCE"; async function main() { const client = await createVaultClient({...

(QB_NEW_EN)


[grammar] ~193-~193: There might be a mistake here.
Context: ...esult); const eoa = await createEoa({ client, request: { metadata: {...

(QB_NEW_EN)


[grammar] ~204-~204: There might be a mistake here.
Context: ..., eoa); const tx = parseTransaction({ to: "0xAbC123456789abcdef123456789abcdef...

(QB_NEW_EN)


[grammar] ~213-~213: There might be a mistake here.
Context: ...const signedTx = await signTransaction({ client, request: { auth: { acc...

(QB_NEW_EN)


[grammar] ~225-~225: There might be a mistake here.
Context: ... const token = await createAccessToken({ client, request: { metadata: {...

(QB_NEW_EN)


[grammar] ~243-~243: There might be a mistake here.
Context: ... const matchingEoas = await listEoas({ client, request: { metadata: {...

(QB_NEW_EN)


[grammar] ~255-~255: There might be a mistake here.
Context: ...rr) => { console.error("Error:", err); });

Instrucciones para Ejecu...

(QB_NEW_EN)

🔇 Additional comments (3)
apps/portal/src/app/vault/sdk/api-reference/page.mdx (3)

40-48: Confirm parseTransaction field types.

Some fields are BigInt, others Number (e.g., gasLimit). Ensure this matches the SDK signature to avoid runtime/type errors in user copies.

Would you like me to check the latest Vault SDK docs and adjust the snippet?


63-80: Policy object shape: verify keys.

Double-check that policy.type and fields (chainId, eoa) are current for “eoa:signMessage”.

If desired, I can validate against the latest SDK reference and update.


1-271: PR description mismatch with changes.

PR summary claims an HTML comment template only, but this file introduces a full runnable example and replaces reference content. Please confirm intent.

I can help split this PR or amend the description accordingly.

Comment on lines +1 to +10
import {
createVaultClient,
ping,
createEoa,
listEoas,
parseTransaction,
signTransaction,
createAccessToken,
} from "@thirdweb-dev/vault-sdk";
import "dotenv/config";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Do not import/execute SDK or dotenv in an MDX docs page (leaks secrets, breaks build).

Top-level imports will execute during build/SSR and attempt real network calls. Importing "dotenv/config" in the docs app is especially unsafe and will expose secrets if bundled. Move all runnable code into fenced code blocks; keep the page purely presentational.

Apply this diff to strip runtime imports and start an example section:

-import {
-  createVaultClient,
-  ping,
-  createEoa,
-  listEoas,
-  parseTransaction,
-  signTransaction,
-  createAccessToken,
-} from "@thirdweb-dev/vault-sdk";
-import "dotenv/config";
+{/* The runnable example is provided below as a fenced code block. */}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import {
createVaultClient,
ping,
createEoa,
listEoas,
parseTransaction,
signTransaction,
createAccessToken,
} from "@thirdweb-dev/vault-sdk";
import "dotenv/config";
{/* The runnable example is provided below as a fenced code block. */}
🧰 Tools
🪛 LanguageTool

[grammar] ~1-~1: There might be a mistake here.
Context: import { createVaultClient, ping, createEoa, ...

(QB_NEW_EN)


[grammar] ~8-~8: There might be a mistake here.
Context: ... signTransaction, createAccessToken, } from "@thirdweb-dev/vault-sdk"; import...

(QB_NEW_EN)


[grammar] ~9-~9: There might be a mistake here.
Context: ...Token, } from "@thirdweb-dev/vault-sdk"; import "dotenv/config"; // --- CONFIGUR...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In apps/portal/src/app/vault/sdk/api-reference/page.mdx around lines 1-10,
remove the top-level runtime imports (createVaultClient, ping, createEoa,
listEoas, parseTransaction, signTransaction, createAccessToken and especially
"dotenv/config") so nothing executes at build/SSR; instead add a presentational
"Example" section and place the shown imports and usage inside a fenced code
block (e.g., ```ts ... ```), so the MDX remains purely presentational and no
secrets or network calls occur during build.

Comment on lines +12 to 97
// --- CONFIGURACIÓN ---

---
const SECRET_KEY = process.env.VAULT_SECRET_KEY!;
const SIG_TOKEN = process.env.VAULT_SIG_TOKEN!;
const BASE_TOKEN = process.env.VAULT_BASE_TOKEN!;

## 1. Client utilities
const TARGET_ADDRESS = "0x6561fF4034De957fAFeA20b3aCC5E6E9FEb21aCE";

| Function | Description |
| --- | --- |
| `createVaultClient({ secretKey })` | Uses your project secret key to establish a connection to your Vault instance and returns a `VaultClient`. Create **one** client per Vault instance and reuse it. |
| `ping({ client, request })` | Health-check endpoint mainly used in examples and tests. Returns the current server time. |
async function main() {
// 1. Crear cliente del Vault
const client = await createVaultClient({ secretKey: SECRET_KEY });

```ts
const client = await createVaultClient({ secretKey: "PROJECT_SECRET_KEY" });
await ping({ client, request: { message: "pong?" } });
```
// 2. Hacer ping al Vault (opcional)
const pingResult = await ping({ client, request: { message: "pong?" } });
console.log("Ping response:", pingResult);

---
// 3. Crear un EOA con metadata que incluya la dirección
const eoa = await createEoa({
client,
request: {
metadata: {
label: "Wallet externa",
externalAddress: TARGET_ADDRESS,
},
},
});
console.log("Nuevo EOA creado (metadatos):", eoa);

## 2. Service Accounts
// 4. Crear una transacción ficticia desde la dirección
const tx = parseTransaction({
to: "0xAbC123456789abcdef123456789abcdef1234567", // dirección de destino ficticia
value: 0n,
chainId: 1,
maxFeePerGas: 30n * 10n ** 9n,
maxPriorityFeePerGas: 1n * 10n ** 9n,
gasLimit: 21_000,
});

| Function | When to use |
| --- | --- |
| `createServiceAccount({ request })` | Bootstrap a brand-new Vault. Returns the **admin key** and **rotation code**. _Run once during provisioning_. |
| `getServiceAccount({ request })` | Retrieve metadata for the current service account. Requires **admin key** or a token with `serviceAccount:read` policy. |
| `rotateServiceAccount({ request })` | Rotate (invalidate) the admin key **and** all existing access tokens in a single atomic operation. Authenticate with the **rotation code**. |
// 5. Firmar transacción (usando la dirección como `from`)
const signedTx = await signTransaction({
client,
request: {
auth: { accessToken: SIG_TOKEN },
options: {
from: TARGET_ADDRESS,
transaction: tx,
},
},
});
console.log("Transacción firmada:", signedTx);

Example – rotate an account after a key leak:
// 6. Crear un access token vinculado a la dirección
const token = await createAccessToken({
client,
request: {
metadata: {
name: "Token para wallet específica",
wallet: TARGET_ADDRESS,
},
policies: [
{
type: "eoa:signMessage",
chainId: 1,
eoa: TARGET_ADDRESS,
},
],
},
});
console.log("Access token creado:", token);

```ts
await rotateServiceAccount({
client,
request: {
auth: { rotationCode: process.env.VAULT_ROTATION_CODE! },
},
});
```

---

## 3. EOAs (Wallets)

| Function | Purpose |
| --- | --- |
| `createEoa` | Create a new EOA (wallet) inside the Vault. Optionally attach arbitrary `metadata` for later querying. |
| `listEoas` | Pagination-aware listing with optional metadata filters. |
| `signTransaction` | Ask the Vault to sign an EVM transaction (legacy, 2930, 1559, 4844 or 7702). |
| `signMessage` | Sign a plain string / hex message. |
| `signTypedData` | Sign EIP-712 typed data with full generic type safety. |
| `signAuthorization` | Sign an [`Authorization`](#authorization) struct used by some L2s / account-abstraction schemes. |
| `signStructuredMessage` | Sign EIP-4337 user-operations (v0.6 & v0.7). |

```ts
// sign a 1559 tx
import { parseTransaction, signTransaction } from "@thirdweb-dev/vault-sdk";

const tx = parseTransaction({
to: "0x...",
value: 0n,
chainId: 1,
maxFeePerGas: 30n * 10n ** 9n,
maxPriorityFeePerGas: 1n * 10n ** 9n,
gasLimit: 21_000,
// 7. Listar EOAs que tengan la dirección como metadato
const matchingEoas = await listEoas({
client,
request: {
metadata: {
externalAddress: TARGET_ADDRESS,
},
},
});
console.log("EOAs encontrados con esa dirección:", matchingEoas);
}

// Ejecutar
main().catch((err) => {
console.error("Error durante la ejecución:", err);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Remove executable script from the page; render as a code sample instead.

The main() flow will run at build/SSR time and requires secrets. Convert it to a fenced TypeScript snippet so readers can copy-paste into a Node script.

Proposed replacement:

-// --- CONFIGURACIÓN ---
-const SECRET_KEY = process.env.VAULT_SECRET_KEY!;
-const SIG_TOKEN = process.env.VAULT_SIG_TOKEN!;
-const BASE_TOKEN = process.env.VAULT_BASE_TOKEN!;
-const TARGET_ADDRESS = "0x6561fF4034De957fAFeA20b3aCC5E6E9FEb21aCE";
-async function main() {
-  const client = await createVaultClient({ secretKey: SECRET_KEY });
-  const pingResult = await ping({ client, request: { message: "pong?" } });
-  console.log("Ping response:", pingResult);
-  const eoa = await createEoa({
-    client,
-    request: {
-      metadata: { label: "Wallet externa", externalAddress: TARGET_ADDRESS },
-    },
-  });
-  console.log("Nuevo EOA creado (metadatos):", eoa);
-  const tx = parseTransaction({
-    to: "0xAbC123456789abcdef123456789abcdef1234567",
-    value: 0n,
-    chainId: 1,
-    maxFeePerGas: 30n * 10n ** 9n,
-    maxPriorityFeePerGas: 1n * 10n ** 9n,
-    gasLimit: 21_000,
-  });
-  const signedTx = await signTransaction({
-    client,
-    request: {
-      auth: { accessToken: SIG_TOKEN },
-      options: { from: TARGET_ADDRESS, transaction: tx },
-    },
-  });
-  console.log("Transacción firmada:", signedTx);
-  const token = await createAccessToken({
-    client,
-    request: {
-      metadata: { name: "Token para wallet específica", wallet: TARGET_ADDRESS },
-      policies: [{ type: "eoa:signMessage", chainId: 1, eoa: TARGET_ADDRESS }],
-    },
-  });
-  console.log("Access token creado:", token);
-  const matchingEoas = await listEoas({
-    client,
-    request: { metadata: { externalAddress: TARGET_ADDRESS } },
-  });
-  console.log("EOAs encontrados con esa dirección:", matchingEoas);
-}
-// Ejecutar
-main().catch((err) => {
-  console.error("Error durante la ejecución:", err);
-});
+```ts
+// vault-integration.ts (Node/TS script - do not run in the browser)
+import "dotenv/config";
+import {
+  createVaultClient,
+  ping,
+  createEoa,
+  listEoas,
+  parseTransaction,
+  signTransaction,
+  createAccessToken,
+} from "@thirdweb-dev/vault-sdk";
+
+const SECRET_KEY = process.env.VAULT_SECRET_KEY!;
+const SIG_TOKEN = process.env.VAULT_SIG_TOKEN!;
+const TARGET_ADDRESS = process.env.TARGET_ADDRESS ?? "0xYourAddress";
+
+async function main() {
+  const client = await createVaultClient({ secretKey: SECRET_KEY });
+  const pingResult = await ping({ client, request: { message: "pong?" } });
+  console.log("Ping response:", pingResult);
+
+  const eoa = await createEoa({
+    client,
+    request: { metadata: { label: "Wallet externa", externalAddress: TARGET_ADDRESS } },
+  });
+  console.log("Nuevo EOA creado (metadatos):", eoa);
+
+  const tx = parseTransaction({
+    to: "0xAbC123456789abcdef123456789abcdef1234567",
+    value: 0n,
+    chainId: 1,
+    maxFeePerGas: 30n * 10n ** 9n,
+    maxPriorityFeePerGas: 1n * 10n ** 9n,
+    gasLimit: 21_000,
+  });
+
+  const signedTx = await signTransaction({
+    client,
+    request: { auth: { accessToken: SIG_TOKEN }, options: { from: TARGET_ADDRESS, transaction: tx } },
+  });
+  console.log("Transacción firmada:", signedTx);
+
+  const token = await createAccessToken({
+    client,
+    request: {
+      metadata: { name: "Token para wallet específica", wallet: TARGET_ADDRESS },
+      policies: [{ type: "eoa:signMessage", chainId: 1, eoa: TARGET_ADDRESS }],
+    },
+  });
+  console.log("Access token creado:", token);
+
+  const matchingEoas = await listEoas({ client, request: { metadata: { externalAddress: TARGET_ADDRESS } } });
+  console.log("EOAs encontrados con esa dirección:", matchingEoas);
+}
+
+main().catch((err) => {
+  console.error("Error durante la ejecución:", err);
+});
+```
🧰 Tools
🪛 LanguageTool

[grammar] ~14-~14: There might be a mistake here.
Context: ...RET_KEY = process.env.VAULT_SECRET_KEY!; const SIG_TOKEN = process.env.VAULT_SIG_...

(QB_NEW_EN)


[grammar] ~15-~15: There might be a mistake here.
Context: ...IG_TOKEN = process.env.VAULT_SIG_TOKEN!; const BASE_TOKEN = process.env.VAULT_BAS...

(QB_NEW_EN)


[grammar] ~50-~50: There might be a mistake here.
Context: ...acción (usando la dirección como from) const signedTx = await signTransaction({...

(QB_NEW_EN)


[grammar] ~94-~94: There might be a mistake here.
Context: ...rección:", matchingEoas); } // Ejecutar main().catch((err) => { console.error(...

(QB_NEW_EN)


[grammar] ~95-~95: There might be a mistake here.
Context: ...; } // Ejecutar main().catch((err) => { console.error("Error durante la ejecució...

(QB_NEW_EN)


[grammar] ~96-~96: There might be a mistake here.
Context: ...ror("Error durante la ejecución:", err); }); ✅ Requisitos Instala las dependencia...

(QB_NEW_EN)


[grammar] ~97-~97: There might be a mistake here.
Context: ..."Error durante la ejecución:", err); }); ✅ Requisitos Instala las dependencias si...

(QB_NEW_EN)

🤖 Prompt for AI Agents
apps/portal/src/app/vault/sdk/api-reference/page.mdx lines 12-97: the file
contains an executable top-level main() script that will run at build/SSR time
and requires secrets; replace the runnable code with a fenced TypeScript code
sample (triple backticks with "ts") that demonstrates usage but does not execute
during rendering — include suggested changes: move dotenv import and example
imports into the snippet, read secrets from process.env (e.g., TARGET_ADDRESS
fallback), keep all async logic inside an exported or example main() function
but do not call main() in the MDX page, and add a short comment line that this
is a Node/TS script (do not run in the browser).

Comment on lines +14 to +16
const SECRET_KEY = process.env.VAULT_SECRET_KEY!;
const SIG_TOKEN = process.env.VAULT_SIG_TOKEN!;
const BASE_TOKEN = process.env.VAULT_BASE_TOKEN!;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Secrets in client-visible context; remove BASE_TOKEN (unused).

Do not reference secrets from a docs page; ensure examples instruct running in Node with .env, not inside MDX. Also BASE_TOKEN is never used—drop it from code and docs to avoid confusion.

-const BASE_TOKEN = process.env.VAULT_BASE_TOKEN!;

And remove its mentions in the “.env example” below.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const SECRET_KEY = process.env.VAULT_SECRET_KEY!;
const SIG_TOKEN = process.env.VAULT_SIG_TOKEN!;
const BASE_TOKEN = process.env.VAULT_BASE_TOKEN!;
const SECRET_KEY = process.env.VAULT_SECRET_KEY!;
const SIG_TOKEN = process.env.VAULT_SIG_TOKEN!;
🧰 Tools
🪛 LanguageTool

[grammar] ~14-~14: There might be a mistake here.
Context: ...RET_KEY = process.env.VAULT_SECRET_KEY!; const SIG_TOKEN = process.env.VAULT_SIG_...

(QB_NEW_EN)


[grammar] ~15-~15: There might be a mistake here.
Context: ...IG_TOKEN = process.env.VAULT_SIG_TOKEN!; const BASE_TOKEN = process.env.VAULT_BAS...

(QB_NEW_EN)

Comment on lines +117 to +133
{
"name": "vault-project",
"version": "1.0.0",
"type": "module",
"main": "vault-integration.ts",
"scripts": {
"start": "ts-node vault-integration.ts"
},
});
```

> **Note**: `parseTransaction` is a convenience helper that normalises user-supplied objects – you can also build the canonical tx object yourself.
---

## 4. Access Tokens

| Function | Purpose |
| --- | --- |
| `createAccessToken` | Mint a **base token** scoped by policies & metadata. Requires **admin key**. |
| `createSignedAccessToken` | Pure-client helper that turns a *base* token into a short-lived, signed JWT (prefixed with `vt_sat_`). No server round-trip required. |
| `listAccessTokens` | List existing tokens with pagination and optional metadata filters. |
| `revokeAccessToken` | Immediately invalidate a token (or all derived signed tokens) by `id`. |

```ts
// Derive a time-boxed signed token for a serverless function
const sat = await createSignedAccessToken({
vaultClient: client,
baseAccessToken: process.env.VAULT_BASE_TOKEN!,
additionalPolicies: [
{ type: "eoa:signMessage", chainId: 1, messagePattern: "^0x.*" },
],
expiryTimestamp: Math.floor(Date.now() / 1000) + 60 * 5, // 5 min
});
```
"dependencies": {
"@thirdweb-dev/vault-sdk": "^0.9.0",
"dotenv": "^16.3.1"
},
"devDependencies": {
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Dependency versions: confirm current releases.

The example pins versions (^0.9.0, ^16.3.1, ts-node ^10.9.1, TS ^5.2.2). Please verify these are still current or adjust to known-good ranges.


🌐 Web query:

What is the latest stable version of @thirdweb-dev/vault-sdk, dotenv, ts-node, and typescript?

💡 Result:

As of Sep 3, 2025:

  • @thirdweb-dev/vault-sdk — 0.0.3. [1]
  • dotenv — 17.2.2. [2]
  • ts-node — 10.9.2. [3]
  • typescript — 5.8.3. [4]

Sources:
[1] @thirdweb-dev/vault-sdk (Libraries.io).
[2] dotenv (npm).
[3] ts-node (npm).
[4] typescript (npm).


Update dependency versions in example: bump @thirdweb-dev/vault-sdk to ^0.0.3, dotenv to ^17.2.2, ts-node to ^10.9.2, and typescript to ^5.8.3 to match the latest stable releases.

🤖 Prompt for AI Agents
In apps/portal/src/app/vault/sdk/api-reference/page.mdx around lines 117 to 133,
the example package.json uses outdated dependency versions; update the
dependency entries to bump "@thirdweb-dev/vault-sdk" to "^0.0.3", "dotenv" to
"^17.2.2", "ts-node" to "^10.9.2", and "typescript" to "^5.8.3" (leave other
fields unchanged) so the example reflects the requested newer stable releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Portal Involves changes to the Portal (docs) codebase.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants