Guidance for AI agents (and humans) working with code in this repository.
The MultiversX dApp Template for React.js — a reference implementation of @multiversx/sdk-dapp demonstrating MultiversX wallet authentication and transaction signing. The source is plain JavaScript/JSX (no tsconfig.json).
Toolchain: Node 24+, pnpm 11 (there is a pnpm-lock.yaml — use pnpm, not npm/yarn), Vite 8 (Rolldown).
Dev server (HTTPS on https://localhost:3000, via @vitejs/plugin-basic-ssl) — pick the target network:
pnpm start-devnet # or start-testnet / start-mainnetBuild (to dist/):
pnpm build-devnet # or build-testnet / build-mainnetLint (must pass; ESLint enforces formatting via the prettier plugin):
pnpm lint
pnpm lint:fixThere is no test runner configured in this repo.
The start-* / build-* scripts cp src/config/config.<network>.js over src/config/index.js (via &&, before Vite runs). So:
src/config/index.jsis a generated file — do not edit it by hand; it is overwritten on every start/build. Editconfig.devnet.js,config.testnet.js,config.mainnet.js, or the sharedsharedConfig.jsinstead.- Each per-network config sets
API_URL,contractAddress,environment, and re-exportssharedConfig.js(containswalletConnectV2ProjectId,nativeAuth, sample batch-transaction SC data, etc.). main.jsximportsenvironmentfrom@/configand passes it toinitApp— the copy mechanism is the single source of truth for the network.
src/lib/is a wrapper layer around the SDK.@multiversx/sdk-dappis imported via deep paths (e.g.@multiversx/sdk-dapp/out/react/account/useGetAccount). Rather than scatter those deep imports across the app,src/lib/sdkDapp/*re-exports them grouped by concern (.hooks,.methods,.managers,.providers,.helpers,.constants,.types, plus wrappedcomponents/). App code should import from@/lib(or@/lib/sdkDapp/...), not from@multiversx/...deep paths directly. When you need an SDK export not yet surfaced, add it to the appropriatesrc/lib/sdkDapp/*file.- Path alias
@→/src(configured invite.config.jsandeslint.config.js). Always use@/...imports. - Routing (
src/routes/routes.js+src/App.jsx): routes are a data array;App.jsxmaps them and wraps each inAuthenticatedRoute, which redirects to/unlockwhenroute.authenticatedRouteis true and the user is not logged in (useGetIsLoggedIn). - Transaction flow (see
src/pages/Dashboard/widgets/SendToSelf/hooks/useSendToSelfTransaction.jsas the canonical example): build aTransactionfrom@multiversx/sdk-core→getAccountProvider().signTransactions()→TransactionManager.getInstance().send()→.track()for toast/status. Account nonce comes fromuseGetAccount(), chain ID fromuseGetNetworkConfig(). - Pages → widgets:
Dashboardcomposes self-containedwidgets/(Account, SendToSelf, SignMessage, etc.), each a folder with its owncomponents/,hooks/, andhelpers/and a barrelindex.js. - Barrel files everywhere: nearly every folder exposes an
index.jsre-exporting its contents; import from the folder, not the file.
sort-exports/sort-exportsandimport/order(alphabetized, grouped builtin→external→internal→parent→sibling→index,reacthoisted first, no blank lines between groups) are errors — keep exports and imports sorted orpnpm lintfails.import/no-unresolvedignores@multiversx/.*(deep/out/paths don't resolve statically) and.svg?reactvirtual imports.*.config.{js,cjs}files disable a fewimport/*rules that misfire on Vite plugin dist bundles.
To prove a change works, run in order:
pnpm lint # must pass
pnpm build-devnet # production build must succeedThere are no automated tests — for login/transaction changes, start pnpm start-devnet, open https://localhost:3000, and exercise the flow manually. After build-testnet/build-mainnet runs, run a devnet build (or cp src/config/config.devnet.js src/config/index.js) so the committed src/config/index.js shows no diff.
The same template dApp exists for other frameworks — useful when a task actually targets a different stack:
| Template | Stack | Repository |
|---|---|---|
| React (TypeScript) | React 18 · TypeScript · Vite | mx-template-dapp |
| React (JavaScript) ← this repo | React 19 · JSX · Vite | mx-template-dapp-reactjs |
| Next.js | Next.js 16 (App Router) · TypeScript | mx-template-dapp-nextjs |
| SolidJS | SolidJS · TypeScript · Vite | mx-template-dapp-solidjs |
| Vue | Vue 3 · TypeScript · Vite | mx-template-dapp-vue |
| Angular | Angular 20 · TypeScript | mx-template-dapp-angular |
| React Native | React Native | mx-template-dapp-react-native |