Welcome to the MultiversX sdk-dapp v5 tutorial! 🚀
This tutorial will guide you through the process of building a dApp from scratch with React, Tailwind, @multiversx/sdk-core and @multiversx/sdk-dapp.
You can find the video tutorial on the MultiversX YouTube channel.
You can find the documentation for the sdk-dapp v5 in the MultiversX sdk-dapp v5 documentation.
Either follow along with the video tutorials or go to a specific section either by checking out a specific git commit or by running the setup scripts.
Example: Running the setup scripts for the first section
cd ./mx-tutorial-sdk-dapp-v5/tutorial/01_create_react_app && bash run_project_setup.shThis will run all the setup scripts for all the sections.
cd ./mx-tutorial-sdk-dapp-v5/tutorial && bash run_all.sh- Creating a new React project with Vite
- Preparing the basic App structure with routing
- Installing sdk-dapp & its dependencies
- Creating the Dashboard with Widgets
- Creating Header, Footer and Layout components
- Connecting and Testing the dApp functionality
- Create a new Vite React project (TypeScript template)
- Install dependencies
- Install Tailwind CSS and its dependencies
- Add tailwind.config.js configuration
- Add postcss.config.js configuration
- Replace contents of src/index.css with Tailwind directives
- Copy the multiversx-white.svg file to the public folder
- Configure eslint and prettier
- Configure .prettierrc file
- Configure eslint.config.js file
- Install Vite configuration dependencies
- Configure vite.config.ts (globals and https)
- Configure tsconfig.json (absolute imports)
- Add formatting scripts to package.json
- Run lint to fix errors
- Check if the project is running
- Install react-router-dom
- Create pages folder and Home page component
- Create routes folder under /src
- Create routes configuration files (index.ts, routes.ts)
- Create Layout component
- Update App.tsx file with routing configuration
- Run lint to fix errors
- Install MultiversX SDK packages (@multiversx/sdk-dapp and related dependencies)
- Create configs for the dApp (config.devnet.ts, contract address)
- Create the dashboard folder structure
- Install FontAwesome and classnames dependencies
- Create helper components (Button, Label, OutputContainer)
- Create the Account widget component
- Create the PingPong widget component
- Create widgets index file for exports
- Create the Dashboard page component
- Export the Dashboard page from pages
- Update the routes configuration with Dashboard
- Run lint to fix errors
- Create generic link component
- Create Unlock page component
- Create Header component with navigation
- Create Footer component
- Update Layout component to use Header and Footer
- Create Transactions widget component
- Update Dashboard page to include Transactions widget
- Run lint to fix errors
- Initialize SDK in main.tsx with dApp configuration
- Update Unlock component and Header navigation with sdk-dapp hooks
- Create FormatAmount component for account widget
- Create TransactionsTable and update Transactions widget
- Create PingPong widget with contract ABI and functionality
- Create AuthenticatedRoutesWrapper component for route protection
%% User Flow
flowchart TD
A[User Enters App] --> B{Is User Logged In?}
B -->|No| C[Home Page]
B -->|Yes| D[Dashboard]
C --> E{User Clicks Unlock/Connect}
E --> F[Unlock Panel Opens]
F --> G{Wallet Connection Successful?}
G -->|Yes| H[Redirect to Dashboard]
G -->|No/Cancelled| I[Stay on Home Page]
D --> J{User Logs Out}
J --> K[Redirect to Home Page]
D --> L[Account Widget]
D --> M[Ping-Pong Smart Contract Widget]
D --> N[Transactions Widget]
M --> O[Send Ping Transaction]
M --> P[Send Pong Transaction]
O --> Q[Transaction Processing]
P --> Q
Q --> R{Transaction Success?}
R -->|Yes| S[Update UI State]
R -->|No| T[Show Error]
S --> U[Refresh Account Balance]
T --> V[Show Error Message]
L --> W[Display Account Info]
L --> X[Show Balance & Address]
N --> Y[Show Transaction History]
N --> Z[Display Transaction Status]
%% Decision boxes (diamond shapes)
style B fill:#444444,stroke:#444444,color:#ffffff
style E fill:#444444,stroke:#444444,color:#ffffff
style G fill:#444444,stroke:#444444,color:#ffffff
style J fill:#444444,stroke:#444444,color:#ffffff
style R fill:#444444,stroke:#444444,color:#ffffff
%% Regular boxes (rectangles)
style A fill:#666666,stroke:#666666,color:#ffffff
style C fill:#666666,stroke:#666666,color:#ffffff
style D fill:#666666,stroke:#666666,color:#ffffff
style F fill:#666666,stroke:#666666,color:#ffffff
style H fill:#666666,stroke:#666666,color:#ffffff
style I fill:#666666,stroke:#666666,color:#ffffff
style K fill:#666666,stroke:#666666,color:#ffffff
style L fill:#666666,stroke:#666666,color:#ffffff
style M fill:#666666,stroke:#666666,color:#ffffff
style N fill:#666666,stroke:#666666,color:#ffffff
style O fill:#666666,stroke:#666666,color:#ffffff
style P fill:#666666,stroke:#666666,color:#ffffff
style Q fill:#666666,stroke:#666666,color:#ffffff
style S fill:#666666,stroke:#666666,color:#ffffff
style T fill:#666666,stroke:#666666,color:#ffffff
style U fill:#666666,stroke:#666666,color:#ffffff
style V fill:#666666,stroke:#666666,color:#ffffff
style W fill:#666666,stroke:#666666,color:#ffffff
style X fill:#666666,stroke:#666666,color:#ffffff
style Y fill:#666666,stroke:#666666,color:#ffffff
style Z fill:#666666,stroke:#666666,color:#ffffff
%% Application structure
flowchart TD
%% Pages Group
subgraph " Pages"
A[App.tsx]
C[Home.tsx]
D[Dashboard.tsx]
E[Unlock.tsx]
end
%% Layout Components
A --> B[Layout.tsx]
%% Layout Components
B --> F[Header.tsx]
B --> G[Footer.tsx]
B --> H[AuthRedirectWrapper.tsx]
%% Dashboard Widgets Group
subgraph "Dashboard Widgets"
I[Account.tsx]
J[PingPongAbi.tsx]
K[Transactions.tsx]
end
%% Dashboard Widgets
D --> I
D --> J
D --> K
%% Custom Hooks Group
subgraph "Hooks"
V[useSendPingTransaction]
W[useSendPongTransaction]
X[useGetSecondsRemaining]
CC[useGetPingAmount]
DD[useGetSmartContractFactory]
ZZ[useGetScController]
end
%% Custom Hooks Usage
J --> V
J --> W
J --> X
%% Hook Dependencies
V --> CC
V --> DD
W --> DD
CC --> ZZ
DD --> ZZ
%% Common Components Group (positioned below)
ZZ ~~~ P
subgraph "Components"
P[Button.tsx]
N[Label.tsx]
M[OutputContainer.tsx]
GG[Generic Link.tsx]
O[FormatAmount.tsx]
T[TransactionsTable.tsx]
end
%% Styling
style A fill:#000000,stroke:#000000,color:#ffffff
style B fill:#000000,stroke:#000000,color:#ffffff
style C fill:#000000,stroke:#000000,color:#ffffff
style D fill:#000000,stroke:#000000,color:#ffffff
style E fill:#000000,stroke:#000000,color:#ffffff
style F fill:#000000,stroke:#000000,color:#ffffff
style G fill:#000000,stroke:#000000,color:#ffffff
style H fill:#000000,stroke:#000000,color:#ffffff
style I fill:#000000,stroke:#000000,color:#ffffff
style J fill:#000000,stroke:#000000,color:#ffffff
style K fill:#000000,stroke:#000000,color:#ffffff
style M fill:#000000,stroke:#000000,color:#ffffff
style N fill:#000000,stroke:#000000,color:#ffffff
style O fill:#000000,stroke:#000000,color:#ffffff
style P fill:#000000,stroke:#000000,color:#ffffff
style T fill:#000000,stroke:#000000,color:#ffffff
style V fill:#000000,stroke:#000000,color:#ffffff
style W fill:#000000,stroke:#000000,color:#ffffff
style X fill:#000000,stroke:#000000,color:#ffffff
style CC fill:#000000,stroke:#000000,color:#ffffff
style DD fill:#000000,stroke:#000000,color:#ffffff
style GG fill:#000000,stroke:#000000,color:#ffffff