🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

solana-wallets-vue-2

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solana-wallets-vue-2

Integrates Solana wallets in your Vue 2 applications.

0.1.6
latest
Source
npm
Version published
Weekly downloads
4
-20%
Maintainers
1
Weekly downloads
 
Created
Source

Solana Wallets Vue 2

Integrates Solana wallets in your Vue 2 applications.

⚡️ View demo

solana-wallets-vue

Installation

To get started, you'll need to install the solana-wallets-vue-2 npm package as well as the wallets adapters provided by Solana.

npm

npm install solana-wallets-vue-2 @solana/wallet-adapter-wallets

yarn

yarn add solana-wallets-vue-2 @solana/wallet-adapter-wallets

Setup

Next, you can install Solana Wallets Vue use as local or global component.
You have to set up Solana Wallets Adapters and prop it to the component instance.

To register as global component:

import { WalletMultiButton } from 'solana-wallets-vue-2'
import 'solana-wallets-vue-2/styles.css'
Vue.component('wallet-multi-button', WalletMultiButton)

To use as a local component:

<template>  
     <div>
        <wallet-multi-button :wallets="wallets" auto-connect />
     </div>
 </template>  
  
<script>  
import {
  CoinbaseWalletAdapter,
  GlowWalletAdapter,
  PhantomWalletAdapter,
  SlopeWalletAdapter,
  SolflareWalletAdapter,
  TorusWalletAdapter,
} from '@solana/wallet-adapter-wallets'

import { WalletAdapterNetwork } from '@solana/wallet-adapter-base'  
import { WalletMultiButton } from 'solana-wallets-vue-2'
import 'solana-wallets-vue-2/styles.css'

export default {
  name: "App",
  components: { WalletMultiButton },
  data() {
    return {
      wallets: [
        new CoinbaseWalletAdapter(),
        new PhantomWalletAdapter(),
        new GlowWalletAdapter(),
        new SlopeWalletAdapter(),
        new SolflareWalletAdapter({ network: WalletAdapterNetwork.Devnet }),
        new TorusWalletAdapter(),
      ],
    };
  },
};   
</script>  

If you prefer the dark mode, simply provide the dark boolean props to the component above.

<wallet-multi-button :wallets="wallets" dark></wallet-multi-button>  

Parameters

Props(Parameter)TypeDefaultDescription
walletsArray[]The wallets available the use.
autoConnectbooleanfalseWhether or not we should try to automatically connect the wallet when loading the page.
autoConnectbooleanfalseWhether or not we should try to automatically connect the wallet when loading the page.
onError(error)voiderror => console.error(error)Will be called whenever an error occurs on the wallet selection/connection workflow.
localStorageKeystringwalletNameThe key to use when storing the selected wallet type (e.g. Phantom) in the local storage.
localStorageKeystringwalletNameThe key to use when storing the selected wallet type (e.g. Phantom) in the local storage.

Usage

You can access the wallet store adding ref to the component instance:

<wallet-multi-button ref="walletConnector" :wallets="wallets" dark></wallet-multi-button>  

Next, you can access by call walletStore in ref:

...  
computed: {  
     publicKey () {
         return this.$refs.walletConnector.walletStore?.publicKey 
     },
}  

walletStore references

The table below shows all the properties and methods you can get from useWallet().

Property/MethodTypeDescription
walletsArrayThe wallets available the use.
autoConnectbooleanWhether or not we should try to automatically connect the wallet when loading the page.
wallet`Walletnull`
publicKey`PublicKeynull`
readyStatestringThe ready state of the selected wallet.
readybooleanWhether the selected wallet is ready to connect.
connectedbooleanWhether a wallet has been selected and connected.
connectingbooleanWhether we are connecting a wallet.
disconnectingbooleanWhether we are disconnecting a wallet.
select(walletName)voidSelect a given wallet.
connect()voidConnects the selected wallet.
disconnect()voidDisconnect the selected wallet.
sendTransaction(tx, connection, options)PromiseSend a transation whilst adding the connected wallet as a signer.
signTransactionFunction or undefinedSigns the given transaction. Undefined if not supported by the selected wallet.
signAllTransactionsFunction or undefinedSigns all given transactions. Undefined if not supported by the selected wallet.

Keywords

vue

FAQs

Package last updated on 18 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts