From 0de149453fbfd7db884dfb14f06c15b05ba114b9 Mon Sep 17 00:00:00 2001 From: Brian Friel Date: Tue, 19 Nov 2024 10:24:44 -0800 Subject: [PATCH 1/3] Update SDK readme --- README.md | 29 +++++++------ packages/sdk/README.md | 94 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 101 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index a8990f3..bb8a8fd 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ In addition to powering wallet creation, Phantom Embedded also comes with a buil ## Features -- Create self custodial wallets without leaving application -- Onboard via Sign in with Google and 4-digit pin (no seed phrases) -- Wallets automatically sync with Phantom's mobile and extension apps +- Create self custodial wallets without leaving your application +- Onboard users via Sign in with Google and a 4-digit pin (no seed phrases) +- Sync embedded wallets with Phantom's mobile and extension apps - Sign transactions and message on Solana (more chains coming soon) - View, send, and receive tokens on Solana, Ethereum, Bitcoin, Base, and Polygon - Pricing: **FREE** @@ -23,30 +23,35 @@ yarn | npm | pnpm add @phantom/wallet-sdk 2. Load the Phantom Embedded wallet in your web application -```jsx +```tsx import { createPhantom } from "@phantom/wallet-sdk" +const opts: CreatePhantomConfig = { + zIndex?: 10_000, + hideLauncherBeforeOnboarded?: true, +} + const App = () => { useEffect(() => { - createPhantom(); + createPhantom(opts); }, []); ... } ``` -3. [Integrate Phantom](https://docs.phantom.app/solana/integrating-phantom) as you would normally. Whenever a user interacts with Phantom (e.g. `window.phantom.connect()`), the Phantom Embedded wallet will automatically initialize if the user does not have Phantom already installed. +3. [Integrate Phantom](https://docs.phantom.app/solana/integrating-phantom) as you would normally. Whenever a user interacts with Phantom (e.g. `window.phantom.solana.connect()`), the Phantom Embedded wallet will automatically initialize if the user does not have Phantom already installed. ## Configuration -The following optional parameters can be passed as `createPhantom({options..})` to customize the Phantom Embedded wallet experience. +The following optional parameters can be passed as `createPhantom({options...})` to customize the Phantom Embedded wallet experience. | Parameter | Type | Description | | ----------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- | -| `hideLauncherBeforeOnboarded` | boolean | If `true`, the Phantom Embedded UI will be hidden until the user engages with Phantom. | -| `colorScheme` | string | The background color of the Phantom Embedded iframe. Can be `"light"`, `"dark"`, or `"normal"`. Defaults to `"normal"`. | -| `zIndex` | string | The z-index of the Phantom Embedded UI. Defaults to `"10_000"`. | -| `paddingBottom` | string | The number of pixels between the Phantom Embedded UI and the right edge of the web. Defaults to `"0"`. | -| `paddingRight` | string | The number of pixels between the Phantom Embedded UI and the bottom edge of the web. Defaults to `"0"`. | +| `hideLauncherBeforeOnboarded` | boolean | If `true`, the Phantom Embedded UI will be hidden until the user engages with Phantom. Defaults to `false`. | +| `colorScheme` | string | The background color of the Phantom Embedded iframe, which should be configured to match your site's theme. Can be `"light"`, `"dark"`, or `"normal"`. Defaults to `"normal"`. | +| `zIndex` | number | The z-index of the Phantom Embedded UI. Defaults to `10_000`. | +| `paddingBottom` | number | The number of pixels between the Phantom Embedded UI and the right edge of the web. Defaults to `0`. | +| `paddingRight` | number | The number of pixels between the Phantom Embedded UI and the bottom edge of the web. Defaults to `0`. | ## See It In Action diff --git a/packages/sdk/README.md b/packages/sdk/README.md index 783468f..bb8a8fd 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -1,21 +1,34 @@ -# @phantom/wallet-sdk +# Phantom Embedded Wallet SDK -### Integrating the Embedded Wallet: Getting Started +Phantom Embedded enables you to seamlessly onboard users to your application, without requiring them to have previously installed a wallet. With Phantom Embedded, users can create a self custodial wallet with just their Google account and a 4-digit pin. Once created, this wallet will automatically sync with [Phantom](https://phantom.app)'s mobile and extension apps without the user needing to know their seed phrase or manage any private keys. -1. Install the Phantom SDK (https://github.com/phantom/wallet-sdk) +In addition to powering wallet creation, Phantom Embedded also comes with a built-in UI for users to view and manage their holdings. This UI serves as a trusted interface for users to sign messages and transactions on your app. + +## Features + +- Create self custodial wallets without leaving your application +- Onboard users via Sign in with Google and a 4-digit pin (no seed phrases) +- Sync embedded wallets with Phantom's mobile and extension apps +- Sign transactions and message on Solana (more chains coming soon) +- View, send, and receive tokens on Solana, Ethereum, Bitcoin, Base, and Polygon +- Pricing: **FREE** + +## Quickstart + +1. Install the Phantom Embedded SDK ```bash yarn | npm | pnpm add @phantom/wallet-sdk ``` -1. Load the embedded wallet and the launcher +2. Load the Phantom Embedded wallet in your web application ```tsx import { createPhantom } from "@phantom/wallet-sdk" const opts: CreatePhantomConfig = { - zIndex: 10_000, - hideLauncherBeforeOnboarded: true, + zIndex?: 10_000, + hideLauncherBeforeOnboarded?: true, } const App = () => { @@ -26,8 +39,69 @@ const App = () => { } ``` -### Options +3. [Integrate Phantom](https://docs.phantom.app/solana/integrating-phantom) as you would normally. Whenever a user interacts with Phantom (e.g. `window.phantom.solana.connect()`), the Phantom Embedded wallet will automatically initialize if the user does not have Phantom already installed. + +## Configuration + +The following optional parameters can be passed as `createPhantom({options...})` to customize the Phantom Embedded wallet experience. + +| Parameter | Type | Description | +| ----------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- | +| `hideLauncherBeforeOnboarded` | boolean | If `true`, the Phantom Embedded UI will be hidden until the user engages with Phantom. Defaults to `false`. | +| `colorScheme` | string | The background color of the Phantom Embedded iframe, which should be configured to match your site's theme. Can be `"light"`, `"dark"`, or `"normal"`. Defaults to `"normal"`. | +| `zIndex` | number | The z-index of the Phantom Embedded UI. Defaults to `10_000`. | +| `paddingBottom` | number | The number of pixels between the Phantom Embedded UI and the right edge of the web. Defaults to `0`. | +| `paddingRight` | number | The number of pixels between the Phantom Embedded UI and the bottom edge of the web. Defaults to `0`. | + +## See It In Action + +Try out Phantom Embedded via our demo app: https://sandbox.phantom.dev/sol-embedded-sandbox + +> Note: Phantom Embedded will not initialize if it detects that the user already has the Phantom extension installed, or if the user is accessing the page from within the Phantom mobile app. + +## Give Feedback + +Phantom Embedded is in active development and will be prioritizing features requested by early adopters. If you are interested in working with us, please email us at `developers@phantom.app` or message `@brianfriel` on Telegram. + +## Frequently Asked Questions + +
+ How does the embedded wallet work with the Phantom extension? + + If the Phantom extension is detected, we will not inject the embedded wallet. Phantom users can continue using their extension like normal. + +
+
+ What does `createPhantom()` do? + + The Phantom embedded wallet lives inside an iframe. The `createPhantom` function loads and attaches the iframe to your website. + +
+
+ How do I interact with the embedded wallet? + + Once `createPhantom` has been called, `window.phantom.solana` and a compliant wallet-standard provider will also be available in the global scope of your website. This means that most of your existing code for interacting with Solana wallets should work out of the box. + + Once a user has onboarded to the embedded wallet, they should be able to click your “connect wallet” button, which gives your website access to their Solana address. After that, signing messages and transactions should just work as normal. + +
+
+ I can't see the embedded wallet on my website. What's wrong? + + The most common cause is that you are using a browser with the Phantom extension installed. If the Phantom extension is detected, we will not inject the embedded wallet. + + You can temporarily disable the Phantom extension by going to `chrome://extensions` and toggling Phantom off. + +
+
+ How much does this cost? + + It's free! + +
+ +## Disclaimers + +We are providing early access to beta software for testing purposes only. Embedded wallet should be used in a non-production environment only. Phantom will not be liable for any losses or damages suffered by you or your end users if you push the early access version of embedded wallets to a production environment. -- hideLauncherBeforeOnboarded: Set to true to avoid showing the launcher button until a user has onboarded to the Phantom Wallet. -- zIndex: Pass a custom zIndex to the Phantom Wallet iframe -- colorScheme: If the Phantom Wallet iframe has an opaque background on your site. You should set this color scheme to match the color scheme of your site. +All suggestions, enhancement requests, recommendations or other feedback provided by you relating to the embedded wallet will be the sole and exclusive property of Phantom and by using the early access version of embedded wallets and providing feedback to Phantom you agree to assign any rights in that feedback to Phantom. From 84c99916c4471febba8ba8fdc6de93b944280b4f Mon Sep 17 00:00:00 2001 From: Brian Friel Date: Tue, 19 Nov 2024 10:26:18 -0800 Subject: [PATCH 2/3] remove unneccesary indent --- packages/sdk/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/README.md b/packages/sdk/README.md index bb8a8fd..a91af45 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -33,7 +33,7 @@ const opts: CreatePhantomConfig = { const App = () => { useEffect(() => { - createPhantom(opts); + createPhantom(opts); }, []); ... } From b6881d4faa796b800dfd4e38bdcc96cce6ec00be Mon Sep 17 00:00:00 2001 From: Brian Friel Date: Tue, 19 Nov 2024 10:28:10 -0800 Subject: [PATCH 3/3] align quickstart indents --- README.md | 6 +++--- packages/sdk/README.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bb8a8fd..2347f78 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ yarn | npm | pnpm add @phantom/wallet-sdk import { createPhantom } from "@phantom/wallet-sdk" const opts: CreatePhantomConfig = { - zIndex?: 10_000, - hideLauncherBeforeOnboarded?: true, + zIndex: 10_000, + hideLauncherBeforeOnboarded: true, } const App = () => { useEffect(() => { - createPhantom(opts); + createPhantom(opts); }, []); ... } diff --git a/packages/sdk/README.md b/packages/sdk/README.md index a91af45..2347f78 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -27,8 +27,8 @@ yarn | npm | pnpm add @phantom/wallet-sdk import { createPhantom } from "@phantom/wallet-sdk" const opts: CreatePhantomConfig = { - zIndex?: 10_000, - hideLauncherBeforeOnboarded?: true, + zIndex: 10_000, + hideLauncherBeforeOnboarded: true, } const App = () => {