This is a simple React example that demonstrates how to use the GelatoSmartWalletDynamicContextProvider
component from the Gelato SmartWallet SDK and initialize the SmartWallet client with the wallet client.
- Install dependencies:
yarn install
- Create a
.env
file based on the.env.example
file:
cp .env.example .env
- Edit the
.env
file and replace the placeholders with your actual values:
VITE_DYNAMIC_ENVIRONMENT_ID=your_dynamic_environment_id_here
VITE_SPONSOR_API_KEY=your_sponsor_api_key_here
- Start the development server:
yarn dev
- Open your browser and navigate to
http://localhost:5173
- Connects to Dynamic WaaS provider
- Displays wallet information
- Allows getting the wallet address
- Initializes SmartWallet client with the wallet client
- Executes transactions using SmartWallet client
- Provides logout functionality
The example uses the GelatoSmartWalletDynamicContextProvider
to wrap the application and provide wallet functionality. The WalletInfo
component demonstrates how to:
- Access the wallet client from the context
- Initialize the SmartWallet client with the wallet client
- Execute transactions using the SmartWallet client
- Handle user interactions
VITE_DYNAMIC_ENVIRONMENT_ID
: Your Dynamic environment ID (required)VITE_SPONSOR_API_KEY
: Your Gelato sponsor API key (required)
If you see an error message saying "Dynamic environment ID is not set" or "Sponsor API key is not set", make sure you have created a .env
file with the correct environment variables.