Skip to main content

Installation

This guide will walk you through setting up Scaffold Stark React Native for mobile dApp development on Starknet.

Prerequisitesโ€‹

Before you begin, ensure you have the following tools installed:

Core Requirementsโ€‹

  • Node.js (>= v24) - We recommend using nvm for version management
  • Yarn (v1 or v2+)
  • Git

Starknet Developer Toolsโ€‹

Install the Starknet development toolchain using Starkup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.starkup.sh | sh

This will install:

  • Scarb 2.16.0 - Cairo package manager and build toolchain
  • Starknet Foundry 0.57.0 - Testing framework for Starknet
  • asdf - Version manager for tool versions
  • Cairo 1.0 VSCode Extension - Syntax highlighting and language support
  • Starknet Devnet 0.7.2 - Local development network

Mobile Development Setupโ€‹

iOS Development (macOS only)โ€‹

  1. Install Xcode from the Mac App Store

  2. Configure Command Line Tools:

    • Open Xcode
    • Go to Settings > Locations
    • Select your Xcode version in the Command Line Tools dropdown
  3. Add iOS Simulator:

    • Open Xcode
    • Go to Settings > Components
    • Download an iOS Simulator (iOS 17+ recommended)
  4. Install Watchman (recommended for file watching):

    brew install watchman

Android Developmentโ€‹

  1. Install Android Studio from developer.android.com

  2. Configure Android SDK:

    • Open Android Studio
    • Go to Settings > Languages & Frameworks > Android SDK
    • Install the latest Android SDK Platform (API 34+)
    • Install Android SDK Build-Tools
  3. Set Environment Variables (add to ~/.bashrc or ~/.zshrc):

    export ANDROID_HOME=$HOME/Android/Sdk
    export PATH=$PATH:$ANDROID_HOME/emulator
    export PATH=$PATH:$ANDROID_HOME/platform-tools
  4. Create Virtual Device:

    • Open Android Studio
    • Go to Tools > Device Manager
    • Click Create Virtual Device
    • Select a device definition and system image

Quick Startโ€‹

1. Create a New Projectโ€‹

Use the create-stark-rn CLI to scaffold a new project:

npx create-stark-rn my-dapp

The CLI will interactively prompt you for:

  • Project name (default: my-stark-app)
  • Include example smart contracts (Starknet Foundry) โ€” default: yes
  • Package manager โ€” npm, yarn, or pnpm (auto-detects your system default)

This creates a monorepo with packages/rn (React Native app) and optionally packages/snfoundry (smart contracts), installs dependencies, and initializes a git repository.

Alternative: Clone the Repository

You can also clone the repository directly for development or contribution:

git clone https://github.com/Scaffold-Stark/scaffold-stark-rn.git
cd scaffold-stark-rn
yarn install

2. Start the Local Devnetโ€‹

In a separate terminal, start the Starknet local development network:

cd my-dapp
yarn chain

This runs starknet-devnet with a seed of 0 for consistent account addresses during development.

3. Deploy Contractsโ€‹

With the devnet running, deploy the example contracts:

yarn deploy

4. Start the Mobile Appโ€‹

For iOS:โ€‹

yarn ios

This will:

  • Start the Expo development server
  • Launch the iOS Simulator
  • Install and run the app

For Android:โ€‹

yarn android

This will:

  • Start the Expo development server
  • Launch the Android Emulator
  • Install and run the app

For Development Server Only:โ€‹

yarn start

Then press i for iOS or a for Android, or scan the QR code with the Expo Go app on your physical device.

Project Structureโ€‹

After scaffolding, your project will have this structure:

my-dapp/
โ”œโ”€โ”€ packages/
โ”‚ โ”œโ”€โ”€ rn/ # React Native app (Expo)
โ”‚ โ”‚ โ”œโ”€โ”€ app/ # Expo Router file-based routing
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ (tabs)/ # Tab layout group
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ index.tsx # Home page
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ debug.tsx # Debug contracts page
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ settings.tsx # Settings/wallet page
โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ _layout.tsx # Custom tab navigator
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ _layout.tsx # Root layout with providers
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ _components/ # App-specific components
โ”‚ โ”‚ โ”œโ”€โ”€ components/
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ scaffold-stark/ # Reusable scaffold components
โ”‚ โ”‚ โ”œโ”€โ”€ hooks/
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ scaffold-stark/ # Custom Starknet hooks
โ”‚ โ”‚ โ”œโ”€โ”€ configs/ # App configuration
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ connectors.ts # Wallet connectors
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ provider.ts # RPC provider setup
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ aegisConfig.ts # Account abstraction config
โ”‚ โ”‚ โ”œโ”€โ”€ contracts/ # Auto-generated contract types
โ”‚ โ”‚ โ”œโ”€โ”€ constants/ # Chain definitions
โ”‚ โ”‚ โ”œโ”€โ”€ scaffold.config.ts # Target networks, polling config
โ”‚ โ”‚ โ””โ”€โ”€ package.json
โ”‚ โ””โ”€โ”€ snfoundry/ # Smart contracts (optional)
โ”‚ โ”œโ”€โ”€ contracts/src/ # Cairo smart contracts
โ”‚ โ”œโ”€โ”€ scripts-ts/ # Deployment scripts
โ”‚ โ””โ”€โ”€ Scarb.toml # Cairo package config
โ””โ”€โ”€ package.json # Monorepo workspace

Connecting to Networksโ€‹

Local Devnet (Default)โ€‹

The app is pre-configured to connect to http://127.0.0.1:5050 (or http://10.0.2.2:5050 on Android emulator). No additional configuration needed.

Sepolia Testnetโ€‹

Update your environment variables in packages/rn/.env:

# Provider URLs (per-network)
EXPO_PUBLIC_DEVNET_PROVIDER_URL=http://127.0.0.1:5050
EXPO_PUBLIC_SEPOLIA_PROVIDER_URL=https://starknet-sepolia.public.blastapi.io/rpc/v0_8
EXPO_PUBLIC_MAINNET_PROVIDER_URL=https://starknet-mainnet.public.blastapi.io/rpc/v0_8

# Account abstraction (Cavos Aegis)
EXPO_PUBLIC_AEGIS_APP_ID=your_aegis_app_id

# Transaction sponsorship (AVNU Paymaster)
EXPO_PUBLIC_AVNU_API_KEY=your_avnu_api_key

All environment variables must be prefixed with EXPO_PUBLIC_ to be accessible in React Native (Expo requirement).

Getting API Keys
  • Cavos Aegis: Sign up at Cavos to get your Wallet-as-a-Service App ID
  • AVNU: Register at AVNU for transaction sponsorship API key

App Configurationโ€‹

The main app configuration is in packages/rn/scaffold.config.ts:

const scaffoldConfig = {
targetNetworks: [chains.devnet], // Networks to support
pollingInterval: 30_000, // Data refresh interval (ms)
onlyLocalBurnerWallet: false, // Restrict burner to devnet only
walletAutoConnect: true, // Auto-reconnect wallet on app load
autoConnectTTL: 60_000, // Auto-connect time-to-live (ms)
};

Available Scriptsโ€‹

Run these from the project root using your chosen package manager (npm, yarn, or pnpm):

CommandDescription
yarn startStart Expo development server
yarn iosStart app on iOS Simulator
yarn androidStart app on Android Emulator
yarn chainStart local Starknet devnet
yarn deployDeploy contracts to active network
yarn deploy:clearDeploy contracts with reset
yarn compileCompile Cairo smart contracts
yarn testRun smart contract tests
yarn verifyVerify contracts on block explorer
yarn formatFormat code with Prettier
yarn lintRun ESLint

Compatible Versionsโ€‹

DependencyVersion
React19.1.0
React Native0.81.4
Expo54.x
starknet.js8.5.3
@starknet-react/core5.0.1
@cavos/aegis0.1.5
nativewind4.1.23
zustand5.0.8
@tanstack/react-query5.87.1
Scarb2.16.0
Starknet Foundry0.57.0
Starknet Devnet0.7.2

Troubleshootingโ€‹

iOS Simulator Issuesโ€‹

Problem: Simulator not launching

# Reset Expo cache
npx expo start --clear

# Or rebuild the app
npx expo run:ios

Android Emulator Issuesโ€‹

Problem: App not connecting to devnet

The Android emulator uses 10.0.2.2 to reach the host machine's localhost. Ensure your network configuration handles this correctly.

Metro Bundler Issuesโ€‹

Problem: Module resolution errors

# Clear Metro cache
yarn start --reset-cache

# Or clean and reinstall
rm -rf node_modules
yarn install

Starknet Devnet Issuesโ€‹

Problem: Devnet not starting

Ensure you have the correct version installed:

starknet-devnet --version
# Should be 0.7.2

If not, reinstall via asdf:

asdf install starknet-devnet 0.7.2
asdf set starknet-devnet 0.7.2

Next Stepsโ€‹