morpherwallet-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.2.10 • Public • Published

Morpher Wallet SDK

npm

Morpher Wallet SDK allows dapps to connect to the Morpher Wallet via a standard web3 Provider

Installing Wallet SDK

  1. Check available versions:

      # yarn
      yarn info morpherwallet-sdk versions
    
      # npm
      npm view morpherwallet-sdk versions
  2. Install latest version:

    # yarn
    yarn add morpherwallet-sdk
    
    # npm
    npm install morpherwallet-sdk
  3. Check installed version:

    # yarn
    yarn list morpherwallet-sdk
    
    # npm
    npm list morpherwallet-sdk

Basic Usage

  1. 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",
         },
     );
  2. Make web3 Provider

         let provider = morpherWallet.getProvider();
  3. Request accounts to initialize connection to wallet

    const addresses = provider.request({
      method: 'eth_requestAccounts',
    });
  4. Make more requests

    provider.request('personal_sign', [
      `0x${Buffer.from('test message', 'utf8').toString('hex')}`,
      addresses[0],
    ]);
  5. Handle wallet events

      morpherWallet.onLogin((eth_address: string, email: string) => {
         console.lo
      });
    
     morpherWallet.value.onLogout(() => {
         console.log('logged out')
     });
  6. 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)
    

Readme

Keywords

none

Package Sidebar

Install

npm i morpherwallet-sdk

Weekly Downloads

788

Version

1.2.10

License

ISC

Unpacked Size

696 kB

Total Files

23

Last publish

Collaborators

  • beornb
  • jimmyverdoora
  • tomw1808