Skip to content

tkhq/demo-consumer-wallet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d823702 · Sep 24, 2023

History

35 Commits
Apr 27, 2023
Sep 24, 2023
Sep 24, 2023
May 4, 2023
Apr 28, 2023
Apr 27, 2023
Apr 28, 2023
Apr 28, 2023
Sep 24, 2023
May 4, 2023
Apr 27, 2023
Apr 28, 2023
Sep 24, 2023
Sep 24, 2023
Apr 27, 2023

Repository files navigation

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:

await SecureStore.setItemAsync(key, value);

Create a TurnkeySigner, bring your own provider, then bridge it via EIP-1193:

const signer = new TurnkeySigner({
client: client,
organizationId: TURNKEY_ORGANIZATION_ID,
privateKeyId: TURNKEY_PRIVATE_KEY_ID,
});
const provider = new ethers.providers.InfuraProvider(
network,
INFURA_API_KEY
);
connectedSigner = signer.connect(provider);
eip1193 = new Eip1193Bridge(connectedSigner, provider);

WalletConnect payloads are signed by Turnkey and broadcasted by your provider, all via the bridge:

txHash = await eip1193.send(
method,
cleanUpSendTxParams(params)
);

About

A minimal consumer wallet app powered by Turnkey

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published