@omnisat/lasereyes-vue
v0.0.10
Published
Set up guide newer
Downloads
38
Readme
lasereyes-vue
Set up guide newer
@omnisat/lasereyes-vue
is a Vue-specific package built on top of lasereyes-core
. It provides Vue composables and wallet functionality to make it easy to integrate Bitcoin wallet support into Vue applications.
This package simplifies the interaction between your Vue app and various Bitcoin wallets, allowing you to focus on building dApps with a seamless user experience.
Key Concepts
Composables
@omnisat/lasereyes-vue
provides the useLaserEyes
composable to interact with wallets within your Vue components. This composable gives you access to the connected wallet and its state, leveraging Vue's reactive system.
Example of using the useLaserEyes
composable:
import { useLaserEyes } from '@omnisat/lasereyes-vue'
export default {
setup() {
const { address, connect } = useLaserEyes()
return {
address,
connect,
}
},
}
Or in a <script setup>
component:
<script setup>
import { useLaserEyes } from '@omnisat/lasereyes-vue'
const { address, connect } = useLaserEyes()
</script>
<template>
<div>
<template v-if="address">
<p>Connected: {{ address }}</p>
</template>
<template v-else>
<button @click="connect">Connect Wallet</button>
</template>
</div>
</template>
Features
- Vue Composables: Use the
useLaserEyes
composable to manage wallet connections and state in your components - Reactive State: Fully integrated with Vue's reactivity system
- TypeScript Support: Built with TypeScript for better type safety and developer experience
- Wallet Integration: Support for multiple Bitcoin wallets including Unisat, Xverse, OKX, and more
API Reference
The useLaserEyes
composable returns an object with the following properties and methods:
State Properties
address
: Current wallet addresspaymentAddress
: Payment addresspublicKey
: Public key of the connected walletpaymentPublicKey
: Payment public keyaccounts
: Array of connected accountsbalance
: Current balance (as a number)connected
: Boolean indicating if wallet is connectedisConnecting
: Boolean indicating if connection is in progressisInitializing
: Boolean indicating if initialization is in progressnetwork
: Current networkprovider
: Current wallet provider
Wallet Detection
hasLeather
: Computed property for Leather wallet availabilityhasMagicEden
: Computed property for Magic Eden wallet availabilityhasOkx
: Computed property for OKX wallet availabilityhasOyl
: Computed property for OYL wallet availabilityhasPhantom
: Computed property for Phantom wallet availabilityhasUnisat
: Computed property for Unisat wallet availabilityhasWizz
: Computed property for Wizz wallet availabilityhasXverse
: Computed property for Xverse wallet availability
Methods
connect()
: Connect to a walletdisconnect()
: Disconnect the current walletgetBalance()
: Get the current balancegetInscriptions()
: Get inscriptions for the connected walletgetNetwork()
: Get the current networkgetPublicKey()
: Get the public keypushPsbt(psbt: string)
: Push a PSBT transactionsignMessage(message: string, toSignAddress?: string)
: Sign a messagerequestAccounts()
: Request connected accountssendBTC(to: string, amount: number)
: Send BTC to an addresssignPsbt(psbt: string, finalize = false, broadcast = false)
: Sign a PSBT transactionswitchNetwork(network: NetworkType)
: Switch to a different network
Installation
npm install @omnisat/lasereyes-vue
# or
yarn add @omnisat/lasereyes-vue
# or
pnpm add @omnisat/lasereyes-vue
Contributing
Contributions are welcome! Feel free to submit pull requests or open issues in the GitHub repository.
License
@omnisat/lasereyes-vue
is MIT licensed.