Joseph  Murray

Joseph Murray

1660159800

Modular TypeScript Wallet Adapters and Components for Solana Apps

@solana/wallet-adapter

Modular TypeScript wallet adapters and components for Solana applications.

Quick Links

  • TypeScript Docs
  • FAQ (Frequently Asked Questions)
    • How can I get support?
    • Can I use this with ___?
    • What does this error mean?
    • How can I sign and verify messages?
  • Quick Setup (using React UI)
    • Install
    • Setup
    • Usage
  • Packages
    • Core
    • Wallets
    • UI Components
    • Starter Projects
    • Community
  • Build from Source

Quick Setup (using React UI)

There are also material-ui and ant-design packages if you use those component frameworks.

Install

Install these dependencies:

yarn add @solana/wallet-adapter-base \
         @solana/wallet-adapter-react \
         @solana/wallet-adapter-react-ui \
         @solana/wallet-adapter-wallets \
         @solana/web3.js \
         @solana-mobile/wallet-adapter-mobile \
         react

Setup

import React, { FC, useMemo } from 'react';
import { ConnectionProvider, WalletProvider } from '@solana/wallet-adapter-react';
import { WalletAdapterNetwork } from '@solana/wallet-adapter-base';
import {
    CoinbaseWalletAdapter,
    GlowWalletAdapter,
    PhantomWalletAdapter,
    SlopeWalletAdapter,
    SolflareWalletAdapter,
    SolletExtensionWalletAdapter,
    SolletWalletAdapter,
    TorusWalletAdapter,
    TokenaryWalletAdapter,
} from '@solana/wallet-adapter-wallets';
import {
    WalletModalProvider,
    WalletDisconnectButton,
    WalletMultiButton
} from '@solana/wallet-adapter-react-ui';
import { clusterApiUrl } from '@solana/web3.js';
import { createDefaultAuthorizationResultCache, SolanaMobileWalletAdapter } from '@solana-mobile/wallet-adapter-mobile';

// Default styles that can be overridden by your app
require('@solana/wallet-adapter-react-ui/styles.css');

export const Wallet: FC = () => {
    // The network can be set to 'devnet', 'testnet', or 'mainnet-beta'.
    const network = WalletAdapterNetwork.Devnet;

    // You can also provide a custom RPC endpoint.
    const endpoint = useMemo(() => clusterApiUrl(network), [network]);

    const wallets = useMemo(
        () => [
            /**
             * Select the wallets you wish to support, by instantiating wallet adapters here.
             *
             * Common adapters can be found in the npm package `@solana/wallet-adapter-wallets`.
             * That package supports tree shaking and lazy loading -- only the wallets you import
             * will be compiled into your application, and only the dependencies of wallets that
             * your users connect to will be loaded.
             */
            new FakeWalletAdapter(),
        ],
        []
    );

    return (
        <ConnectionProvider endpoint={endpoint}>
            <WalletProvider wallets={wallets} autoConnect>
                <WalletModalProvider>
                    <WalletMultiButton />
                    <WalletDisconnectButton />
                    { /* Your app's components go here, nested within the context providers. */ }
                </WalletModalProvider>
            </WalletProvider>
        </ConnectionProvider>
    );
};

Usage

import { WalletNotConnectedError } from '@solana/wallet-adapter-base';
import { useConnection, useWallet } from '@solana/wallet-adapter-react';
import { Keypair, SystemProgram, Transaction } from '@solana/web3.js';
import React, { FC, useCallback } from 'react';

export const SendOneLamportToRandomAddress: FC = () => {
    const { connection } = useConnection();
    const { publicKey, sendTransaction } = useWallet();

    const onClick = useCallback(async () => {
        if (!publicKey) throw new WalletNotConnectedError();

        const transaction = new Transaction().add(
            SystemProgram.transfer({
                fromPubkey: publicKey,
                toPubkey: Keypair.generate().publicKey,
                lamports: 1,
            })
        );

        const signature = await sendTransaction(transaction, connection);

        await connection.confirmTransaction(signature, 'processed');
    }, [publicKey, sendTransaction, connection]);

    return (
        <button onClick={onClick} disabled={!publicKey}>
            Send 1 lamport to a random address!
        </button>
    );
};

Packages

This library is organized into small packages with few dependencies. To add it to your dApp, you'll need core packages, some wallets, and UI components for your chosen framework.

Core

These packages are what most projects can use to support wallets on Solana.

packagedescriptionnpm
baseAdapter interfaces, error types, and common utilities@solana/wallet-adapter-base
reactContexts and hooks for React dApps@solana/wallet-adapter-react

Wallets

These packages provide adapters for each wallet. You can use the wallets package, or add the individual wallet packages you want.

packagedescriptionnpm
walletsIncludes all the wallets (with tree shaking)@solana/wallet-adapter-wallets
avanaAdapter for Avana@solana/wallet-adapter-avana
backpackAdapter for Backpack@solana/wallet-adapter-backpack
bitkeepAdapter for BitKeep@solana/wallet-adapter-bitkeep
bitpieAdapter for Bitpie@solana/wallet-adapter-bitpie
bloctoAdapter for Blocto@solana/wallet-adapter-blocto
braveAdapter for Brave@solana/wallet-adapter-brave
cloverAdapter for Clover@solana/wallet-adapter-clover
coin98Adapter for Coin98@solana/wallet-adapter-coin98
coinbaseAdapter for Coinbase@solana/wallet-adapter-coinbase
coinhubAdapter for Coinhub@solana/wallet-adapter-coinhub
exodusAdapter for Exodus@solana/wallet-adapter-exodus
glowAdapter for Glow@solana/wallet-adapter-glow
huobiAdapter for HuobiWallet@solana/wallet-adapter-huobi
hyperpayAdapter for HyperPay@solana/wallet-adapter-hyperpay
keystoneAdapter for keystone@solana/wallet-adapter-keystone
ledgerAdapter for Ledger@solana/wallet-adapter-ledger
magicedenAdapter for Magic Eden@solana/wallet-adapter-magiceden
mathwalletAdapter for MathWallet@solana/wallet-adapter-mathwallet
nekoAdapter for Neko@solana/wallet-adapter-neko
nightlyAdapter for Nightly@solana/wallet-adapter-nightly
nufiAdapter for NuFi@solana/wallet-adapter-nufi
phantomAdapter for Phantom@solana/wallet-adapter-phantom
safepalAdapter for SafePal@solana/wallet-adapter-safepal
saifuAdapter for Saifu@solana/wallet-adapter-saifu
salmonAdapter for Salmon@solana/wallet-adapter-salmon
skyAdapter for Sky@solana/wallet-adapter-sky
slopeAdapter for Slope@solana/wallet-adapter-slope
solflareAdapter for Solflare@solana/wallet-adapter-solflare
solletAdapter for Sollet@solana/wallet-adapter-sollet
solongAdapter for Solong@solana/wallet-adapter-solong
strikeAdapter for Strike@solana/wallet-adapter-strike
solongAdapter for Solong@solana/wallet-adapter-solong
tokenaryAdapter for Tokenary@solana/wallet-adapter-tokenary
tokenpocketAdapter for TokenPocket@solana/wallet-adapter-tokenpocket
torusAdapter for Torus@solana/wallet-adapter-torus
trustAdapter for Trust Wallet@solana/wallet-adapter-trust

UI Components

These packages provide components for common UI frameworks.

packagedescriptionnpm
react-uiComponents for React (no UI framework, just CSS)@solana/wallet-adapter-react-ui
material-uiComponents for Material UI with React@solana/wallet-adapter-material-ui
ant-designComponents for Ant Design with React@solana/wallet-adapter-ant-design
angular-material-uiComponents for Angular Material UI@heavy-duty/wallet-adapter-material

Starter Projects

These packages provide projects that you can use to start building a dApp with built-in wallet support. Alternatively, check out solana-dapp-next for a more complete framework.

packagedescriptionnpm
exampleDemo of UI components and wallets@solana/wallet-adapter-example
create-react-app-starterCreate React App project using React UI@solana/wallet-adapter-create-react-app-starter
material-ui-starterParcel project using Material UI@solana/wallet-adapter-material-ui-starter
react-ui-starterParcel project using React UI@solana/wallet-adapter-react-ui-starter
nextjs-starterNext.js project using React UI@solana/wallet-adapter-nextjs-starter

Community

Several packages are maintained by the community to support additional frontend frameworks.

Build from Source

  1. Clone the project:
git clone https://github.com/solana-labs/wallet-adapter.git

2.   Install dependencies:

cd wallet-adapter
yarn install

3.   Build all packages:

yarn build

4.   Run locally:

cd packages/starter/react-ui-starter
yarn start

Download details:

Author: solana-labs
Source code: https://github.com/solana-labs/wallet-adapter
License: Apache-2.0 license

#svelte #javascript #typescript #blockchain #solana 

What is GEEK

Buddha Community

Modular TypeScript Wallet Adapters and Components for Solana Apps

Develop a Secure Mobile Wallet App

AppClues Infotech offers digital wallet mobile app development services to build secure and easy-to-use mobile wallet app for your business. Let’s talk with us about the complete procedure of getting a highly secure mobile wallet app developed with advanced features & technologies.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#develop a secure mobile wallet app #develop a secure mobile wallet app #develop a secure mobile wallet app #top digital wallet app development company #best e-wallet app development services #best e-wallet app development services

Make Digital E-Wallet Mobile App for Secure Online Transaction

Get a customized fully-protected digital wallet app, e-wallet app & mobile payment app. AppClues Infotech offers feature-rich and fully-protected eWallet App Development Services for Android, iPhone and Wearable Devices.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#e-wallet app development company in usa #hire mobile wallet app developers #hire mobile wallet app developers #hire mobile wallet app developers #mobile wallet app development #develop e-wallet mobile app for payment

Marcus Anthony

1614316441

Mobile Wallet Development, eWallet App Development, Digital Wallet App Development

With new technology and innovations born every day, we, at Appdupe, as the leading digital wallet app development company, are transforming and updating our services. So if you are an entrepreneur who wants to digitize your finance business, then here’s your best shot to join hands with us for developing a blue-chip e-wallet app.

#mobile wallet development #mobile wallet app development #e wallet app development #e wallet development #digital wallet app development #mobile wallet app developer

Marcus Anthony

1612264920

Mobile Wallet Development, eWallet App Development, Digital Wallet App Development

Digital wallet apps are becoming the talk of the town, because of the extreme ease of transferring, and paying funds they are providing. If you are an aspiring entrepreneur, looking for an idea, then digital wallet app development is your call. All you have to do is start your journey to the Appdupe team and rest is assured. Don’t wait further!Mobile wallet development

#mobile wallet development #mobile wallet app development #e wallet app development #e wallet development #digital wallet app development #mobile wallet app developer

Digital Wallet App Development | Mobile Payment App Development | e-Wallet App Development

Are you looking for the most trusted and custom mobile wallet development company in USA? We at AppClues Infotech offering reliable & productive mobile wallet app development services with advanced technologies and functionalities. Hire dedicated mobile wallet designer & developers from us at the best price for your business requirements.

Our Mobile Wallet App Development Services
• Custom Mobile Wallet App Solution
• Cryptocurrency Wallet App Development
• Digital Wallet App Development
• Mobile Payment App Development
• Mobile Wallet UI/UX Designing

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#digital wallet app development #mobile payment app development #e-wallet app development #digital e-wallet app development company #digital wallet app development services #ewallet app development