1.2.10 • Published 5 months ago

morpherwallet-sdk v1.2.10

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

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

```js
     let provider = morpherWallet.getProvider();
  1. Request accounts to initialize connection to wallet

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

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

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

7 months ago

1.2.10

5 months ago

1.2.0

10 months ago

1.2.8

10 months ago

1.2.7

10 months ago

1.2.6

10 months ago

1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

3 years ago