Skip to content

Commit

Permalink
Merge pull-request #395
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarshanbhag committed Oct 18, 2024
2 parents e72e74b + c23d248 commit 4ebd50e
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/email-auth-local-storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The overall flow for email auth is outlined below:

This example contains an auth page as well and enables you to create wallets using an email auth credential. Unlike our other [email auth example](https://github.com/tkhq/sdk/tree/main/examples/email-auth), this does not use an iframe, which typically houses a target embedded key. Instead, a target embedded key is created within the application itself and stored in local storage.

You can try this example quickly on Stackblitz. Follow the instructions below --> [Stackblitz Instructions](#4-stackblitz-example)

## Getting started

### 1/ Cloning the example
Expand Down Expand Up @@ -65,3 +67,28 @@ $ pnpm run dev
```

This command will run a NextJS app on port 3000. If you navigate to http://localhost:3000 in your browser, you can follow the prompts to start an email auth.

### 4/ Stackblitz Example

Example Link: https://stackblitz.com/edit/stackblitz-starters-pyyw59

#### Prerequisites

To use the example you need the following

- Turnkey Organization
- API key for the root user (both public and private key needed)
- Turnkey Suborg with an email user

#### Set Env Variables

Set the following environment variables in the `.env.local` file

- `API_PUBLIC_KEY` --> Set this to be the public key of the API key for the root user for the org you've created
- `API_PRIVATE_KEY` --> Set this to be the private key of the API key for the root user for the org you've created
- `NEXT_PUBLIC_ORGANIZATION_ID` --> Set this to be the Org ID of the org you've created
- `NEXT_PUBLIC_BASE_URL` --> This will be preset with https://api.turnkey.com

#### Directions to use

- run `npm install && npm run dev`
31 changes: 31 additions & 0 deletions examples/with-eth-passkeys-galore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The flow showcases 3 ways to make requests to Turnkey:

If you want to see a Viem or Ethers demo with API keys instead of passkeys, see these examples: [`with-viem`](https://github.com/tkhq/sdk/tree/main/examples/with-viem), [`with-ethers`](https://github.com/tkhq/sdk/tree/main/examples/with-ethers). See our [SDK repo](https://github.com/tkhq/sdk) for additional packages and examples.

You can try this example quickly on Stackblitz. Follow the instructions below --> [Stackblitz Instructions](#4-stackblitz-example)

## Getting started

### 1/ Clone or fork this repo
Expand Down Expand Up @@ -55,6 +57,35 @@ $ pnpm run dev

This command will start a NextJS app on localhost. If you navigate to http://localhost:3000 in your browser, you can follow the prompts to create a sub organization, create a private key for the newly created sub-organization, and sign a message using your passkey with a Viem custom account, or Ethers signer!

### 4/ Stackblitz Example

Example Link: https://stackblitz.com/edit/stackblitz-starters-2psu3g

#### Prerequisites

To use the example you need the following

- Turnkey Organization
- API key for the root user (both public and private key needed)

#### Set Env Variables

Set the following environment variables in the `.env.local` file

- `API_PUBLIC_KEY` --> Set this to be the public key of the API key for the root user for the org you've created
- `API_PRIVATE_KEY` --> Set this to be the private key of the API key for the root user for the org you've created
- `NEXT_PUBLIC_ORGANIZATION_ID` --> Set this to be the Org ID of the org you've created
- `NEXT_PUBLIC_BASE_URL` --> This will be preset with https://api.turnkey.com
- `NEXT_PUBLIC_RPID` --> this should be pre-filled with the value `local-credentialless.webcontainer.io` which is the RPID required in the Stackblitz environment
- `NEXT_PUBLIC_SERVER_SIGN_URL` → fill this out with the url in the browser of Stackblitz followed by “/api” --> for example: https://stackblitzstartersh5pmnu-0bej--3000--134daa3c.local-credentialless.webcontainer.io/api. This needs to be replaced as in the note below

NOTE: when you update `.env.local` file (or any file) in Stackblitz, the project will get forked and a new Stackblitz environment will get created. This means that you'll have to `NEXT_PUBLIC_SERVER_SIGN_URL` will have to be updated to be the Stackblitz environment broswer URL + the suffix "/api"

#### Directions to use

- run `npm install && npm run dev`
- follow the example's flow

# Legal Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL TURNKEY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 changes: 34 additions & 0 deletions examples/with-solana-passkeys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The flow showcases 3 ways to make requests to Turnkey:

If you want to see a Solana demo with API keys instead of passkeys, head to the example [`with-solana`](https://github.com/tkhq/sdk/tree/main/examples/with-solana).

You can try this example quickly on Stackblitz. Follow the instructions below --> [Stackblitz Instructions](#4-stackblitz-example)

## Getting started

### 1/ Clone or fork this repo
Expand Down Expand Up @@ -61,6 +63,38 @@ $ pnpm run dev

This command will start a NextJS app on localhost. If you navigate to http://localhost:3000 in your browser, you can follow the prompts to create a sub organization, create a private key for the newly created sub-organization, and sign a message using your passkey with a Solana custom account!

### 4/ Stackblitz Example

Example Link: https://stackblitz.com/edit/stackblitz-starters-h5pmnu

#### Prerequisites

To use the example you need the following

- Turnkey Organization
- API key for the root user (both public and private key needed)
- Solana wallet for Parent org (created within turnkey UI)
- Airdrop devnet SOL to parent org wallet using devnet faucet → https://faucet.solana.com/

#### Set Env Variables

Set the following environment variables in .env.local

- `API_PUBLIC_KEY` → Public key of your API associated with root user
- `API_PRIVATE_KEY` → Private key of your API associated with root user
- `NEXT_PUBLIC_ORGANIZTION_ID` → org ID of the Turnkey organization that you’re using
- `NEXT_PUBLIC_BASE_URL` --> This will be preset with https://api.turnkey.com
- `NEXT_PUBLIC_RPID` --> this should be pre-filled with the value `local-credentialless.webcontainer.io` which is the RPID required in the Stackblitz environment
- `NEXT_PUBLIC_SERVER_SIGN_URL` → fill this out with the url in the browser of Stackblitz followed by “/api” --> for example: https://stackblitzstarters2psu3g-5wkd--3000--134daa3c.local-credentialless.webcontainer.io/api. This needs to be replaced as in the note below
- `NEXT_PUBLIC_FEE_PAYER_ADDRESS` --> the address of the Solana address with airdropped funds

NOTE: when you update `.env.local` file (or any file) in Stackblitz, the project will get forked and a new Stackblitz environment will get created. This means that you'll have to `NEXT_PUBLIC_SERVER_SIGN_URL` will have to be updated to be the Stackblitz environment broswer URL + the suffix "/api"

#### Directions to use

- run `npm install && npm run build && npm run dev"
- follow example flow

# Legal Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL TURNKEY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 30 additions & 0 deletions examples/with-solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This example walks through the following:
- Construction of a transaction sending the funds out with the `@turnkey/solana` signer
- Creating, minting, and transferring a SPL token using Turnkey

You can try this example quickly on Stackblitz. Follow the instructions below --> [Stackblitz Instructions](#6-stackblitz-example)

## Getting started

### 1/ Cloning the example
Expand Down Expand Up @@ -163,3 +165,31 @@ Token balance for warchest: 0.0001
```

Enjoy!

### 6/ Stackblitz Example

Example Link: https://stackblitz.com/edit/stackblitz-starters-xeb93i

#### Prerequisites

To use the example you need the following

- Turnkey Organization
- API key for the root user (both public and private key needed)

#### Set Env Variables

Set the following environment variables in the `.env.local` file

- `API_PUBLIC_KEY` --> Set this to be the public key of the API key for the root user for the org you've created
- `API_PRIVATE_KEY` --> Set this to be the private key of the API key for the root user for the org you've created
- `ORGANIZATION_ID` --> Set this to be the Org ID of the org you've created

#### Optional Env Variables

- `SOLANA_ADDRESS` --> This is optional, If you want to use an existing Solana address in your organization, put it here!
- `SOLANA_ADDRESS_FEE_PAYER` --> This is optional, a separate fee payer address. To be used in `withFeePayer.ts`

#### Directions to use

- run `npm install && npm start`

0 comments on commit 4ebd50e

Please sign in to comment.