@horizonx/aptos-wallet-connector
TypeScript icon, indicating that this package has built-in type declarations

0.12.1 • Public • Published

aptos-wallet-connector

Detail

Provides a common interface for aptos wallets in a minimal package.

Function Description Arguments
connect connect wallet -
account returns current account -
network returns current network name -
chainId returns current chainId -
isConnected returns connected or not -
disconnect disconnect wallet -
signAndSubmitTransaction call connected wallet to sign and submit transction payload: Transaction Payload
(optional) options: TransactionOptions
onAccountChanged add listener callback on account changed listener: (address: string | undefined) => VoidFunction (removeListener)
onNetworkChanged add listener callback on network changed listener: (payload: { network: string, chainId?: number}) => VoidFunction (removeListener)

Installation

yarn add @horizonx/aptos-wallet-connector

or

npm install @horizonx/aptos-wallet-connector
Some wallets require additional dependencies.
  • Blocto

    Dependencies:

    @blocto/sdk
    

    Example:

    import BloctoSDK from '@blocto/sdk'
    import { connect, WalletInterface, WalletType } from '@horizonx/aptos-wallet-connector'
    
    const walletClient: WalletInterface = await connect('blocto', new BloctoSDK({ aptos: { chainId: 1 } }).aptos!)

How to Use

import { connect, connectWalletWithProvider, WalletInterface, WalletType } from '@horizonx/aptos-wallet-connector'

const type: WalletType = 'aptos' // 'aptos'(petra) | 'fewcha' | 'martian' | 'pontem'
const walletClient: WalletInterface = await connect(type)

// If an external provider is required, it must be passed as the second argument.
const type: WalletType = 'blocto' // 'blocto'
const walletClient: WalletInterface = await connect(type, provider)

See code example.

Features

Function Description Arguments
connect connect a wallet type: Wallet Type
provider?: External Provider
isSupportedWalletType returns passed arg is supported wallet type or not arg: any
lastConnectedWalletType returns last connected wallet type -

Constant Description type
SUPPORTED_WALLETS array of supported wallet type strs WalletType[]
ERRORS dictionary of errors Record<ErrorType, string>

Errors

ErrorType Description
NOT_INSTALLED wallet not installed
NOT_CONNECTED wallet not connected
CANCELLED request cancelled by user

Supported Wallets

Petra Fewcha Martian Pontem Blocto
version 1.0.5 0.4.8 1.1.4 2.1.1 0.3.9-beta
connect
account
network
chainId
isConnected
disconnect
signAndSubmitTransaction
onAccountChanged
onNetworkChanged

Readme

Keywords

Package Sidebar

Install

npm i @horizonx/aptos-wallet-connector

Weekly Downloads

0

Version

0.12.1

License

MIT

Unpacked Size

60.3 kB

Total Files

51

Last publish

Collaborators

  • horizonx-dev