9.0 KiB
TokenizeRWATemplate-frontend
This starter React project has been generated using AlgoKit. See below for default getting started instructions.
Setup
Initial Setup
1. Clone the Repository
Start by cloning this repository to your local machine.
2. Install Pre-requisites
Ensure the following pre-requisites are installed and properly configured:
- npm: Node package manager. Install from Node.js Installation Guide. Verify with
npm -vto see version18.12+. - AlgoKit CLI: Essential for project setup and operations. Install the latest version from AlgoKit CLI Installation Guide. Verify installation with
algokit --version, expecting2.0.0or later.
3. Bootstrap Your Local Environment
Run the following commands within the project folder:
- Install Project Dependencies: With
algokit project bootstrap all, ensure all dependencies are ready.
Development Workflow
Terminal
Directly manage and interact with your project using AlgoKit commands:
- Build Contracts:
algokit project run buildbuilds react web app and links with smart contracts in workspace, if any. - Remaining set of command for linting, testing and deployment can be found in respective package.json file and .algokit.toml files.
VS Code
For a seamless experience with breakpoint debugging and other features:
- Open Project: In VS Code, open the repository root.
- Install Extensions: Follow prompts to install recommended extensions.
- Debugging:
- Use
F5to start debugging. - Windows Users: Select the Python interpreter at
./.venv/Scripts/python.exeviaCtrl/Cmd + Shift + P>Python: Select Interpreterbefore the first run.
- Use
Other IDEs
While primarily optimized for VS Code, Jetbrains WebStorm has base support for this project:
- Open Project: In your JetBrains IDE, open the repository root.
- Automatic Setup: The IDE should configure the Python interpreter and virtual environment.
- Debugging: Use
Shift+F10orCtrl+Rto start debugging. Note: Windows users may encounter issues with pre-launch tasks due to a known bug. See JetBrains forums for workarounds.
AlgoKit Workspaces and Project Management
This project supports both standalone and monorepo setups through AlgoKit workspaces. Leverage algokit project run commands for efficient monorepo project orchestration and management across multiple projects within a workspace.
Please note, by default frontend is pre configured to run against Algorand LocalNet. If you want to run against TestNet or MainNet, comment out the current environment variable and uncomment the relevant one in
.envfile that is created after running bootstrap command and based on.env.template.
Continuous Integration
This project uses GitHub Actions to define CI workflows, which are located in the .github/workflows folder.
For pull requests and pushes to main branch against this repository the following checks are automatically performed by GitHub Actions:
install: Installs dependencies usingnpmlint: Lints the codebase usingESLintbuild: Builds the codebase usingvite
Please note, if you instantiated the project via
algokit initwithout explicitly specifying the--no-workspaceflag, we will automatically attempt to move the contents of the.githubfolder to the root of the workspace.
Continuous Deployment
The project template provides base Github Actions workflows for continuous deployment to Netlify or Vercel. These workflows are located in the .github/workflows folder.
Please note: when configuring the github repository for the first time. Depending on selected provider you will need to set the provider secrets in the repository settings. Default setup provided by the template allows you to manage the secrets via environment variables and secrets on your github repository.
Setting up environment variables and secrets for webapp deployment
For Vercel:
- Retrieve your Vercel Access Token
- Install the Vercel CLI and run
vercel login - Inside your folder, run
vercel linkto create a new Vercel project - Inside the generated
.vercelfolder, save theprojectIdandorgIdfrom theproject.json - Inside GitHub, add
VERCEL_TOKEN,VERCEL_ORG_ID, andVERCEL_PROJECT_IDas secrets. - Create an .env file containing ENV vars for the project (pointing to testnet or mainnet), drag and drop the .env file to upload initial batch of default environment variables to your vercel project.
- Upon invocation, CD pipeline will pull the VITE_ prefixed environment variables, build the project and deploy to the specified environment.
For Netlify:
- Retrieve your Netlify Access Token
- Inside your folder run
netlify login - Inside your folder run
netlify sites:createto create a new site, obtain NETLIFY_SITE_ID from the output - Inside GitHub, add
NETLIFY_AUTH_TOKENandNETLIFY_SITE_IDas secrets. - Define the VITE_ prefixed environment variables in netlify environment variables under site settings.
- Upon invocation, CD pipeline will build the project and deploy to the specified environment.
If you prefer alternative deployment methods, you can modify the relevant workflow files from the
.github/workflowsfolder or modify deploy scripts in.algokit.toml.
Algorand Wallet integrations
The template comes with use-wallet integration, which provides a React hook for connecting to an Algorand wallet providers. The following wallet providers are included by default:
- LocalNet:
-
- KMD/Local Wallet - Algorand's Key Management Daemon (KMD) is a service that manages Algorand private keys and signs transactions. Works best with AlgoKit LocalNet and allows you to easily test and interact with your dApps locally.
- TestNet and others:
Refer to official use-wallet documentation for detailed guidelines on how to integrate with other wallet providers (such as WalletConnect v2). Too see implementation details on the use wallet hook and initialization of extra wallet providers refer to App.tsx.
Tools
This project makes use of React and Tailwind to provider a base project configuration to develop frontends for your Algorand dApps and interactions with smart contracts. The following tools are in use:
- AlgoKit Utils - Various TypeScript utilities to simplify interactions with Algorand and AlgoKit.
- React - A JavaScript library for building user interfaces.
- Tailwind CSS - A utility-first CSS framework for rapidly building custom designs.
- daisyUI - A component library for Tailwind CSS.
- use-wallet - A React hook for connecting to an Algorand wallet providers.
- npm: Node.js package manager
- jest: JavaScript testing framework
- playwright: Browser automation library
- Prettier: Opinionated code formatter
- ESLint: Tool for identifying and reporting on patterns in JavaScript
- Github Actions workflows for build validation It has also been configured to have a productive dev experience out of the box in VS Code, see the .vscode folder.
Integrating with smart contracts and application clients
Refer to the detailed guidance on integrating with smart contracts and application clients. In essence, for any smart contract codebase generated with AlgoKit or other tools that produce compile contracts into ARC34 compliant app specifications, you can use the algokit generate command to generate TypeScript or Python typed client. Once generated simply drag and drop the generated client into ./src/contracts and import it into your React components as you see fit.