Skip to main content

Paper Wallet

Prompt users to connect to your app using their email with Paper Wallet

Usage

import { PaperWallet } from "@thirdweb-dev/wallets";
import { Ethereum } from "@thirdweb-dev/chains";

const wallet = new PaperWallet({
chain: Ethereum, // chain to connect to
clientId: "client_id", // Paper SDK client ID
});

wallet.connect();

Configuration

Provide a configuration object when instantiating the PaperWallet class.

chain (required)

The chain to connect to by default.

Must be a Chain object, from the @thirdweb-dev/chains package.

chains (optional)

Provide an array of chains you want to support.

Must be an array of Chain objects, from the @thirdweb-dev/chains package.

clientId (required)

Paper SDK requires a clientId for instantiation. You can create a clientId for your app on paper.xyz

Must be a string.

walletStorage (optional)

The wallet needs to store data in persistent storage. By default localStorage is used. If you want to use a different storage, you can pass it in the walletStorage option.

Must be an object conforming to the AsyncStorage interface:

export interface AsyncStorage {
getItem(key: string): Promise<string | null>;
setItem(key: string, value: string): Promise<void>;
removeItem(key: string): Promise<void>;
}

Example:

import { PaperWallet } from "@thirdweb-dev/wallets";

const wallet = new PaperWallet({
// ... other required config

walletStorage: {
getItem: (key) => {
// Implement your own storage logic here
},
removeItem: (key) => {
// Implement your own storage logic here
},
setItem: (key, value) => {
// Implement your own storage logic here
},
},
});

Methods

Inherits all the public methods from the AbstractClientWallet class.

connect

open the Paper Wallet's Modal and prompt the user to log in with their email address. Once connected, it returns the public wallet address assigned to the user.

await wallet.connect();
Configuration
connect(options?: {
email?: string,
chainId?: 5 |
10 |
1 |
56 |
97 |
137 |
250 |
420 |
4002 |
42161 |
43114 |
80001 |
421613
}): Promise<string>;
email (optional)

If email is not provided, the user will be prompted to enter their email address or sign in with a Google account. Once the user enters the email address or signs in with a Google account, an OTP will be sent to the user's email address. Once the user enters the OTP, the wallet will be connected.

If the email is provided, the user will be directly shown the OTP screen, the user will not be prompted to enter their email.

chainId (optional)

If chainId is provided, the wallet will be connected to the network with the given chainId, else it will be connected to the Ethereum Mainnet.

Paper Wallet only supports the below shown chains at the moment:

  • Ethereum (1)
  • Goerli (5)
  • Polygon (137)
  • Avalanche(43114)
  • Fantom (250)
  • Fantom Testnet (4002)
  • Mumbai Testnet (80001)
  • Avalanche (43114)
  • Optimism (10)
  • Optimism Testnet (420)
  • Binance Smart Chain (56)
  • Binance Smart Chain Testnet (97)
  • Arbitrum One (42161)
  • Arbitrum Goerli Testnet (421611)

Return Value

Returns a string containing the user's assigned public wallet address.

getEmail

Get the email associated with the currently connected wallet.

const email = await wallet.getEmail();
Configuration

Return Value

Returns a string containing the email.

string;