{"id":26266142,"url":"https://github.com/bitriel/wallet-sdk-expo-example","last_synced_at":"2025-08-01T08:07:14.377Z","repository":{"id":281228212,"uuid":"944618864","full_name":"bitriel/wallet-sdk-expo-example","owner":"bitriel","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-07T17:18:05.000Z","size":237,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-07T18:25:59.036Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitriel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-07T17:04:46.000Z","updated_at":"2025-03-07T17:18:08.000Z","dependencies_parsed_at":"2025-03-07T18:37:10.255Z","dependency_job_id":null,"html_url":"https://github.com/bitriel/wallet-sdk-expo-example","commit_stats":null,"previous_names":["bitriel/wallet-sdk-expo-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitriel%2Fwallet-sdk-expo-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitriel%2Fwallet-sdk-expo-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitriel%2Fwallet-sdk-expo-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitriel%2Fwallet-sdk-expo-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitriel","download_url":"https://codeload.github.com/bitriel/wallet-sdk-expo-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515532,"owners_count":20303258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-14T03:17:00.624Z","updated_at":"2025-03-14T03:17:01.229Z","avatar_url":"https://github.com/bitriel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bitriel Wallet SDK Integration Guide\n\nThis guide demonstrates how to integrate the Bitriel Wallet SDK into an Expo React Native project using the actual implementation from the codebase.\n\n## Prerequisites\n\n- Node.js (v14 or higher)\n- Expo CLI\n- iOS Simulator (for iOS development)\n- Android Studio (for Android development)\n\n## Installation\n\n1. Create a new Expo project:\n\n```bash\nnpx create-expo-app my-bitriel-app\ncd my-bitriel-app\n```\n\n2. Install the required dependencies:\n\n```bash\npnpm add bitriel-wallet-sdk @expo/react-native-action-sheet @gorhom/bottom-sheet expo-secure-store expo-dev-client react-native-gesture-handler zustand nativewind tailwindcss\n```\n\n## Project Structure\n\n```\napp/\n├── (tabs)/\n│   ├── _layout.tsx\n│   └── index.tsx\n├── _layout.tsx\n└── global.css\ncomponents/\n├── NetworkSelector.tsx\n├── TransactionForm.tsx\n└── WalletInfo.tsx\nstore/\n└── useWalletStore.ts\n```\n\n## Implementation\n\n1. Create the wallet store (`store/useWalletStore.ts`):\n\n```typescript\nimport { BitrielWalletSDK, NetworkConfig, WalletState } from 'bitriel-wallet-sdk';\nimport * as SecureStore from 'expo-secure-store';\nimport { create } from 'zustand';\n\ninterface WalletStateStore {\n  sdk: BitrielWalletSDK | null;\n  walletState: WalletState | null;\n  currentNetwork: NetworkConfig | null;\n  isLoading: boolean;\n  error: string | null;\n\n  // Actions\n  initializeWallet: () =\u003e Promise\u003cvoid\u003e;\n  connectToNetwork: (chainId: string) =\u003e Promise\u003cvoid\u003e;\n  refreshWalletState: () =\u003e Promise\u003cvoid\u003e;\n  setError: (error: string | null) =\u003e void;\n  disconnect: () =\u003e Promise\u003cvoid\u003e;\n}\n\nexport const useWalletStore = create\u003cWalletStateStore\u003e((set, get) =\u003e ({\n  sdk: null,\n  walletState: null,\n  currentNetwork: null,\n  isLoading: false,\n  error: null,\n\n  initializeWallet: async () =\u003e {\n    try {\n      set({ isLoading: true, error: null });\n      let mnemonic = await SecureStore.getItemAsync('wallet_mnemonic');\n\n      if (!mnemonic) {\n        mnemonic = BitrielWalletSDK.createMnemonic();\n        await SecureStore.setItemAsync('wallet_mnemonic', mnemonic);\n      }\n\n      const walletSdk = new BitrielWalletSDK(mnemonic);\n      set({ sdk: walletSdk });\n\n      const lastNetwork = await SecureStore.getItemAsync('last_network');\n      if (lastNetwork) {\n        await get().connectToNetwork(lastNetwork);\n      }\n    } catch (error: any) {\n      set({ error: error.message });\n      console.error('Failed to initialize wallet:', error);\n    } finally {\n      set({ isLoading: false });\n    }\n  },\n\n  connectToNetwork: async (chainId: string) =\u003e {\n    const { sdk } = get();\n    if (!sdk) {\n      set({ error: 'Wallet not initialized' });\n      return;\n    }\n\n    try {\n      set({ isLoading: true, error: null });\n      await sdk.connect(chainId);\n      const state = await sdk.getWalletState();\n\n      set({\n        walletState: state,\n        currentNetwork: state.network,\n      });\n\n      await SecureStore.setItemAsync('last_network', chainId);\n    } catch (error: any) {\n      set({ error: error.message });\n      console.error('Failed to connect to network:', error);\n    } finally {\n      set({ isLoading: false });\n    }\n  },\n\n  refreshWalletState: async () =\u003e {\n    const { sdk, currentNetwork } = get();\n    if (!sdk || !currentNetwork) return;\n\n    try {\n      set({ isLoading: true, error: null });\n      const state = await sdk.getWalletState();\n      set({ walletState: state });\n    } catch (error: any) {\n      set({ error: error.message });\n      console.error('Failed to refresh wallet state:', error);\n    } finally {\n      set({ isLoading: false });\n    }\n  },\n\n  setError: (error: string | null) =\u003e set({ error }),\n  disconnect: async () =\u003e {\n    const { sdk } = get();\n    if (sdk) {\n      try {\n        set({ isLoading: true, error: null });\n        await sdk.disconnect();\n        set({\n          walletState: null,\n          currentNetwork: null,\n        });\n      } catch (error: any) {\n        set({ error: error.message });\n      } finally {\n        set({ isLoading: false });\n      }\n    }\n  },\n}));\n```\n\n2. Create the main app layout (`app/_layout.tsx`):\n\n```typescript\nimport '../global.css';\nimport 'expo-dev-client';\nimport { ActionSheetProvider } from '@expo/react-native-action-sheet';\nimport { BottomSheetModalProvider } from '@gorhom/bottom-sheet';\nimport { ThemeProvider as NavThemeProvider } from '@react-navigation/native';\nimport { Stack } from 'expo-router';\nimport { StatusBar } from 'expo-status-bar';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\nimport { useColorScheme, useInitialAndroidBarSync } from '~/lib/useColorScheme';\nimport { NAV_THEME } from '~/theme';\n\nexport default function RootLayout() {\n  useInitialAndroidBarSync();\n  const { colorScheme, isDarkColorScheme } = useColorScheme();\n\n  return (\n    \u003c\u003e\n      \u003cStatusBar\n        key={`root-status-bar-${isDarkColorScheme ? 'light' : 'dark'}`}\n        style={isDarkColorScheme ? 'light' : 'dark'}\n      /\u003e\n      \u003cGestureHandlerRootView style={{ flex: 1 }}\u003e\n        \u003cBottomSheetModalProvider\u003e\n          \u003cActionSheetProvider\u003e\n            \u003cNavThemeProvider value={NAV_THEME[colorScheme]}\u003e\n              \u003cStack\u003e\n                \u003cStack.Screen\n                  name=\"index\"\n                  options={{\n                    title: 'Bitriel Wallet',\n                    headerLargeTitle: true,\n                  }}\n                /\u003e\n              \u003c/Stack\u003e\n            \u003c/NavThemeProvider\u003e\n          \u003c/ActionSheetProvider\u003e\n        \u003c/BottomSheetModalProvider\u003e\n      \u003c/GestureHandlerRootView\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n3. Create the main wallet screen (`app/(tabs)/index.tsx`):\n\n```typescript\nimport { useEffect } from 'react';\nimport { View, ScrollView, RefreshControl } from 'react-native';\n\nimport { NetworkSelector } from '~/components/NetworkSelector';\nimport { TransactionForm } from '~/components/TransactionForm';\nimport { WalletInfo } from '~/components/WalletInfo';\nimport { useWalletStore } from '~/store/useWalletStore';\n\nexport default function Home() {\n  const { initializeWallet, refreshWalletState, isLoading } = useWalletStore();\n\n  useEffect(() =\u003e {\n    initializeWallet();\n  }, []);\n\n  return (\n    \u003cScrollView\n      className=\"flex-1 bg-gray-100\"\n      refreshControl={\u003cRefreshControl refreshing={isLoading} onRefresh={refreshWalletState} /\u003e}\u003e\n      \u003cView className=\"p-4\"\u003e\n        \u003cNetworkSelector /\u003e\n        \u003cWalletInfo /\u003e\n        \u003cTransactionForm /\u003e\n      \u003c/View\u003e\n    \u003c/ScrollView\u003e\n  );\n}\n```\n\n## Features Available\n\nThe implementation provides:\n\n- Wallet initialization with mnemonic generation\n- Network selection and connection\n- Wallet state management\n- Transaction handling\n- Secure storage for sensitive data\n- Pull-to-refresh functionality\n- Error handling\n- Loading states\n\n## Security Considerations\n\n1. Mnemonics are stored securely using `expo-secure-store`\n2. Network credentials are persisted securely\n3. Error messages are sanitized\n4. Loading states prevent multiple operations\n5. Proper error handling throughout the application\n\n## Error Handling\n\nThe implementation includes comprehensive error handling:\n\n```typescript\ntry {\n  // Operation\n} catch (error: any) {\n  set({ error: error.message });\n  console.error('Operation failed:', error);\n} finally {\n  set({ isLoading: false });\n}\n```\n\n## Support\n\nFor additional support or questions, please refer to the official Bitriel Wallet SDK documentation or contact the development team.\n\n## License\n\nThis integration guide is provided under the MIT License. The Bitriel Wallet SDK is subject to its own license terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitriel%2Fwallet-sdk-expo-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitriel%2Fwallet-sdk-expo-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitriel%2Fwallet-sdk-expo-example/lists"}