-
Notifications
You must be signed in to change notification settings - Fork 27
feat: Add a Vite + React example with injected provider #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tiero
wants to merge
7
commits into
master
Choose a base branch
from
phantom-example
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f1f8a71
feat: Add a Vite + React example for Phantom wallet integration
google-labs-jules[bot] f89012a
fix phantom example (#137)
tiero c6d1ba7
feat: Implement Xverse wallet integration with ARK transactions
tiero 8fd0bf4
format
tiero 686dbba
feat: Update README for ARK SDK Xverse wallet integration example and…
tiero 2fe37f0
refactor: Remove Phantom example files and configuration
tiero 3e59fab
feat: add Bitcoin signing Snap with Taproot support
tiero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # ARK MetaMask Snap Demo | ||
|
|
||
| A React application demonstrating ARK wallet integration using MetaMask Snap for Bitcoin Taproot operations. | ||
|
|
||
| ## Overview | ||
|
|
||
| This demo showcases: | ||
|
|
||
| - MetaMask Snap integration for Bitcoin signing | ||
| - Taproot address generation and management | ||
| - ARK protocol transactions (send, settle, balance management) | ||
| - Secure signing without exposing private keys | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - MetaMask browser extension | ||
| - Node.js 18+ | ||
| - pnpm package manager | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### 1. Install Dependencies | ||
|
|
||
| ```bash | ||
| # Install snap dependencies | ||
| cd ../../snap | ||
| pnpm install | ||
|
|
||
| # Install app dependencies | ||
| cd ../examples/metamask-react-app | ||
| pnpm install | ||
| ``` | ||
|
|
||
| ### 2. Build and Start the Snap | ||
|
|
||
| ```bash | ||
| cd ../../snap | ||
| pnpm build | ||
| pnpm serve | ||
| ``` | ||
|
|
||
| The snap development server will start on `http://localhost:8080`. | ||
|
|
||
| ### 3. Start the React App | ||
|
|
||
| ```bash | ||
| cd ../examples/metamask-react-app | ||
| pnpm dev | ||
| ``` | ||
|
|
||
| The app will be available at `http://localhost:5173`. | ||
|
|
||
| ### 4. Connect and Use | ||
|
|
||
| 1. Open the app in your browser | ||
| 2. Click "Connect MetaMask Snap" | ||
| 3. Approve the snap installation in MetaMask | ||
| 4. Your Taproot and ARK addresses will be displayed | ||
| 5. Use the app to check balances and send transactions | ||
|
|
||
| ## Features | ||
|
|
||
| - **Secure Key Management**: Private keys remain in MetaMask Snap | ||
| - **Taproot Addresses**: Native Taproot address generation | ||
| - **ARK Integration**: Full ARK protocol support (send, settle, balance) | ||
| - **User Confirmation**: All transactions require MetaMask approval | ||
| - **Signet Network**: Uses Bitcoin Signet for safe testing | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### MetaMask Snap (`/snap/`) | ||
|
|
||
| - Deterministic key derivation from MetaMask entropy | ||
| - PSBT signing for Taproot transactions | ||
| - RPC interface for dApp communication | ||
|
|
||
| ### React App | ||
|
|
||
| - MetaMaskSnapIdentity: Drop-in replacement for other wallet identities | ||
| - ArkWallet: Simplified wallet management interface | ||
| - Real-time balance and transaction updates | ||
|
|
||
| ## Development | ||
|
|
||
| The snap runs locally during development. For production: | ||
|
|
||
| 1. Publish snap to npm | ||
| 2. Update snap manifest with production details | ||
| 3. Use production snap ID in the React app | ||
|
|
||
| ## Network Configuration | ||
|
|
||
| - **Bitcoin Network**: Signet (testnet) | ||
| - **ARK Server**: `https://signet.arkade.sh` | ||
| - **Block Explorer**: `https://mempool.space/signet/` | ||
|
|
||
| Get testnet Bitcoin from [Signet faucets](https://signet.bc-2.jp/) for testing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| export default { | ||
| root: true, | ||
| env: { browser: true, es2020: true }, | ||
| extends: [ | ||
| "eslint:recommended", | ||
| "plugin:react/recommended", | ||
| "plugin:react/jsx-runtime", | ||
| "plugin:react-hooks/recommended", | ||
| ], | ||
| ignorePatterns: ["dist", ".eslintrc.cjs"], | ||
| parserOptions: { ecmaVersion: "latest", sourceType: "module" }, | ||
| settings: { react: { version: "18.2" } }, | ||
| plugins: ["react-refresh"], | ||
| rules: { | ||
| "react-refresh/only-export-components": [ | ||
| "warn", | ||
| { allowConstantExport: true }, | ||
| ], | ||
| "react/prop-types": "off", | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>ARK MetaMask Snap - React</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.jsx"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "name": "arkade-metamask-react-app", | ||
| "private": true, | ||
| "version": "0.1.0", | ||
| "description": "ARK MetaMask Snap demo application", | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "vite", | ||
| "build": "vite build", | ||
| "preview": "vite preview" | ||
| }, | ||
| "packageManager": "pnpm@10.15.0", | ||
| "dependencies": { | ||
| "@arkade-os/sdk": "link:../..", | ||
| "@scure/base": "^1.1.3", | ||
| "@scure/btc-signer": "^1.3.1", | ||
| "@noble/curves": "^1.2.0", | ||
| "react": "^18.2.0", | ||
| "react-dom": "^18.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@vitejs/plugin-react": "^4.2.1", | ||
| "vite": "^5.2.0" | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
❓ Verification inconclusive
Fix Prettier CI failure.
Run repository formatting; if you want, add a local script for this example.
🏁 Script executed:
Length of output: 189
Fix Prettier commands for example CI
-wflag and run formatting locally inexamples/metamask-react-app:examples/metamask-react-app/package.json:🧰 Tools
🪛 GitHub Actions: CI
[error] 1-1: Prettier formatting issue detected. Run 'prettier --write' to fix code style.
🛠️ Refactor suggestion
Declare Node engine to match Vite 5 (Node ≥18).
Prevent “unsupported engine” CI/dev surprises by pinning a minimum Node.
📝 Committable suggestion
🧰 Tools
🪛 GitHub Actions: CI
[error] 1-1: Prettier formatting issue detected. Run 'prettier --write' to fix code style.
🤖 Prompt for AI Agents