morpherwallet-sdk
v1.2.8
Published
This is an SDK for the zero-wallet to simply add it to the website. Drop-In Replacement for Fortmatic/Portis/MetaMask
Downloads
44
Readme
Morpher Wallet SDK
Morpher Wallet SDK allows dapps to connect to the Morpher Wallet via a standard web3 Provider
Installing Wallet SDK
Check available versions:
# yarn yarn info morpherwallet-sdk versions # npm npm view morpherwallet-sdk versions
Install latest version:
# yarn yarn add morpherwallet-sdk # npm npm install morpherwallet-sdk
Check installed version:
# yarn yarn list morpherwallet-sdk # npm npm list morpherwallet-sdk
Basic Usage
Initialize SDK
import MorpherWallet from "morpherwallet-sdk"; const morpherWallet = new MorpherWallet( "{rds link to chain}", {chain id}, { show_transaction: true, confirm_transaction: true, show_message: true, confirm_message: true, env: "live", }, );
Make web3 Provider
let provider = morpherWallet.getProvider();
Request accounts to initialize connection to wallet
const addresses = provider.request({ method: 'eth_requestAccounts', });
Make more requests
provider.request('personal_sign', [ `0x${Buffer.from('test message', 'utf8').toString('hex')}`, addresses[0], ]);
Handle wallet events
morpherWallet.onLogin((eth_address: string, email: string) => { console.lo }); morpherWallet.value.onLogout(() => { console.log('logged out') });
Use with Viem
import { createPublicClient, createWalletClient, custom } from "viem"; let provider = morpherWallet.getProvider(); let wallet_client = createWalletClient({ chain: chain, account: wallet_eth_address as `0x${string}`, transport: custom(provider), }); let accounts = await wallet_client.getAddresses(); console.log('accounts', accounts)