Frontend workspace for deploying and inspecting Carbon tokens on Phantasma.
Built with Next.js (App Router) and @phantasma/connect-react so dApps can connect to Phantasma Link, assemble Carbon create-token transactions, and broadcast them end‑to‑end without a backend.
| Area | Choice | Notes |
|---|---|---|
| Framework | Next.js 15 (App Router, TypeScript) | Turbopack dev/build; deployment is SSR-friendly. |
| UI Toolkit | Tailwind utility classes + custom cards | Minimal, no CSS-in-JS. |
| Wallet Integration | @phantasma/connect-react |
Provides PhaConnectState, PhaAccountWidgetV1, and Link/socket handling. |
| Phantasma SDK | phantasma-sdk-ts (local file: dependency) |
We copy the SDK into node_modules/phantasma-sdk-ts so the frontend uses the latest Carbon helpers. |
| Toasts/Alerts | sonner |
Non-blocking notification stack. |
src/
app/
deploy/page.tsx // main deployment UI
components/
DebugLogger.tsx // structured log viewer with copy/reset
PhantasmaProvider.tsx // wraps app with PhaConnectState
lib/
phantasmaClient.ts // RPC + Link integration (tokens + create flow)
-
Deploy page (
deploy/page.tsx)- Connects to the wallet with
PhaAccountWidgetV1. - Displays paginated list of currently owned tokens with expandable detail view.
- Provides full create-token form (symbol, decimals, metadata, fee parameters).
- Shows transaction confirmation status (pending → success/failure) with copyable hash.
- Includes structured debug log viewer at the bottom for troubleshooting.
- Connects to the wallet with
-
phantasmaClient.ts- Wraps
phantasma-sdk-tsCarbon helpers for frontend use. - Builds metadata using
TokenMetadataBuilder, appliesCreateTokenFeeOptions. - Sends the Carbon transaction via Link (
signCarbonTransaction), waits for on-chain confirmation by pollinggetTransaction. - Returns rich result object with
tokenId/ failure diagnostics. - Exposes
getTokens(owner)to fetch token inventory for the current wallet address.
- Wraps
-
Node.js 18+ (ES2022 features +
BigIntusage). -
Phantasma Link (v4+) wallet
Required forsignCarbonTransactioncapability.
npm install
npm run dev # starts Next dev server with TurbopackEnvironment variables (.env.local):
NEXT_PUBLIC_API_URL=http://localhost:5172/rpc
NEXT_PUBLIC_PHANTASMA_NEXUS=testnet- Connect wallet via top-right
PhaAccountWidgetV1. - Review existing tokens:
- List is paginated (10 entries per page).
- Click chevron on a token to inspect metadata and raw JSON.
- Refresh button refetches complete list from RPC.
- configure new token:
- Type toggle (fungible vs NFT). NFT forces decimals to 0.
- Symbol (uppercase enforced), optional name, max supply.
- Metadata tools: upload logo (Data URI) and add arbitrary key/value entries.
- Fees & limits: editable gas parameters with sane defaults (matches current Carbon expected values).
- Deploy:
- Submits Carbon create token request via Link.
- UI shows
pendingstatus until RPC confirms success/failure (polling withgetTransaction). - On success, hash + optional tokenId are shown with a copy button; tokens list auto-refreshes and new token detail is expanded.
- On failure, the failure reason from RPC (
debugCommentorresult) is surfaced.
Debug logs capture each step (fee parsing, metadata payload, RPC responses) for easier troubleshooting.
- Wait for confirmation:
waitForTransactionConfirmationpollsgetTransactionup to 30 times (1s interval), returning:successwithtxdata,failurewith debug message,- or
timeout. UI renders the result accordingly.
- Public key derivation: addresses are decoded via
Address.FromText(...).GetPublicKey().
- Link endpoint mismatch: Ensure Phantasma Link is updated to a Carbon-capable release (v4+). The official
@phantasma/connect-reacthandles messaging; inspect the browser console if Link reports errors. - Metadata issues: Structured form builds metadata JSON automatically. Inspect compiled metadata payload in debug logs before submission.
- RPC confirmation: When transactions seem “stuck”, check Link console output and
Debug Logs. The confirmation loop stops at 30 seconds; failures includedebugCommentif available.
| Command | Description |
|---|---|
npm run dev |
Start Next.js dev server (Turbopack). |
npm run build |
Production build. |
npm run start |
Serve production build. |
npm run lint |
ESLint (ignores structured logs but enforces TS rules for repo sources). |
- Integrate token-series creation & NFT minting.