create-sbc-app 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ # create-sbc-app
2
+
3
+ This directory contains ready-to-use templates for quickly starting new projects with the SBC App Kit. Each template is a minimal, fully functional app that demonstrates best practices for integrating @stablecoin.xyz/core and @stablecoin.xyz/react.
4
+
5
+ ## Available Templates
6
+
7
+ - **react/** – Minimal React app with SBC integration (Vite)
8
+
9
+ ## How to Use a Template
10
+
11
+ 1. **Copy the template directory** you want to use:
12
+
13
+ ```bash
14
+ cp -r create-sbc-app/react my-new-sbc-app
15
+ # or for Next.js:
16
+ cp -r create-sbc-app/nextjs my-new-sbc-next-app
17
+ ```
18
+
19
+ 2. **Install dependencies:**
20
+
21
+ ```bash
22
+ cd my-new-sbc-app
23
+ pnpm install
24
+ # or
25
+ npm install
26
+ ```
27
+
28
+ 3. **Run the app:**
29
+
30
+ ```bash
31
+ pnpm dev
32
+ # or
33
+ npm run dev
34
+ ```
35
+
36
+ 4. **Customize as needed:**
37
+ - Update the API key and config in `src/App.tsx` or `app/page.tsx`.
38
+ - Follow the template’s README for more details.
39
+
40
+ ## Keeping Templates Up to Date
41
+
42
+ - All templates use the latest published versions of SBC packages.
43
+ - Code and config are kept in sync with the main repo’s best practices.
44
+ - If you find an issue, please open a PR or issue in the main repo.
45
+
46
+ ---
47
+
48
+ Each template has its own README with specific instructions and details.
@@ -0,0 +1,2 @@
1
+ # SBC App Kit Configuration
2
+ VITE_SBC_API_KEY={{apiKey}}
@@ -0,0 +1,18 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: { browser: true, es2020: true },
4
+ extends: [
5
+ 'eslint:recommended',
6
+ '@typescript-eslint/recommended',
7
+ 'plugin:react-hooks/recommended',
8
+ ],
9
+ ignorePatterns: ['dist', '.eslintrc.cjs'],
10
+ parser: '@typescript-eslint/parser',
11
+ plugins: ['react-refresh'],
12
+ rules: {
13
+ 'react-refresh/only-export-components': [
14
+ 'warn',
15
+ { allowConstantExport: true },
16
+ ],
17
+ },
18
+ }
@@ -0,0 +1,146 @@
1
+ # {{projectName}}
2
+
3
+ A gasless smart account application powered by [SBC (Stable Coin Inc)](https://stablecoin.xyz).
4
+
5
+ ## πŸš€ Quick Start
6
+
7
+ ### 1. Install Dependencies
8
+ ```bash
9
+ npm install
10
+ ```
11
+
12
+ ### 2. Configure Environment Variables
13
+ Copy the example environment file and add your SBC API key:
14
+
15
+ ```bash
16
+ cp .env.example .env # Optional: for local overrides
17
+ ```
18
+
19
+ Edit `.env` and add your SBC API key:
20
+ ```bash
21
+ VITE_SBC_API_KEY=your_api_key_here
22
+ VITE_SBC_CHAIN={{chain}}
23
+ VITE_SBC_DEBUG=true
24
+ ```
25
+
26
+ > **Get your API key:** Visit the [SBC Dashboard](https://dashboard.stablecoin.xyz) to create an account and get your API key.
27
+
28
+ ### 3. Start the Development Server
29
+ ```bash
30
+ npm run dev
31
+ ```
32
+
33
+ Your app will be available at `http://localhost:3000` πŸŽ‰
34
+
35
+ ## πŸ”₯ What You'll See
36
+
37
+ This example app demonstrates:
38
+
39
+ - **πŸ”— Wallet Connection**: Connect any Ethereum wallet
40
+ - **🏦 Smart Account Creation**: Automatically creates a gasless smart account
41
+ - **β›½ Gasless Transactions**: Send transactions without paying gas fees
42
+ - **πŸ’° Balance Checking**: Check your account balance
43
+ - **πŸ”§ Ready-to-Use Setup**: Environment variables and error handling included
44
+
45
+ ## πŸ›  How It Works
46
+
47
+ ### Environment Variables (Vite)
48
+ The app uses Vite's environment variables with the `VITE_` prefix:
49
+
50
+ ```typescript
51
+ const config = {
52
+ apiKey: import.meta.env.VITE_SBC_API_KEY,
53
+ chain: {{chain}},
54
+ debug: import.meta.env.VITE_SBC_DEBUG === 'true'
55
+ };
56
+ ```
57
+
58
+ ### SBC Integration
59
+ ```typescript
60
+ import { SbcProvider, useSbcApp, WalletConnect } from '@stablecoin.xyz/react';
61
+
62
+ // 1. Wrap your app with SbcProvider
63
+ <SbcProvider config={config}>
64
+ <YourApp />
65
+ </SbcProvider>
66
+
67
+ // 2. Use the SBC hooks
68
+ const { sbcAppKit, account, isInitialized } = useSbcApp();
69
+
70
+ // 3. Send gasless transactions
71
+ const tx = await sbcAppKit.sendTransaction({
72
+ to: recipientAddress,
73
+ value: parseEther('0.001'),
74
+ data: '0x'
75
+ });
76
+ ```
77
+
78
+ ## πŸ“š Available Scripts
79
+
80
+ - `npm run dev` - Start development server
81
+ - `npm run build` - Build for production
82
+ - `npm run preview` - Preview production build
83
+ - `npm run lint` - Run ESLint
84
+
85
+ ## πŸ”§ Development
86
+
87
+ ### Project Structure
88
+ ```
89
+ src/
90
+ β”œβ”€β”€ App.tsx # Main app with SBC integration
91
+ β”œβ”€β”€ main.tsx # Vite entry point
92
+ β”œβ”€β”€ App.css # Styles
93
+ └── index.css # Global styles
94
+ ```
95
+
96
+ ### Adding Your Own Features
97
+
98
+ 1. **Custom Transactions**: Modify the `sendGaslessTransaction` function in `App.tsx`
99
+ 2. **Smart Contract Interactions**: Use `sbcAppKit.sendTransaction()` with contract calls
100
+ 3. **Additional UI**: Add new components and import them in `App.tsx`
101
+
102
+ ## 🌐 Chain Configuration
103
+
104
+ This app is configured for **{{chain}}**. To use a different chain:
105
+
106
+ 1. Update `.env`:
107
+ ```bash
108
+ VITE_SBC_CHAIN=your_chain_here
109
+ ```
110
+
111
+ 2. Update the import in `App.tsx`:
112
+ ```typescript
113
+ import { yourChain } from 'viem/chains';
114
+ ```
115
+
116
+ ## πŸ“– Learn More
117
+
118
+ - [SBC Documentation](https://docs.stablecoin.xyz)
119
+ - [SBC React SDK](https://www.npmjs.com/package/@stablecoin.xyz/react)
120
+ - [Viem Documentation](https://viem.sh)
121
+ - [React Documentation](https://react.dev)
122
+
123
+ ## πŸ†˜ Troubleshooting
124
+
125
+ ### "Configuration Required" Error
126
+ - Make sure you've set `VITE_SBC_API_KEY` in your `.env` file
127
+ - Restart the dev server after changing environment variables
128
+
129
+ ### Transaction Failures
130
+ - Check that you're on the correct network ({{chain}})
131
+ - Ensure your wallet has a small amount of ETH for account deployment
132
+ - Check the browser console for detailed error messages
133
+
134
+ ### Build Issues
135
+ - Make sure all dependencies are installed: `npm install`
136
+ - Try clearing the cache: `rm -rf node_modules package-lock.json && npm install`
137
+
138
+ ## πŸ” Security
139
+
140
+ - Never commit your `.env` file with real API keys
141
+ - Use `.env.local` for local development overrides
142
+ - The `.env` file in this template is for demonstration only
143
+
144
+ ---
145
+
146
+ **Happy building with SBC! πŸš€**
@@ -0,0 +1,32 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from '@typescript-eslint/eslint-plugin'
6
+ import tsparser from '@typescript-eslint/parser'
7
+
8
+ export default [
9
+ { ignores: ['dist'] },
10
+ {
11
+ files: ['**/*.{ts,tsx}'],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ parser: tsparser,
16
+ },
17
+ plugins: {
18
+ '@typescript-eslint': tseslint,
19
+ 'react-hooks': reactHooks,
20
+ 'react-refresh': reactRefresh,
21
+ },
22
+ rules: {
23
+ ...js.configs.recommended.rules,
24
+ ...tseslint.configs.recommended.rules,
25
+ ...reactHooks.configs.recommended.rules,
26
+ 'react-refresh/only-export-components': [
27
+ 'warn',
28
+ { allowConstantExport: true },
29
+ ],
30
+ },
31
+ },
32
+ ]
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/png" href="/sbc-logo.png" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="{{projectName}} - SBC-powered application"
11
+ />
12
+ <title>{{projectName}}</title>
13
+ </head>
14
+ <body>
15
+ <div id="root"></div>
16
+ <script type="module" src="/src/main.tsx"></script>
17
+ </body>
18
+ </html>
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "{{projectName}}",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "@stablecoin.xyz/core": "latest",
13
+ "@stablecoin.xyz/react": "latest",
14
+ "react": "^18.2.0",
15
+ "react-dom": "^18.2.0",
16
+ "viem": "^2.31.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^18.2.0",
20
+ "@types/react-dom": "^18.2.0",
21
+ "@vitejs/plugin-react": "^4.0.0",
22
+ "typescript": "^5.0.0",
23
+ "vite": "^5.0.0"
24
+ }
25
+ }