This example showcases how to get started using Privy's Flutter SDK inside a Flutter application.
mkdir -p privy-flutter-starter && curl -L https://github.com/privy-io/privy-examples/archive/main.tar.gz | tar -xz --strip=2 -C privy-flutter-starter examples-main/privy-flutter-starter && cd privy-flutter-starterflutter pub getCreate a .env file in the root directory and configure your Privy app credentials:
touch .envUpdate .env with your Privy app credentials:
PRIVY_APP_ID=your_app_id_here
PRIVY_CLIENT_ID=your_client_id_hereImportant: Get your credentials from the Privy Dashboard.
flutter runThis will launch the app on your connected device or emulator.
Login or sign up using Privy's authentication flow for Flutter.
import 'package:privy_flutter/privy_flutter.dart';
final privy = PrivyManager().privy;
// Authentication handled through Privy's Flutter screensProgrammatically create embedded wallets for Ethereum and Solana.
lib/features/authenticated/widgets/ethereum_wallets_widget.dart
import 'package:privy_flutter/privy_flutter.dart';
// Create Ethereum wallet
await privy.createEthereumWallet();
// Create Solana wallet
await privy.createSolanaWallet();Send transactions on Ethereum using Flutter SDK's RPC methods.
lib/features/wallet/eth_wallet_screen.dart
import 'package:privy_flutter/privy_flutter.dart';
final request = EthereumRpcRequest.ethSendTransaction(
jsonEncode({
"from": wallet.address,
"to": toAddress,
"value": weiHex,
"chainId": "0xAA36A7",
}),
);
final result = await wallet.provider.request(request);