crypblizz8 / demo-consumer-wallet

A minimal consumer wallet app powered by Turnkey

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Turnkey Demo: Consumer Wallet

Introduction

This repository features a minimal consumer wallet app powered by Turnkey. Behind the scenes, it uses @turnkey/ethers for signing and WalletConnect (v1) for accessing dapps.

With Turnkey, you can easily build wallet apps leveraging the existing ecosystem; TurnkeySigner is a drop-in replacement for ethers.Wallet, but with fine-grained transaction controls via Turnkey policies, all without compromising on security.

with-uniswap.mp4

Getting started

Make sure you have Node.js installed locally; we recommend using Node v16+.

$ node --version # v16+
$ git clone https://github.com/tkhq/demo-consumer-wallet
$ cd demo-consumer-wallet/
$ corepack enable # Updates npm for the local project

$ npm install
$ npm start # Follow the instructions on screen to build to your device or a simulator

To configure the demo passkey wallet you'll need the following:

  • A Turnkey organization ID: you can create one by following our quickstart guide.
  • A new Turnkey API key (public/private key pair). You can generate one using our CLI, or through the Turnkey dashboard dashboard
  • Turnkey's base URL: you can leave the default of https://api.turnkey.com.
  • A new Turnkey private key ID: head to "Private Keys" in your Turnkey dashboard and create a new one ("Create private key"). The "Curve type" should be "SECP256K1", and the "Asset address type" should be "ETHEREUM".
  • An account on Infura and Etherscan

You'll provide this information on first app start in the settings screen:

Wallet settings

Upon clicking "Save" the settings are saved in your phone's keychain and you should see your wallet address and ETH balance:

Wallet home

Technical tl;dr

Turnkey API keys and other credentials are encrypted and stored in your phone's Keychain: https://github.com/tkhq/demo-consumer-wallet/blob/14f7e5535c453ab9990373e0dff61165329be15b/src/turnkey/CredentialsContext.tsx#L111

Create a TurnkeySigner, bring your own provider, then bridge it via EIP-1193: https://github.com/tkhq/demo-consumer-wallet/blob/14f7e5535c453ab9990373e0dff61165329be15b/src/turnkey/TurnkeyWalletContext.tsx#L73-L85

WalletConnect payloads are signed by Turnkey and broadcasted by your provider, all via the bridge: https://github.com/tkhq/demo-consumer-wallet/blob/14f7e5535c453ab9990373e0dff61165329be15b/src/screens/WalletConnectScreen.tsx#L222-L225

About

A minimal consumer wallet app powered by Turnkey

License:Apache License 2.0


Languages

Language:TypeScript 96.7%Language:JavaScript 3.3%